Forums / Developer / How to split large objects into several edit pages

How to split large objects into several edit pages

Author Message

Lazaro Ferreira

Tuesday 17 August 2004 4:12:52 am

Hi,

We would like to split a large object edit tpl, into several shorter edit templates, to make easier the input of data ( something like EZP setup wizard )

Is there any standard approach to deal with this, in EZP 3.4 ?

Thanks
Lazaro Ferreira

Lazaro
http://www.mzbusiness.com

Bård Farstad

Tuesday 17 August 2004 5:00:21 am

Hi Lazaro,

this is currently not directly supported. But you could probably make it by changing the edit template. The the problem is that some datatypes require input, which means that you would need to add hidden variables for the different fields. You could e.g. make a switch which will show the fields for the current step while at the same time having the oter attribute variables as hidden variables.

You could step through the steps using the store draft buttong and adding a status variable about the position. E.g. /content/edit/42/2/(position)/first_step then you would change the form target to /content/edit/42/2/(position)/second_step based on the current posistion.

--bård

Documentation: http://ez.no/doc

Lazaro Ferreira

Tuesday 17 August 2004 6:17:38 am

Hi bård,

I got it, We will try!

Thanks
Lazaro Ferreira

 

Lazaro
http://www.mzbusiness.com

Bård Farstad

Tuesday 17 August 2004 7:01:07 am

Great,

let us know how you progress. I know other people are interested in this as well. It was also discussed on the summer conference this year.

--bård

Documentation: http://ez.no/doc

J-A Eberhard

Wednesday 06 September 2006 9:34:55 am

Hi,

Two years later I have the same question...

Did you came up with a nice solution?

Regards

Open Source Solution Provider
Open-Net Ltd Switzerland
http://www.open-net.ch

J-A Eberhard

Tuesday 19 September 2006 12:03:56 pm

FYI. I solved the problem with a css based solution.
Testing if arguments have value and hidding them with the css properties. Like that I submit everytime the whole object but the user only see relevant fields.

Open Source Solution Provider
Open-Net Ltd Switzerland
http://www.open-net.ch

Claudia Kosny

Tuesday 19 September 2006 1:07:31 pm

Hi

I think I would have done it by writing a small extension for this using Bards suggestion. Rough idea:
Replace the edit template with an override where the form action is a script of your extension. The script takes the posted variables and gives them back to the template which makes hidden input types out of them and shows the next batch of the attributes to edit. This is repeated until we are at the last batch. The the form action is changed to the original form action again so when we post this, EZ gets the data for the full form.

Advantages:
- Easy to implement (for a specific class, a general solution is a bit more complicated as you would have to group the attributes somehow).
- Easy to implement the possibility to get back and forward between the single pages/
- No objects with partial data are created, if the user cancels there are no leftovers to cleanup
- Also works for objects with required attributes.

Problems:
- Validation is done only at the end, not at each page (although this could certainly be implemented)
- Posted data might be very long (although not longer than with the one-page edit)

Greetings from Luxembourg

Claudia

Norman Leutner

Tuesday 19 September 2006 1:24:17 pm

Hi,
we've done this on a project and used an extension to create the objects as a draft version.
After the last step, the object is published.

As already metioned by Claudia, we had to validate all attributes by hand.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

J-A Eberhard

Tuesday 19 September 2006 3:09:45 pm

Hi,

You talked about an extension, could you publish it?
Would such an extension been able to take care of the Enhanced ObjectRelation datatype?

Thanks

Open Source Solution Provider
Open-Net Ltd Switzerland
http://www.open-net.ch

Norman Leutner

Tuesday 19 September 2006 11:21:25 pm

The extension we made was for an online auction system so its a bit to special for your needs, but it shouldn't be a problem to build you one one.

Creating an draft object is simple:

 function createDraftObject($parent_node_id, $owner_id, $class_name, $attributes )
   {    
      $class =& eZContentClass::fetchByIdentifier( $class_name );

      if ( !is_object( $class ) )
      {
         die("Class not found");
      }
    
     
      $parent_node =& eZContentObjectTreeNode::fetch($parent_node_id);
      
      // set associated object to parent node (folder object) 
      if ( !is_object( $parent_node ) )
      {
         die("Could not set parent node");
      }
      
      
      $parent_content = $parent_node->attribute('object');
      $section_id = $parent_content->attribute( 'section_id' );

      
      // create the object
      $content_object =& $class->instantiate( $owner_id, $section_id );

      //assign new object to parent node
      $node_assignment =& eZNodeAssignment::create( array(
            'contentobject_id' => $content_object->attribute( 'id' ),
            'contentobject_version' => $content_object->attribute( 'current_version' ),
            'parent_node' => $parent_node->attribute( 'node_id' ),
            'is_main' => 1 ) );
      $node_assignment->store();

      // Set status to draft for the content object version
      $content_object_version =& $content_object->version(
              $content_object->attribute( 'current_version' ) );
      $content_object_version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT);
      $content_object_version->store();             


      // Assign the attributes
      $content_attributes =& $content_object_version->contentObjectAttributes();
      foreach ($content_attributes as $content_attribute)
      {
         // Each attribute has an attribute called 'identifier' that identifies it.
         $attribute_identifier = 
            $content_attribute->attribute("contentclass_attribute_identifier");

         if (isset($attributes[$attribute_identifier]))
         {          
            $this->importAttribute($attributes[$attribute_identifier], $content_attribute);
            $contentClassAttribute = $content_attribute->attribute( 'contentclass_attribute' );
            $dataTypeString = $contentClassAttribute->attribute( 'data_type_string' );
            //echo $dataTypeString."<br/>";
         }
         else
         {        
            eZDebug::writeDebug( 'attribute value not found for '.
                  $class_name.".".$attribute_identifier);
         }
      }

      $id = $content_object->attribute('id');
      
      return eZContentObject::fetch($id);
   }

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh