Hot to browse node tree from php

Author Message

Daniele Nocentini

Thursday 29 July 2010 9:05:30 am

Hi,

I need to do an import script that importa some data from csv file but I need to make function for user to choice a node where he want to import data.

How can I do in my php script a function like browsing for related objects in a standard content edit template?

Antica Bottega Digitale srl
http://www.abd.it

Thiago Campos Viana

Thursday 29 July 2010 12:34:47 pm

I don't know what exactly you want, but to fetch a node in php you use:

$mynode = eZContentObjectTreeNode::fetch($node_id);

To get the children of this node you use:

$nodechildren=$mynode->children(); //you can use foreach...

To get some attribute of a node you use:

$mynode->attribute('name_of_attribute');

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Daniele Nocentini

Thursday 29 July 2010 2:35:03 pm

What I want to do is a template with a form button calles "choice node" like a "add relations" button in a content edit template.

When user click choice node button he can browse in a tree of contents for choice a specific node.

I need this function for create a php script for import data from csv file. A user must specify in which content node he want to import data from csv file so I need a browsing node function like related objects or embedding object of online editor.

Antica Bottega Digitale srl
http://www.abd.it

Thiago Campos Viana

Thursday 29 July 2010 4:23:31 pm

You could give a look in the code on kernel/role/assign.php , then create a module, make some changes in that code, so when the user click in a link and goes to your module/yourview, he will be redirected to content/browse and then goes back to your module. So you can get selected nodes with $http->postVariable( 'SelectedObjectIDArray' ).

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Daniele Nocentini

Friday 30 July 2010 12:39:20 am

Ok thanks Thiago you put me in the right way.

But now when I choice a node with content/browse and press select button the script go to edit page, How can I go back to my script?

And another question is how can I make a single selection for a node (radio button)?

Antica Bottega Digitale srl
http://www.abd.it

Thiago Campos Viana

Friday 30 July 2010 4:41:29 am

I think you specify in this way:

eZContentBrowse::browse( array( 'action_name' => 'YourAction',
'from_page' => '/yourmodule/yourview/' . $someID,
'cancel_page' => '/yourmodule/yourview/' . $someID),
$Module );

You will need to make some changes in browse.ini and include 'YourAction' settings.

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

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 29 2025 23:51:59
Script start
Timing: Jan 29 2025 23:51:59
Module start 'layout'
Timing: Jan 29 2025 23:51:59
Module start 'content'
Timing: Jan 29 2025 23:51:59
Module end 'content'
Timing: Jan 29 2025 23:51:59
Script end

Main resources:

Total runtime0.0108 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.0041 589.2734151.2109
Module start 'layout' 0.00410.0019 740.484436.6484
Module start 'content' 0.00600.0038 777.132898.1563
Module end 'content' 0.00970.0010 875.289137.9922
Script end 0.0108  913.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002119.4747140.0002
Check MTime0.00109.2009140.0001
Mysql Total
Database connection0.00065.367210.0006
Mysqli_queries0.001514.001830.0005
Looping result0.00000.083710.0000
Template Total0.00087.510.0008
Template load0.00065.774810.0006
Template processing0.00021.700910.0002
Override
Cache load0.00043.862310.0004
General
dbfile0.00021.837580.0000
String conversion0.00000.066140.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