Forums / Developer / Hot to browse node tree from php
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
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.
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' ).
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)?
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.