Forums / Developer / Hot to browse node tree from php

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

eZ debug

Timing: Jan 17 2025 22:54:12
Script start
Timing: Jan 17 2025 22:54:12
Module start 'content'
Timing: Jan 17 2025 22:54:13
Module end 'content'
Timing: Jan 17 2025 22:54:13
Script end

Main resources:

Total runtime0.9766 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 587.7188180.8281
Module start 'content' 0.00560.8629 768.5469585.6875
Module end 'content' 0.86850.1080 1,354.2344341.3672
Script end 0.9765  1,695.6016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.4472210.0002
Check MTime0.00150.1547210.0001
Mysql Total
Database connection0.00050.051210.0005
Mysqli_queries0.895391.67532030.0044
Looping result0.00190.19892010.0000
Template Total0.948097.120.4740
Template load0.00280.287120.0014
Template processing0.945296.784920.4726
Template load and register function0.00010.014610.0001
states
state_id_array0.00110.109910.0011
state_identifier_array0.00080.084820.0004
Override
Cache load0.00240.2469360.0001
Sytem overhead
Fetch class attribute can translate value0.00130.132030.0004
Fetch class attribute name0.00120.128080.0002
XML
Image XML parsing0.00200.203830.0007
class_abstraction
Instantiating content class attribute0.00000.0021120.0000
General
dbfile0.00600.6127330.0002
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/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/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs