drahcirtt
unread,Jan 21, 2009, 3:31:12 PM1/21/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.
<?php
//*****************************************************************//
// 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</
div>\n";
echo "<div class=\"block_body\">\n";
eval('?>' . $page_content . '<?php ');
echo "</div>\n<div class=\"block_footer\"></div>\n</div>\n";
?>