PHP: get nodes and compare to class_id

Author Message

Jorge estévez

Wednesday 24 March 2010 7:33:09 am

Helo,

This is ezpublish versión 3.10.1

I am searching in PHP for all items at ezcontentobject table, and I assumed that the “Id” was the Node_id of the item but it seems It isn’t. How can I get the node_Id of the node? Or is there a table I can search for all objects and get the node_id of each one of them?

I need to:

Access the database table XXXX

Get all nodes, and compare (foreach) if each one of them belongs to class No XXX

If someone has a tip, I am making my first approach to database searching.

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Bruce Morrison

Wednesday 24 March 2010 5:10:49 pm

Hi Jorge

The DB table that holds nodes is ezcontentobject_tree but you'll have to join this with ezcontentobject to access the class. Have a look at http://ez.no/doc/ez_publish/technical_manual/3_10/concepts_and_basics/content_management/the_content_node for some of the underlying info.

I'm not sure exactly what you are trying to achieve but typically in eZ Publish you utilise the API to retrieve data and don't do direct queries on the DB. The easiest way to retrieve the data you are after is a template fetch query from PHP:

$nodes = eZFunctionHandler::execute( 'content', 'tree',
    array( 'parent_node_id'     => $top_node_id,
           'class_filter_type'  => 'include',
           'class_filter_array' => array( 'article' ) ) );

As the filtering is done in the fetch there is no need to loop through the returned nodes and check class type.

This is quite flexible as you can utilise the same parameters as used in templates.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jorge estévez

Thursday 25 March 2010 5:10:33 am

Thanks

Is there a way to donwload the whole API Reference instead of reading online?

Best Regards

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Jorge estévez

Thursday 25 March 2010 5:15:18 am

Found at http://pubsvn.ez.no/doxygen/3.10/

thanks again!

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

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 02:09:07
Script start
Timing: Jan 18 2025 02:09:07
Module start 'layout'
Timing: Jan 18 2025 02:09:07
Module start 'content'
Timing: Jan 18 2025 02:09:08
Module end 'content'
Timing: Jan 18 2025 02:09:08
Script end

Main resources:

Total runtime1.1914 sec
Peak memory usage4,096.0000 KB
Database Queries61

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.1328152.6250
Module start 'layout' 0.00580.0032 741.757839.4453
Module start 'content' 0.00901.1809 781.2031548.6953
Module end 'content' 1.18980.0015 1,329.898412.1563
Script end 1.1913  1,342.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2669160.0002
Check MTime0.00140.1140160.0001
Mysql Total
Database connection0.00080.066210.0008
Mysqli_queries1.138995.5929610.0187
Looping result0.00060.0518590.0000
Template Total1.162197.520.5810
Template load0.00210.178920.0011
Template processing1.159997.359420.5800
Template load and register function0.00030.021810.0003
states
state_id_array0.00160.135910.0016
state_identifier_array0.00110.093020.0006
Override
Cache load0.00180.1519310.0001
Sytem overhead
Fetch class attribute can translate value0.00140.114320.0007
Fetch class attribute name0.00160.134750.0003
XML
Image XML parsing0.00060.049320.0003
class_abstraction
Instantiating content class attribute0.00000.001250.0000
General
dbfile0.00080.0632160.0000
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
4content/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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.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: 9

Time used to render debug report: 0.0001 secs