eZ Community » Forums » Setup & design » Edit Multiple Objects within one...

Edit Multiple Objects within one template

Edit Multiple Objects within one template

Tuesday 05 August 2008 1:42:27 pm - 10 replies


Can we edit multiple objects of same or different classes with one template?


Tuesday 03 January 2012 9:27:46 pm

Anyone has an answer for this - it would be of great help!

Tuesday 03 January 2012 9:41:32 pm

Hello Christopher and Mohammad,


I'm afraid this is not supported (at all) within the default functionality of eZ Publish (4.6.x / Today)


You may be able to create such functionality through a custom extension module view(s).


Best wishes. I hope this helps ...




Wednesday 04 January 2012 1:44:26 pm


Thank you for your reply!

Would you care to give a quick description of how you would go about to build such a module - what elements etc? Nothing more than a couple of lines would be helpful to point us in the right direction!

best regards,


Thursday 12 January 2012 8:55:15 pm

I've developed a solution which is working pretty well for me.  I first looked an extension called powercontent which allows you to submit a form to create an object without creating and opening a draft first (which is the default behaviour and the cause of the limitation).  However I found the code out of date and more complex than what I needed, so I wrote a new extension called directcontent.  This extension serves the same purpose but is much simpler. It would be great to develop it into a more robust extension for sharing but I haven't had time.  Here's how it works:

In my template I have a bunch of forms for different objects I want the user to be able to create.  The forms use action="directcontent/create" instead of the default to direct the forms to my custom module.  Below all of the forms there is a submit button which activates a jquery script to gather all of the forms and submit them one at a time.  During submission the forms are hidden and a message is presented to the user like: item 2 of 5 is being submitted.  It does take a while for each of the forms to be submitted but that's just the way ezPublish is, creating new objects is slow.

Server side, the module just receives the data and uses the ezComponents createAndPublish function to create and publish the new object.  It's surprisingly straight forward.  The key is you have to figure out what the name and value have to be for each datatype to ensure that it stores correctly.  

Major warning with this is that it doesn't include any of the validation and other checks that are normally done so there are some risks.  Also, digging around in the code I think it would be possible to create a custom action for the normal ezpublish action or edit module to avoid a whole new module. 

It would be great to get others involved to help develop a more robust solution.  Here is some code for you:

The Module

 <?php$module = array( 'name' => 'directcontent' );
$ViewList = array(); $ViewList['create'] = array( 'script' => 'create.php',                             'params' => array( 'ClassIdentifier', 'ParentNodeID' ),                             'functions' => array( 'create' ) );$ViewList['update'] = array( 'script' => 'update.php',                             'params' => array( 'ContentObjectID' ),                             'functions' => array( 'update' ) );
// setting user permissions required by our module:$FunctionList = array();$FunctionList['create'] = array();$FunctionList['update'] = array();


 <?php/** * File containing the eZ Publish view implementation. * * @copyright Fraser Hore * @license GPL * @version 1.0.0 * @package issat_directcontent */
$http = eZHTTPTool::instance();
// CreatorID$user =& eZUser::currentUser();$creatorID =& $user->attribute( 'contentobject_id' );
// Class Identifierif(!$http->hasPostVariable( 'ClassIdentifier' ))     {eZDebug::writeError( 'Missing mandatory parameter ClassIdentifier' );}else    {$classIdentifier = $http->postVariable( 'ClassIdentifier' );}
// Parent Node IDif(!$http->hasPostVariable( 'ParentNodeID'))     {eZDebug::writeError( 'Missing mandatory parameter ParentNodeID (the parent nodeid)' );}else    {$parentNodeID = $http->postVariable( 'ParentNodeID' );}
// Fetch the class object for the ClassIdentifier to determine attribute identifiers to compare to the posted data$classObject = eZContentClass::fetchByIdentifier( $classIdentifier );$classAttributes = $classObject->dataMap();
// Attribute list - ensures that only attribute identifiers from the class are used$attributeList = array_intersect_key( $_POST, $classAttributes );
// Create the data import array $params = array(); $params['creator_id'] = $creatorID; $params['class_identifier'] = $classIdentifier; $params['parent_node_id'] = $parentNodeID; $params['attributes'] = $attributeList;
// Create and publish the new object$contentObject = eZContentFunctions::createAndPublishObject( $params );                                ?>

Template with foreach creating the forms

 {foreach $organisation_types as $item}                            {if not($rated_organisation_types|contains($item.name))}                            <div class="form-elements">                                <form method="post" action={"directcontent/create/"|ezurl}>                                    <input type="hidden" name="ClassIdentifier" value="organisation_experience" />                                    <input type="hidden" name="ParentNodeID" value="{$user-node.node_id}" />                                    <span class="organisation-type">                                        <input type="hidden" name="organisation_type" value="{$item.contentobject_id}" />{$item.name}                                    </span>                                    <span class="internal toolTip" title="Have worked inside an organisation of this type (e.g. as an employee)">                                        <input type="checkbox" name="employee" value="1"/>                                    </span>                                    <span class="external toolTip" title="Have worked as an external advisor to an organisation of this type">                                        <input type="checkbox" name="external" value="1"/>                                    </span>                                    <span class="ssr-activity toolTip" title="Have worked on SSR activities with an organisation of this type">                                        <input type="checkbox" name="ssr_activity" value="1"/>                                    </span>                                    <span class="required">                                    {foreach $rating_scale_organisation as $level}                                        <span class="level {$level.name} toolTip" title="{$level.data_map.description.content.output.output_text|strip_tags())}">                                            <input type="radio" name="experience_level" value="{$level.contentobject_id}"/>                                        </span>                                    {/foreach}                                    </span>                                </form>                            </div>                            {/if}                            {/foreach}                            <button class="button" onclick="submitForms('edit-organisation-experience')">Submit</button>

