coding fetch in PHP

Author Message

anne martinet

Thursday 21 August 2008 9:56:59 am

Hi,

I don't understand how coding this function, in my file .php

{def $video_mm=fetch('content','list',hash(     'parent_node_id', 365,
                                                'class_filter_type',include,
                                                'class_filter_array',array('video_flash_mm')))}

André R.

Thursday 21 August 2008 11:35:24 am

In php you should really use the api, most of the objects that you use in templates (nodes, objects, classes, object attributes..) have a php class in kernel/classes/.
And most of those classes have fetch functions.

Your template example would look like this in php:

$nodes = eZContentObjectTreeNode::subTreeByNodeID(array(
    'ClassFilterType' => 'include',
    'ClassFilterArray' => array( 'video_flash_mm' ),
    'Depth' => 1,
    'DepthOperator' => 'eq'
    ), 365);

Or if you want to sort by the parent node:

$node  = eZContentObjectTreeNode::fetch( 365 );
$nodes = $node->subTree(array(
    'ClassFilterType' => 'include',
    'ClassFilterArray' => array( 'video_flash_mm' ),
    'Depth' => 1,
    'DepthOperator' => 'eq',
    'SortBy' => $node->sortArray() 
    ));

Note: If you plan to use most of the attributes, then set the LoadDataMap parameter to true.
Note2: For counts there usually similar functions that takes the same parameters, in the above case it would be ::subTreeCountByNodeID() and ->subTreeCount()

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

anne martinet

Friday 22 August 2008 2:20:02 am

Thanks,

I have again difficulties to read API, and to find interesting functions.

I code your answer :

$v=eZContentObjectTreeNode::subTreeByNodeID(
        array(  'ClassFilterType' => 'include',
                'ClassFilterArray' => array('video_flash_mm'),
                'Depth' => 1,
                'DepthOperator' => 'eq'),
        365
);

foreach ( $v as $o )
{
        echo $o->attribute('name')." --- et son etat ".$dm['etat_ezstring']."<br/>";
}

But I don't see the string for $dm['etat_ezstring'], I see this : Object id #47
How can I see this content???

thanks

Pascal Specht

Friday 22 August 2008 3:57:41 am

Hello,

is $dm['etat_ezstring'] a datamap ?
Probably, you should use $dm['etat_ezstring']->content() instead.

</Pascal>

anne martinet

Friday 22 August 2008 4:13:04 am

effectively, ($dm=$o->dataMap();) $dm is datamap.

and yes, $dm['etat_ezstring']->content() write content of attribute

:)
thanks
:)

anne martinet

Friday 22 August 2008 5:41:18 am

But if I want change content of an attribute to an instance (of classe 'video_flash_mm') how can I do?

thanks

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 31 2025 06:27:48
Script start
Timing: Jan 31 2025 06:27:48
Module start 'layout'
Timing: Jan 31 2025 06:27:48
Module start 'content'
Timing: Jan 31 2025 06:27:48
Module end 'content'
Timing: Jan 31 2025 06:27:48
Script end

Main resources:

Total runtime0.0122 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.0313151.1953
Module start 'layout' 0.00500.0020 739.226636.6172
Module start 'content' 0.00700.0040 775.843894.2500
Module end 'content' 0.01100.0012 870.093837.9922
Script end 0.0122  908.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002218.4421140.0002
Check MTime0.00108.1454140.0001
Mysql Total
Database connection0.00086.571110.0008
Mysqli_queries0.001814.822130.0006
Looping result0.00000.072410.0000
Template Total0.00097.810.0009
Template load0.00086.224910.0008
Template processing0.00021.541110.0002
Override
Cache load0.00054.347510.0005
General
dbfile0.00032.206080.0000
String conversion0.00000.041140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs