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:

$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
keeasti
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Hi,
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
keeasti replied on at Permalink Reply
keeasti
Thanks for the quick reply ... I'll try that.
keeasti replied on at Permalink Reply
keeasti
That worked well ... thanks again.

concrete5 Environment Information

Concrete 5.6.3.2

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.