Simple "editable" block work-around

Showing 1-7 of 7 messages
Simple "editable" block work-around drahcirtt 1/21/09 12:31 PM
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";
?>
Re: Simple "editable" block work-around Nick 1/21/09 3:02 PM
i have no idea if this works but it sounds very clever. i am gonna try
it. well done
Re: Simple "editable" block work-around drahcirtt 1/22/09 8:13 AM
I've added this file to the files in this group for people to download
if they want less hassle...

http://groups.google.com/group/pixie-cms/web/block_pageslug.php

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.
Re: Simple "editable" block work-around Scott 1/24/09 7:09 AM
Fantastic little work around, thanks for sharing it!

Scott
Re: Simple "editable" block work-around cls.co.za 3/14/09 12:43 AM
Sublte and effective nice. Very clever. Ta
Re: Simple "editable" block work-around enache 5/1/09 4:47 PM

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
Re: Simple "editable" block work-around Scott 5/8/09 8:12 AM
Hi Enache
Apologies but I do not fully follow your email... maybe trying
uploading a visual of what you are trying to achieve?

http://groups.google.com/group/pixie-cms/files?upload=1

Scott