Adding blocks to theme templates
Permalink 2 users found helpful
Hi, OK I have been able to add the autonav block to a theme, but now I want to add the search block and potentially other blocks. Can anyone advise as to whether this is possible, i've tried pulling the data from the database in what i think is the same way as the autonav block...?? Thanks
The working autonav block used in template:
<div id="search"><?php $bt_main = BlockType::getByHandle('search'); $bt_main->controller->title = 'Search'; $bt_main->controller->buttonText = 'Go'; $bt_main->controller->baseSearchPath = ''; $bt_main->controller->resultsURL = 'search-results'; $bt_main->render(''); ?> </div>
The working autonav block used in template:
<div id="navigation"> <?php $bt_main = BlockType::getByHandle('autonav'); $bt_main->controller->displayPages = 'top'; $bt_main->controller->orderBy = 'display_asc'; $bt_main->controller->displaySubPages = 'none'; $bt_main->render('templates/header_menu'); ?> </div>
Awesome, thanks! I think i'd been staring at it too long, lol
This is great! I've used this for the news items with the previous next block. Check it out!
<div id="next-previous-in-template"> <?php $bt_main=BlockType::getByHandle('next_previous'); $bt_main->controller->nextLabel=t('next post'); $bt_main->controller->previousLabel=t('previous post'); $bt_main->controller->parentLabel=t('show all in list'); $bt_main->controller->showArrows=1; $bt_main->controller->loopSequence=0; $bt_main->controller->orderBy='display_desc'; $bt_main->render('view'); ?> </div>
$bt_main->render('view');
rather than just
$bt_main->render('');