Include a block in a page type with PHP

Permalink
I have a page type and I want to call the next - prev block underneath some content.

I'm wondering if I can call it with php. I tried adding it to the defaults in page-type but it always shows up before the content that I'm trying to show.

Thoughts?

bryanlewis
 
JohntheFish replied on at Permalink Reply
JohntheFish
I solved a similar requirement(though not with Prev/Next) by adding an extra area to the theme, so I had areas 'Main' and 'MainBelow'.

I could then put the block in the default for 'MainBelow', and it would always be below anything in Main and would not be in the way of any new block added to Main.
bryanlewis replied on at Permalink Reply
bryanlewis
Yea I thought about that too but i didn't want the client to manually add it to each new page.

I'm trying to implement this but its not working as of right now for me.

http://www.concrete5.org/index.php?cID=79703...

I think its because I'm pasting the block code into a packages view.php file. Not my actual theme?
JohntheFish replied on at Permalink Reply
JohntheFish
I thought using page type deafults was acceptable as that was what you said you were trying out first, but now using a default for the MainBelow area of the page type.

You can also use permissions to block the client from editing the MainBelow area, so having got the block onto every page with a page type default in Main Below, it is relatively tamper proof.
beebs93 replied on at Permalink Reply
beebs93
If you have advanced permissions on I'd say JohnTheFish's suggestion would work well.

Another method would be to programatically create the block using the BlockType class and put said code in the page type itself.

An example with the autonav block:

$bt_main = BlockType::getByHandle('autonav');
$bt_main->controller->mainCollection = $c;
$bt_main->controller->displayPages = 'top';
$bt_main->controller->orderBy = 'display_asc';
$bt_main->controller->displaySubPages = 'relevant';
$bt_main->controller->displaySubPageLevels = 'all';
$bt_main->render('templates/customnav');


It's almost the same as creating a block through the UI and setting the options as above.

I say "almost" because (someone feel free to tell me different if I'm way off) creating blocks this way ignores any caching rules set specifically in the block's controller. So this manually-created block may prevent full page caching (unless in Emergency Mode). If you have a large site with heavy traffic it may become a problem.
bryanlewis replied on at Permalink Reply
bryanlewis
This is exactly what I'm looking for I will try this out and see if it works! Thanks beebs93!
beebs93 replied on at Permalink Reply
beebs93
You're welcome - hope it works out :)