Hard-coding dynamic blocks
Permalink 1 user found helpful
Hi,
Is there a way to hard-code blocks into a template so that a client can't change them? For example, I want to hard-code an auto-nav into my template so my client client can't add another block to the same area and destroy the layout?
Thanks,
osu
Is there a way to hard-code blocks into a template so that a client can't change them? For example, I want to hard-code an auto-nav into my template so my client client can't add another block to the same area and destroy the layout?
Thanks,
osu
I'll look into advanced permissions now then. Thanks katz515
Hi, I use this code in most of my themes. It's much easier to maintain than advanced permissions and default blocks.
It's a bit tricky to get the correct variables and values without the gui, but that doesn't mean you can't do it.
Btw, you can use a similar code for any block, but most blocks need a proper entry in the database in order to work correctly so the results are not always as expected.
Another way to hard code blocks into the template is add them to the scrapbook and then call them from there. There's a post somewhere explaining how to do it. I'll see if I find it and will post a link.
It's a bit tricky to get the correct variables and values without the gui, but that doesn't mean you can't do it.
$bt = BlockType::getByHandle('autonav'); $bt->controller->displayPages = 'top'; $bt->controller->orderBy = 'display_asc'; $bt->controller->displaySubPages = 'none'; $bt->controller->displaySubPageLevels = 'all'; echo $bt->render('view');
Btw, you can use a similar code for any block, but most blocks need a proper entry in the database in order to work correctly so the results are not always as expected.
Another way to hard code blocks into the template is add them to the scrapbook and then call them from there. There's a post somewhere explaining how to do it. I'll see if I find it and will post a link.
Here's another thread describing other ways of doing it.
Look for Tony's suggestion towards the middle, although the other suggestions are good aswell.
http://www.concrete5.org/index.php?cID=13668...
Look for Tony's suggestion towards the middle, although the other suggestions are good aswell.
http://www.concrete5.org/index.php?cID=13668...
Thanks martogertel, the scrapbook option works great for me - still going to look into Advanced Permissions as they look like they could be useful for other areas of this site I'm working on.
Thanks to both of you for the help
Thanks to both of you for the help
I have problem getting this based on your example.
How would you add image block from image/file attribute?
How would you add image block from image/file attribute?
http://www.concrete5.org/help/building_with_concrete5/installation/...