Javascript for submitting the forms

 {ezscript_require( array( 'ezjsc::jquery' ) )}<script type="text/javascript" src="{'libs/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js'|ezdesign('no')}" charset="utf-8"></script>
 <script type="text/javascript" charset="utf-8">    <!--{literal}        function submitForms( formsContainerID )        {            var forms = $('#'+formsContainerID).find('form:has(input:checked[type=radio])'); // Have to create a more sophisticated filter e.g. ignore if required inputs, text areas, options, etc. have no value or content            var numberOfForms = forms.length;            if ( numberOfForms )            {                var counter = 0;                $('#'+formsContainerID).html( '<div class="loading">Please wait, publishing item 1 of '+numberOfForms+'.</div>' );                forms.each(function(index) {                    index = ++index;                    var url = this.action;                    var data = $(this).serialize();                    $.ajax({                        type: "POST",                        url: url,                        data: data,                        success: function(data,status) {                            counter = ++counter;                            $('#'+formsContainerID).html('<div class="loading">Please wait, publishing item '+(counter)+' of '+numberOfForms+'.</div>');                            if(index == numberOfForms){location.reload();}                            },                        error:function(){                            $('#'+formsContainerID).html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');                            }                    });                });            }            else            {            alert('Please complete one or more of the items before submitting');            }        }        {/literal}--></script>

Sorry the code above isn't pretty but that's the way it pastes. Just paste it into your IDE to prettify it.

I hope this helps! I'd be happy to help turn this into a more robust extension for sharing in the ezCommunity Projects section if others think it would be useful.



Thursday 12 January 2012 9:44:50 pm

Hello Fraser,


Thank you very much for sharing the solution you have developed thus far. This is serious progress that should not be ignored or forgotten. We must take action now to ensure the future of the users tomorrow and beyond or this could still slip away as an unusable solution for most users by default (sorry, but this is not really enough / complete for the users who need this work most)


This is frequently requested feature. So much so my first thought to your reply is ...


I think you ensure more users continue to suffer indefinitely without properly sharing your extension via projects.ez.no -and- github.com (please don't use svn repositories any longer, it's beyond a bad idea at this point in our communities history).

The newer users who beg for this feature so regularly have no abliity to create this on their own, nor can they often implement solutions based on badly formatted source code snippets shared in a forum message (not your fault share.ez.no + ezoe + custom tag for source code -eats source code formatting every day and every time someone tries to paste content into it and i hate it-)

This is really why I must insist that you have not yet done enough (your not bad but I am challenging you to be like myself; co-operate with supporters of your work and help us take it to the next level; true turn key solution with full documentation; ready to use out of the box by -anyone-.

Until you have shared the extension (as is; don't bother cleaning it up if you lack time; just post a complete zip of it) via github.com (at least; projects can come later as optional but strongly recommended if you'll make the time) ... users continue to struggle greatly regardless without limitation.


I would gladly assist you and the community by volunteering to do the time consuming work of refactoring the entire solution you publish until it is -idiot- proof and able to be used by any user regardless of specific experience.

Also I write extensive and comprehensive extension documentation in most of our BC contributed extensions so we think we could help ensure this solution is properly documented and ready to use out of the box without troubles (in most use cases).


I hope this helps ... reach a point where users are finally set free from this daunting and frustrating superficial limitation within eZ Publish.


I -really- am compelled to help you complete this work and mature it beyond its current state. Please consider my requests carefully. I am dead serious. I will do all the work you do not have time for and will do an amazing job on your behalf. Just please ... please don't ignore our cries for you to complete the sharing we would prefer / require to take your ideas to the next logical level towards a complete solution anyone would be beyond proud to install, use and recommend to others ...

You can reach me through skype at almost any time simply send a message to 'brookinsconsulting' and ask for Heath. I'd be happy to discuss my ideas further ....

Thank you for your time and consideration.




Friday 13 January 2012 12:01:32 am

Fraser and Heath,

Thank you very much for your replies!

I really hope you will be able to join resources so that this initative will bring about a functional, downloadable extension from the projects.ez.no!

Friday 13 January 2012 1:35:38 am

Hello Christopher,

Thank you for your kind words of support of these ideas and goals! I need all the support I can get these days especially emotional (i'm prolly just fine with the code work etc)

I'm sure going to try my hardest possible and push further into the beyond than most dare to tread!


Most people -do not- understand how serious this issue is to other users.

This would for me be a proof of concept that actually goes further ...

How many other views in eZ publish only allow you to work on 1 or only a small number of objects per action / at a time ... quite a few. And for the key views, many users regularly request multi object + action support for these views; a prime that comes to mind is the older ezapprove2 moderation of content. Now that's not a imeediat goal as it is deprecated and not supported anylonger in favor of 'object states' based solutions as more flexible so that may not be a good example of another view that could use a similar solution but it is another example which was valid until object states were available and reliable ...I can't think of any more and I'm in a real rush this evening so I'll move on for now. This has potential beyond this first extension / solution I think at least in concept. I think this is worth noting for future efforts ... IF Fraser engages / shares with me the extension to get started on the work required to make the difference our users -deserve-


I'm watching the forums and projects like a hawk for Fraser's next move (no pressure lol) ...


Hey have a great weekend guys! I know I'm going to try to take a break and rest up ... unless Fraser shares the code we requested and I can get started completing the work this weekend ... I would rather have a solid beta ready for you guys to test on monday than catch up on my missing sleep. 


Update: @Fraser You can, if you wish or prefer to invest virtually no futher efforts but still help us a little more, simply email us a zip of the extension to   brookinsconsulting+ez@gmail.com

All I was really hoping was to encourage you to share your current work in a more complete way to help the rest of use get started quickly into the work of re-factoring, documenting and preparing for more serious testing by others. Normally it's a gut reaction to recommend posting it using projects and/or github as that is what we are used to ourselves. I realize you may not wish to create a project / publish public source code you do not intend on supporting and maintaining. If you could still see it through to the end by at least sharing a copy of your current work to use as a working basis It would lessen the work I would need to do to re-create this solution solely based on your existing (partial?) code snippets ...




Modified on Friday 13 January 2012 3:31:23 am by // Heath

Friday 13 January 2012 4:51:21 pm

Heath, thanks for the encouragement and push happy.gif Emoticon  I've finally taken the time to set up a github account and create a repository for this project.  Check it out at https://github.com/fraserhore/fh_directcontent.  At least you can now have a look at my code and start thinking about how we could take this forward.  

While creating this extension I had to study quite hard the ez modules for action and content and I found them to be quite difficult to follow and not well commented so it was quite hard to figure out what was going on. Especially for the actual creation and publishing of objects, I never did really figure out exactly how it works.  It would be nice if that code were better organised and commented.  Then it would be easier to hook into.  Also it seems that there is a lot of older legacy code where things could be done much more clearly and cleanly using ZetaComponents.  

I think you will be surprised at how simple this code actually is (which is what partly leads me to believe that the kernel code could be more concise) because the ZetaComponents createAndPublish function makes it pretty easy.  

It would be good to hook into the standard ezpublish validation workflow it possible, or replicate it.  Also, as I mentioned, it's a bit tricky figuring out what data to send to ezPublish so that all attributes are stored properly.  to make this extension useful for others we'd have to include templates that create the right form elements for each datatype.

What are your thoughts on next steps?

Saturday 14 January 2012 11:34:12 am

Hello Fraser,


Thank you very much for your investment here by taking the time to do the work required (not so much eh?) to share with the community your extension. 

Congratulations Fraser we truly appreciate your continued support!


My time left today is short. I have many thoughts and questions brewing.

I fear I will be away for some time till tomorrow. When I return I hope to have more to share. Such as questions, worthy thoughts, ideas ...


First thoughts on code today

  • Static object class and attribute code and usage
  • Static template code
  • Static PHP code
  • Basic error handling
  • Basic jQuery JavaScript and Ajax
  • Minimal module extension
  • Minimal design templates
  • No documentation

I think i'm going to enjoy playing with it and re-reviewing / comparing it to powercontent extension.


A friendly warning ..

Though a friend rather ominously reminds me just now that, "re-creating the content module is a tricky business, tread with great care ... safe journey my friend". 


First thoughts on improvements needed

First thoughts on improvements needed (comparable to most key features of content module)

- Validation

- Dynamic node edit gui html (properties and attribute display edit/create form code)

- Documentation: Skeleton to minimal (while in flux)

-  More specific plan of action in terms of the design solutions / directions available


Ok, I can't wait on all my questions

It's late I must be over looking something, did you comment this out before commit on purpose or for some other reason, I wonder what will happen when I run this uncommented code or rather why it commented in the first place.

I was merely trying to think of the first things that would happen when I tried to test while reviewing in the near future.



Apache Zeta Components != eZ Components + Patches

One thing to note here. While Apache Zeta Components .... is used in eZ Publish (in a way / persay)

This will always be a misnomer until the Zeta project is even able to make it's first release since it's graduation into Apache.

Though it has been many years so far and they are a long way away from reaching this milestone of their first release.

So in reality only Zeta may not itself be being used within eZ Publish rather a private copy modified for the needs of eZ Systems / eZ Publish.

Think of what is distributed with eZ Publish up to today since the departure of eZ Components project from eZ and graduation into Apache ... think of it as the last version of eZ Components + patches (private and possible some from Zeta today unknown) could be being distributed here as what is used in eZ Publish. In the future eZ Publish's 'components' actual source code (regardless of the name/moniker) may more closely match the Zeta's own source code (this is not the case today for certain) [0]

Also please realize that the PHP class and method you mention in reference to Zeta are actually eZ Publish kernel class methods and not really related to Zeta directly (or at all to my knowledge).


More soon! Stay tuned happy.gif Emoticon


I hope this helps ...





[0] http://share.ez.no/forums/install-configuration/ezc-in-4.2011

Modified on Monday 16 January 2012 6:59:27 am by // Heath

Monday 16 January 2012 7:14:30 am

@ Fraser


I was unable to make much progress this weekend.

I think I had made some incorrect assumptions as to the current state of the solution you were sharing, my apologies.

I think it will take me a bit more time to try to find the best design for making a dynamic and flexible solution that gets the job done for everyone.


I did want to post an update at least here in the forums.


One question on my mind at the end of today ...


If you you could choose how to handle error's with attribute content while trying to publish a modified node any way you wished what would you prefer, How would you like to handle generic publishing errors and more specific attribute input validation errors?


Also I see you were trying to use a more ajax based solution in your original source code.

Do you have a specific preference if the same functionality could be more easily provided today within the context of server side requests (at least at first?).

I think starting with server side is best because it provides a more solid foundation with which to build upon and go further by adding client side form submission requests / processing / validation / error handeling / etc at a later point. This is because server side requests are still the most common context and while ajax is growing, it's not quite the same for all users.


My primary concern is that I did not see much in the way of error handling in your original ajax / javascript source code ... this would be a critical component to include in a flexible and properly consistent solution. 


Also I am looking more into the powercontent extension to see what lessons it can share with regard to some the related requirements. It seems that the powercontent extension relies on the content/edit module view indirectly, there may be useful ways to avoid having to duplicate aspects of the features provided by content/edit (in a server side context) within the solution we are talking about in general.


I look forward to you thoughts Fraser. Thank you again for your continued support!


I hope this helps ...





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

36 542 Users on board!

Forums menu

Proudly Developed with from