page type displaying blocks automatically

Permalink
::Programmatically::
I am trying to understand how by using page types I can have a block appear on the page when a user selects the page type when adding a page.

Lets say would like to have an add block appear in the sidebar area automatically when the user selects a page type. I would like this add to still be positionable and I would like the page creator to still have the option of deleting the block.

I do not want to hard code the block into the page template just have it appear in one of the editable regions.

I have seen this in the Simpleblog block.

Also when I have created the page templates how do I install them?

 
ThemeGuru replied on at Permalink Reply
ThemeGuru
Create your page type for example Sidebar (which is sidebar.php). Then go to your dashboard > pages & themes > Page Types > Sidebar > Defaults. There you can set the default blocks.

I.e. adding some dummy text.

Hope that helps.
Tao replied on at Permalink Reply
Tao
dashboard > pages and themes > page types > default
No good?
doodle replied on at Permalink Reply
I need to know how to do it from code. I have made a package that includes template pages. I need to make the pages have a certain block on it when some one installs the package.

From looking at other peoples packages that I have downloaded it must be being set inside the database. I am still digging around as to where.
DarkGhostHunter replied on at Permalink Reply
I know is kinda late (two years) but, if somebody is still diggin' around, there is the catch.

Have you seen how Concrete5, when you install it with sample content, the Composer for blog_entry already is populated with blocks? It's because of the package installation. So yes, it's made by the installation script of that package in particular (concrete/config/install/packages/standard/content.xml, below <pagetypes>). I think the same procedure is for normal packages.

<pagetypes>
        <pagetype handle="blog_entry" name="Blog Entry" internal="0" icon="template1.png" package="">
            <composer method="PARENT" pagetype="" parent="{ccm:export:page:/blog}">
                <items>
                    <block type="image" name="Header Image" composer-template="header.php"></block>
                    <block type="image" name="Thumbnail Image" composer-template="thumbnail.php"></block>
                    <block type="content" name="Blog Content"></block>
                    <attributekey handle="tags"></attributekey>
                </items>
            </composer>
...


After looking how it works, I came to the conclusion that there is no way to edit the Composer of a custom page_type using just the code inside your theme, except only when the theme is packaged and installed - because it reads and executes [content.xml]. You will have to add these blocks manually through the "Defaults" from Page Types Administration. Packaging a Theme is not difficult if you see "standard" controller.php and content.xml as guidelines, but not a walk in the park either.

While this may be a letdown for many, it's not just so. As seen in the "standard" package from before, you can even add content automatically, add new areas and populate custom block_types. So you may think first about configuring the theme here in the first place, then install it and see how it performs. If something in the db happens, at least you won't bother populating the areas with their respective blocks again.