Helper classes?

Author Message

Kristofer Pettersson

Wednesday 04 January 2006 1:21:33 pm

I just figured out that I need to fetch the ezcontentattributes even though I might have a correct instance of a ezcontentobject.

$attrs = $target_object->contentObjectAttributes();
foreach( $attrs as $attr ) {
  switch( $attr->contentClassAttributeIdentifier() ) {
    case 'first_name': $first_name = $attr->attribute( 'data_text' );
     break;
    case 'last_name': $last_name = $attr->attribute( 'data_text' );
     break;
    case 'approved_by': $approved_by = $attr->attribute( 'data_text' );
     break;
   }
}

This is a really bothersome way to do it, and I wonder if there exist a easier way to automatically stuff the attributes in a much more simple (untyped) structure like an array with the contentClassAttributeIdentifier mapped against relevant value?

Something like this would be nice:
$doc = getDocumentById( $id );
echo "Document title: ".$doc->getAttribute("title");

No meta data unless I request it! :^)

Kristofer Pettersson

Thursday 05 January 2006 5:07:35 am

It seems the above method isn't enough for the ezselection class. How do I load the selected value from the target document?

I've tried the following:

The obvious: $target_document->attribute( 'approved_by' )->content();
The less obvious: $attr->attribute( 'approved_by' )->content();
The bizare: $attr->dataType()->title();

with no success. :-(

Yelitza Jaramillo

Thursday 05 January 2006 7:07:28 am

Hei Kristofer,

To store data in an ezselection datatype
try this link
http://ez.no/community/forum/developer/storing_content_in_an_ezselection_attribute

To retrieve data


$object_data_map = $target_object->attribute( 'data_map' );
// this returns an array

$aproved_by = $object_data_map[ 'aproved_by' ]->content();
//this will return the option number if the datatype is an ezselection

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 15:56:33
Script start
Timing: Jan 18 2025 15:56:33
Module start 'layout'
Timing: Jan 18 2025 15:56:33
Module start 'content'
Timing: Jan 18 2025 15:56:34
Module end 'content'
Timing: Jan 18 2025 15:56:34
Script end

Main resources:

Total runtime0.9803 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.9063152.6094
Module start 'layout' 0.00620.0027 741.515639.4063
Module start 'content' 0.00890.9699 780.9219507.3125
Module end 'content' 0.97880.0014 1,288.234412.2031
Script end 0.9802  1,300.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3152160.0002
Check MTime0.00140.1413160.0001
Mysql Total
Database connection0.00110.114910.0011
Mysqli_queries0.929594.8225570.0163
Looping result0.00050.0522550.0000
Template Total0.940495.920.4702
Template load0.00210.210120.0010
Template processing0.938495.727420.4692
Template load and register function0.00020.022910.0002
states
state_id_array0.00400.406610.0040
state_identifier_array0.00100.107120.0005
Override
Cache load0.00170.1687250.0001
Sytem overhead
Fetch class attribute can translate value0.00110.113920.0006
Fetch class attribute name0.00100.104940.0003
XML
Image XML parsing0.00200.202220.0010
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00270.2706150.0002
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs