Hardcoded Blocks

Permalink 5 users found helpful
As a company we have been building custom themes with concrete5 for about 6 months solid and one of the things we have hit constantly is how to hardcode two of the blocks into the theme to give our users a better experience. Autonav and Page List being the two in question.

To that end we built the following snippets to make thing easier for the team and as such we felt that they would be useful to all.

Please comment and let us know if they help you, Franz & the team I hope this is ok to put out into public view.

<!-- Hardcoded Auto Nav -->
<?php
   //Start
   $dNav = BlockType::getByHandle('autonav');
   //Set Options
   $dNav->controller->displayPages = 'custom'; //Options ('top', 'second_level', 'third_level', 'above', 'current', 'below', 'custom')
   $dNav->controller->orderBy = 'display_asc'; //Options ('display_asc', 'chrono_desc', 'chrono_asc', 'alpha_asc', 'alpha_desc', 'display_desc')
   $dNav->controller->displayPagesCID = '71';  //Only to be used for displayPages = 'custom'                  
   $dNav->controller->displaySubPages = 'all'; //Options ('none', 'enough', 'enough_plus1', 'all', 'custom')
   $dNav->controller->displaySubPageLevelsNum = ''; //Only to be used if displaySubPages = 'custom'
   //Render (Always Required!)
   $dNav->render('view'); //Set Custom Template Here
?>

and...
<!-- Hardcoded Page List -->
<?php
   //Start
   $dPlst = BlockType::getByHandle('page_list');
   //Set Options
   $dPlst->controller->num = '2'; //Number of Pages in to display in block
   $dPlst->controller->selectCTID = '2'; //ID of page type (Value is found in Option List *** View Source in edit mode of block to see ***)
   $dPlst->controller->displayFeaturedOnly = '1'; //Options ('1', '0') 
   $dPlst->controller->displayAliases = '1'; //Options ('1', '0')
   $dPlst->controller->paginate = '1'; //Options ('1', '0')
   $dPlst->controller->cParentID = '71'; //Set for pages beneath a specific page if not set as 1
   $dPlst->controller->orderBy = 'display_asc'; //Options ('display_asc', 'chrono_desc', 'chrono_asc', 'alpha_asc', 'alpha_desc')
   $dPlst->controller->truncateSummaries = '1'; //Options ('1', '0')
   $dPlst->controller->truncateChars = '128'; //Number to be set if Summaries required as above
   //Render (Always Required!)


These blocks are built based on the tutorials and documentation provided PLEASE test before inserting into a live site

Have fun

Justin

darwinje
 
tallacman replied on at Permalink Reply
tallacman
Thank you, Justin. This is helpful.

steve
darwinje replied on at Permalink Reply
darwinje
No Problems Steve
samkitson replied on at Permalink Reply
Hi Jeredit

Thanks for this, it's really useful. I was wondering whether you know how to display pages under a specific page when using the page list hardcode. I've had a dig through the controller for page lists but can't seem to find the info I need.

Many thanks in advance!
imran replied on at Permalink Reply
Hi jeredit,
Thanks for this cool Hardcoded. i have question that how to hardcoded for date-nav in theme, or any other blocks to hardcode any steps or something useful to know how to hardcode?
tsdonohue5 replied on at Permalink Reply
Doesn't display all subpages in V5.5.

Amazing how something so simple is so difficult to find out.
erswelljustin replied on at Permalink Reply
erswelljustin
Hi tsdonohue5, I haven't tried this method with 5.5 yet I will be today so I will let you know what I find!
zoinks replied on at Permalink Reply
Yep. Should be documented. Wild goose chases get really tiresome.

EDIT: thanks again to Jordan Lev, man of the hour 24/7...
http://c5blog.jordanlev.com/blog/2012/04/hard-coded-autonav-options...