This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Suggestions » Standard "Create here" selection

Standard "Create here" selection

Standard "Create here" selection

Monday 19 June 2006 11:34:33 pm - 8 replies


It would be very useful to add a ini setting were you could define the type of class you normally would create under a given node.

Takes this structure for example:

Ez publish (2)
. . . News (61)
. . . . . . National (62)
. . . . . . Local (63)
. . . Images (83)
. . . Attachments (68)


In this case it would be natural to create an article object under News, an image object under Images, a file under Attachments and so on...

This could easily be defined in <i>content.ini</i> like this using the <i>node_id</i> as the key:

# /
# / News
# / Images
# / Attachments

And in the <i>design/admin/templates/children.tpl</i> [, override] we could use the <i>$node</i> var to do a "reverse dig" if the current node is not defined to check if the parent is specified in the <i>DefaultClassMap</i>.
First check if the current node is defined in the ini, if not; check if the parent node is, if not; check the parent parent node is, stop...
I don't think it would be relevant for further digging.

<select name="ClassID" onchange="updateLanguageSelector(this)" title="{'Use this menu to select the type of item you wish to create and click the "Create here" button. The item will be created within the current location.'|i18n( 'design/admin/node/view/full' )|wash()}">
       {def $DefaultClassMap=ezini('DefaultCreateHere','DefaultClassMap','content.ini')}

       {def $prefered_class=null}

       {if $DefaultClassMap[$node.node_id]}
           {set $prefered_class = $DefaultClassMap[$node.node_id]}

       {elseif $DefaultClassMap[$node.parent_node_id]}
           {set $prefered_class = $DefaultClassMap[$node.parent_node_id]}

       {elseif $DefaultClassMap[$node.parent.parent_node_id]}
           {set $prefered_class = $DefaultClassMap[$node.parent.parent_node_id]}

       {section var=CanCreateClasses loop=$can_create_classes}
           {if $CanCreateClasses.item.can_instantiate_languages}
               <option{eq($prefered_class, $CanCreateClasses.item.identifier)|choose( '', ' selected' )} value="{$}">{$|wash()}</option>

It is not a timesaver per say, just luxury happy.gif Emoticon
Just a suggestion,


PS! I have tested the code above, it works fine for me.

Modified on Tuesday 20 June 2006 1:49:16 am by Muu Sle

Tuesday 20 June 2006 8:25:43 am


I suggested almost the same for eZ 3.9 happy.gif Emoticon It could be done on class level too (for example images under each image gallery).

I'll definitely try your code. Thanks for sharing it with us!

Tuesday 20 June 2006 9:01:36 am

A slightly modified version for eZ publish 3.7 of Muu Sle's code with support for defaults specified by the content class identifier:

    <select name="ClassID" title="{'Use this menu to select the type of item you wish to create and click the "Create here" button. The item will be created within the current location.'|i18n( 'design/admin/node/view/full' )|wash()}">
    {def $DefaultClassMapByNode=ezini('DefaultCreateHere','DefaultClassMapByNode','content.ini')
        {if is_set($DefaultClassMapByClass[$node.class_identifier])}
            {set $prefered_class = $DefaultClassMapByClass[$node.class_identifier]}

        {if is_set($DefaultClassMapByNode[$node.node_id])}
            {set $prefered_class = $DefaultClassMapByNode[$node.node_id]}
        {elseif is_set($prefered_class)|not}
            {if is_set($DefaultClassMapByNode[$node.parent_node_id])}
                {set $prefered_class = $DefaultClassMapByNode[$node.parent_node_id]}
            {elseif is_set($DefaultClassMapByNode[$node.parent.parent_node_id])}
                {set $prefered_class = $DefaultClassMapByNode[$node.parent.parent_node_id]}
        {section var=CanCreateClasses loop=$can_create_classes}
              <option{eq($prefered_class, $CanCreateClasses.item.identifier)|choose( '', ' selected' )} value="{$}">{$|wash()}</option>
    {undef $DefaultClassMapByNode $prefered_class}

Example INI settings:


First it looks for a default for the class of the current node, then this choice can be overriden for specific nodes. If then still no default is found, it will look for a node default of either the parent node, or the grandparent node.

Modified on Tuesday 20 June 2006 2:58:52 pm by Kristof Coomans

Tuesday 20 June 2006 1:33:51 pm

Agreed, it would be complete when adding support for doing this at class level, very handy!

Friday 27 October 2006 6:04:18 pm


Cool ! This is exactly what I was looking for. Do you know if this code exists as an extension ? Or if I have to create mine ?


Friday 27 October 2006 7:05:15 pm

It's not in an extension yet, but feel free to create one and to post it as a contribution, as long as you give us some credits happy.gif Emoticon

Monday 30 October 2006 12:16:23 pm

In fact, I was searching a way to limit available "create here" choices, not only suggest one.

I thought it was in eZ settings, but can't find where, then I found this post. I'll try to change this code a little to add a way to limit available classes as well in the "create here" function.

I know we can do this with roles & policies, but I want to do this in a more efficient and global manner. I think this is the way. But correct me if I'm wrong or if it already exists.


Tuesday 31 October 2006 11:28:50 am

Apparently, I have 2 profiles with the same email blunk.gif Emoticon

By the way, I made the extension, with the possibility to define available classes by node or class.

Modified on Tuesday 31 October 2006 11:32:54 am by Guillaume Contival

Saturday 27 January 2007 3:48:38 pm

I've packed the modified template for eZ 3.9.0 in an extension and it's in svn now:


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from