Possible to define in page type files the blocks that'll go in the areas?

Permalink
Hi,

I've created a page type that my content managers use to write news stories. I'd like every one of those pages to have a Page List block in the sidebar, listing the latest news. How can I do that, without having the content managers to add that block every time?

I know that in a page type template file I can set up areas through "new Area()". So my question is if it possible to have an area automatically pre-populated with a given block?

Thanks,
Alejandro

View Replies:
ryan replied on at Permalink Reply
ryan
So, the first and easiest way to do it is to go into the dashboard->page types, find your page type, then click defaults. That will put the page in edit mode and you can edit it like a normal page. When you create a page of that type it'll be like the default one you setup.

Also changes you make to those blocks will take affect in the existing pages.

Another way is to do it with code in the template:
<?
$bt = BlockType::getByHandle('autonav');
$bt->controller->displayPages = 'second_level';
$bt->controller->orderBy = 'display_asc';
$bt->controller->displaySubPages = 'relevant_breadcrumb';
$bt->controller->displaySubPageLevels = 'enough';
$bt->render('view');
?>
andrew replied on at Permalink Reply
andrew
This code actually wont' work until 5.1 is released. But the master template approach described above will work right now.
alpeb replied on at Permalink Reply
Thanks!
tmcguire47 replied on at Permalink Reply
Hi,
I have edited the default page under page type. It looks good...what I'd like to clarify is the statement that changes to blocks will "take affect in existing pages."
I have seen that if i add a block, say to the sidebar, then go and create new pages with that page type, it works. Old pages with the same page type do not inherit this new "default" sidebar. Even if i cahnge the page type to full and back to right sidebar, for example.

also, changes to the default do show up on the newly created pages, but only if i modify the block that was there when i created the new page. If i add a new block to the default page type, that block does not show up on the real pages.

To me, this option is pretty powerful. Nobody likes doing the same thing multiple times, like adding a block to each page that already exists. Does it seem like there would be a way to make these default page types act more like a template, that can be applied to existing pages?
thanks,
like most people here, love c5, really trying to get into it.
-tmcguire47
frz replied on at Permalink Reply
frz
If you add something to defaults, only new pages created after the fact will get the new thing you've added.

If you want to update all pages using that type to have the new block you made, its quite simple.
Stay in edit mode.
Instead of editing the specific block, look towards the bottom of the menu of options.
There's a command there called Set on Child Pages (or something along those lines).
That gives you an interface to push the new block out to all, or only specific, pages following the type.

Oh, and yes if you change a block in defaults, any pages that already had it should reflect the changes.
tmcguire47 replied on at Permalink Reply
Thank you, the "Set on Child Pages" is exactly what i need. thanks for taking the time point me in the right direction.
andoro replied on at Permalink Reply
andoro
Hello frz!

Even if the default blocks in a page type are simple blocks instead of global blocks?

I didn't know this...