eZ publish: Custom root node

One of many key features of eZ publish is flexibility. You can customize almost anything from content structure to output presentation. In this short tutorial I will show how to specify a custom default root node class.

By default, eZ publish uses a root node ID 2 in content structure ("Content structure" tab) tree based on the folder class, and in many cases that is sufficient. However, sometimes we want to use our own custom class as the site's front page. A custom class allows us to build a complex front page that uses a different layout than the rest of the site. Rather than extending the default folder class with attributes that are only used on the front page, creating a custom class gives us the flexibility to build a custom front page without impacting the rest of the site.

First we need to create new content class. You can define your new content class in the Administration Interface. Click the Setup tab, then select the Classes option from the left menu. I will not describe this process as it is very well explained in the eZ publish technical manual.

Note that your custom class must be marked as a ?container? in order to display content from within the content structure tree.

Once the content class is ready to use, create a new content object as an instance of your new class somewhere under the root node. Now we can swap the eZ publish root node with the newly created object. Click the left mouse button on the folder icon beside the root node folder name and select ?Advanced->Swap with another node? from the context menu.

In browse mode choose the newly created object and click the ?Select? button.

Done. Now you can edit your root node and populate the attributes of your custom class with content.

Next we need to configure the content structure tree.
Edit the file ?settings/siteaccess/(your_admin_siteaccess)/contentstructuremenu.ini.append.php? and add your class to the list. Your configuration file should contain the following data:

<?php /*
 
[TreeMenu]
ShowClasses[]
ShowClasses[]=folder
ShowClasses[]=user_group
ShowClasses[]=custom_class
 
*/ ?>

Save your settings and clear the cache. After the page reloads, you should see your custom front page in the content structure, similar to the picture below:

Now you can assign a template to your custom class or make a node override for node ID 2 and make nice front page for your site.

Comments

Node swapping

Ur instructions were really helpfull.I really thankful to you .God bless you

I'm precise ...

Hi Björn,

Thanks for comment. I wrote about root node of content structure tree which is node ID 2 (by default, as long as you will not change it). It is mention in text. Pictures also present it ;)

to be precise...

http://ez.no/doc/ez_publish/technical_manual/3_8/concepts_and_basics/content_management/top_level_nodes

Technically you are talking about the top level node "content".

The root node is node 1 not 2... Doh... :-)

Appreciation?

My Amazon.com Wish List

eZ publish™ copyright © 1999-2010 eZ systems as