Embed page list block in template
Permalink 3 users found helpful
I use the following to hard code an auto-nav into a template I'm looking to do the same thing with a page list block displaying only pages under the page I select - anyone know the proper code to do that? Thanks.
$headernav = BlockType::getByHandle('autonav'); $headernav->controller->displayPages = 'top'; $headernav->controller->orderBy = 'display_asc'; $headernav->controller->displaySubPages = 'none'; $headernav->render('view');
why? What's wrong with his approach..
He just need to look into controller.php / db.xml to find the proper properties and it should work imo
He just need to look into controller.php / db.xml to find the proper properties and it should work imo
Remo - That's basically what I'm starting to do, I was just curious if anyone had already done it for a page list. I just have the basics now Is it necessary to have every property the block offers defined in order for it to work? IN other words, do i need to also include truncate summaries, paginate, etc. What I have now isn't working yet.
<?php $pagelist1 = BlockType::getByHandle('page_list'); $pagelist1->controller->num = ''; $pagelist1->controller->cThis = ''; $pagelist1->controller->cParentID = ''; $pagelist1->controller->orderBy = 'display_asc'; $pagelist1->controller->ctID =''; $pagelist1->controller->rss = ''; ?>
there's no answer to that question which is true for all the blocks. I'd have to look into the code..
Some properties are optional, some aren't.
Try to use FireBug, add a page list block with all the properties you want but before you hit "save", inspect all the form elements, the form element name is the var name and the value is the value...
Some properties are optional, some aren't.
Try to use FireBug, add a page list block with all the properties you want but before you hit "save", inspect all the form elements, the form element name is the var name and the value is the value...
Well nothing, I just thought it might be a little easier than having to dig through the code to find the specific values that need to be set. It could potentially get tricky if setting page ID's and things like that. I just thought it might be easier to actually create the block using the normal interface and then pull it into the template from the scrapbook.
Either way works...one might be better than the other just depending on how it is to be used.
Either way works...one might be better than the other just depending on how it is to be used.
I was looking for a way to easily add blocks to the template.php files. I took jgarcia's advice and made scrapbook items, and then used his code to put the blocks into the template pages, and it is working good so far. Thanks!
Yeah I agree... with the exception of the auto-nav block, its much easier running things through the scrapbook rather than trying to figure out all the specifics tied to each individual block.
I have tried both approaches, it works great except RSS.
In the case with scrapbook the feed from the pages don't show up on rss page.
Maybe somebody knows why it can be?
In the case with scrapbook the feed from the pages don't show up on rss page.
Maybe somebody knows why it can be?
I'm not sure if this will work, but try changing line #193 of YOURSITE/concrete/blocks/page_list/tools/rss.php from this:
...to this:
$c = $b->getBlockCollectionObject();
...to this:
$c = Page::getCurrentPage();
hey, jordanlev,
thank you for your response,
but in that file through the path that you've indicated I have just 57 lines and don't have that method getBlockCollectionObject()
I have concrete5.4.1.1 version.. maybe it is some differences due to version?
thank you for your response,
but in that file through the path that you've indicated I have just 57 lines and don't have that method getBlockCollectionObject()
I have concrete5.4.1.1 version.. maybe it is some differences due to version?
I have found it!:)
in the controller for the page list block
changed it, but have an error
"Permission Denied
This page list doesn't use the custom blog template, or you don't have permission to access this RSS feed"
I have custom blog template for it.. but controller the same, what can I do to fix it?
in the controller for the page list block
changed it, but have an error
"Permission Denied
This page list doesn't use the custom blog template, or you don't have permission to access this RSS feed"
I have custom blog template for it.. but controller the same, what can I do to fix it?
Yeah, sorry about that -- I did mean the controller file. But it looks like that isn't working, so unfortunately I don't know how to solve your original problem :(
thanks for trying to help anyways!
So I think I'll leave it not embedded for now
So I think I'll leave it not embedded for now
Of course $b is a Block object, rather than a BlockType object (which you are using) so I'm not really too sure if that makes a difference.