Hard coded pagelist teasers block
Permalink Browser Info Environment
Hi Jordan,
Many thanks for this block ... works a treat.
I tried to hard code a page list block and apply the teasers custom template to it. I used the following code:
Unfortunately, I couldn't get to work though. With the teasers template, everything under where the hard coded block is inserted cuts off.
If I change the last line to use the normal view.php then it works fine but of course sans teasers.
I was wondering whether you have any advice on this at all.
Cheers.
Many thanks for this block ... works a treat.
I tried to hard code a page list block and apply the teasers custom template to it. I used the following code:
$bt = BlockType::getByHandle('page_list'); // grabs the page list block and sets it as the object $bt in this instance $bt->controller->cThis = '1'; // display pages under the current page (I think) - 0 = no, 1 = yes $bt->controller->cParentID = '133'; // if another page enter its ID (cid) - 0 must be entered above for cThis $bt->controller->ctID =''; // only show pages of a particular type(collection Type ID) $bt->controller->num = '5'; // amount to display on a single page $bt->controller->includeAllDescendents = 'true'; // 'true', 'false' $bt->controller->orderBy = 'display_asc'; // display_asc = Display order ascending, display_desc = Display order descending, chrono_asc = Publish date, alpha_asc = By name ascending, alpha_desc = By name descending $bt->controller->rss = '0'; // provide a RSS feed of the pages - 0 = no, 1 = yes $bt->controller->displayFeaturedOnly = '1'; // displays only pages with an attribute of is_featured uses a boolean value - 0 = no, 1 = yes $bt->controller->displayAliases = ''; // 0 = no, 1 = yes $bt->controller->truncateSummaries = '1'; // if a description is used decides whether to shorten it uses a boolean value - 0 = no, 1 = yes $bt->controller->truncateChars = '0'; // amount of characters to shorten the description by. $bt->controller->paginate = '1'; // if more pages then the controller->num decide if you would like the results paginated - 0 = no, 1 = yes $bt->render('templates/teasers'); // Specify a custom template
Unfortunately, I couldn't get to work though. With the teasers template, everything under where the hard coded block is inserted cuts off.
If I change the last line to use the normal view.php then it works fine but of course sans teasers.
I was wondering whether you have any advice on this at all.
Cheers.
Type: | |
---|---|
Status: | In Progress |
I don't recommend hardcoding blocks in your templates -- use a global area instead. I just wrote up a quick blog post about this because I do get this question from time to time and unfortunately most of the advice in the forums is rather outdated on this topic:
http://concrete5tricks.com/blog/dont-hardcode-blocks-use-a-global-a...
Hope that helps!
-Jordan