Simple "editable" block work-around

Skip to first unread message


Jan 21, 2009, 3:31:12 PM1/21/09
to Pixie
Hi there,

In putting together a site for my father-in-law, he wanted blocks, but
wanted to be able to edit them in the same way that he can edit pages.
I know the Pixie devs are working on this for a future release, but
instead of me having to manually update his blocks every time he
wanted to change something, I did a bit of exploring of the code, and
after about 20 minutes, I came up with a work-around "plan"...

Basically, I created a page with the slug of "block1". I then put the
content in that page, and removed it from navigation. Essentially, I
don't use that page as a page in the current Pixie sense - I just use
that page so that I can edit the content of the block. The "trick"
comes in with the special block files I created...

I created a block file (in the admin/blocks folder) called
block_block1.php - note that the bit after the "block_" and before the
".php" matches the slug for the page I created above. In a similar
way, if I wanted a second editable block, I'd create a page with the
slug of "mysecondblock" or whatever, and create another block file
called block_mysecondblock.php - so all you have to do to get this to
work is create a matching block file which uses the slug of the page
you want the contents from.

For all of the editable block_*.php files, the block contents is the
same - you can just copy the following code and put it in your own
block_<<your block content page slug>>.php file, and it should just
work. So, without further ado, here's the code to put in the PHP file
for this work-around to work... (copy everything from the <? to the ?>
inclusive and make sure there are no leading or trailing spaces or
lines around the code.

// Pixie: The Small, Simple, Site Maker. //
// ----------------------------------------------------------------//
// Licence: GNU General Public License v3 //
// Title: Editable block work-around. //
// Usage: Just create a page not in navigation, and then rename //
// this file to be "block_<<slug>>.php" where <<slug>> is //
// the slug of the page you want to use as the content for //
// this block. If you want more than one editable block, //
// create another page, copy this file, and rename it in //
// the same way. To edit the block contents, just edit the //
// page which serves the content (identified by the slug) //
// in the normal fashion. Enjoy. //
// Contributed by: Richard Tanner-Tremaine //

$s = substr(__FILE__, strpos(__FILE__,"block_")+6);
$s = substr($s, 0, strpos($s, ".php"));

extract(safe_row("*", "pixie_core", "page_name='$s'"));
echo "<div id=\"block_$s\" class=\"block\">\n";
echo "<div class=\"block_header\">\n<h4>$page_display_name</h4>\n</
echo "<div class=\"block_body\">\n";
eval('?>' . $page_content . '<?php ');
echo "</div>\n<div class=\"block_footer\"></div>\n</div>\n";


Jan 21, 2009, 6:02:57 PM1/21/09
to Pixie
i have no idea if this works but it sounds very clever. i am gonna try
it. well done


Jan 22, 2009, 11:13:08 AM1/22/09
to Pixie
I've added this file to the files in this group for people to download
if they want less hassle...

Just follow the instructions - i.e. create a page and remove it from
navigation, and then rename this file accordingly (replace "pageslug"
with the slug of the page you want to use for content).

Note that this only works with static pages.


Jan 24, 2009, 10:09:43 AM1/24/09
to Pixie
Fantastic little work around, thanks for sharing it!


Mar 14, 2009, 3:43:57 AM3/14/09
to Pixie
Sublte and effective nice. Very clever. Ta


May 1, 2009, 7:47:23 PM5/1/09
to Pixie

hy, first of all a big thank for all the developers and especially
drahcirtt who done that, i dont know if my post is good to be here but
after i apply what drahcirtt made i have something in mind that i
cannot do it and i need help if you are wiling to give it offcourse.
I wish if its posibile to extract this block of content like a simple
page i mean to have only the content on that page, because i want to
have a link to the page only with the content for showing her in a
popup lets say, do you think you can help me, i don;t know if i was
clear enough, sorry for my english, thanks


May 8, 2009, 11:12:48 AM5/8/09
to Pixie
Hi Enache
Apologies but I do not fully follow your email... maybe trying
uploading a visual of what you are trying to achieve?

Reply all
Reply to author
0 new messages