Forums / Setup & design / How to get node_id of object you are editing

How to get node_id of object you are editing

Author Message

Iain MacLean

Tuesday 24 February 2004 2:40:38 pm

Hi all

How do you get the node_id of an object you are editing?

I am setting up a site where the logged on users can edit their own account details. It all works fine, except that I want to have a RedirectURI in the form that returns the user to the view details page when they have either discarded or stored the info. When a user 'discards' the details from the edit screen, they are returned by default to the view details screen, which is good. When they 'store' the details they are taken by default to the node specified in the site.ini file. I can change this be inserting a hidden RedirectURI input field into the form to take them to the home page or site map etc. But for consistency (and also so they can check the details they have just editied) I would like to return them to the view details page.

The object_id is easy to get when you are editing an object. But I cannot get the node_id. It's probably really simple (these things normally are) but I can't figure it out.

Can anyone help?

Cheers
Iain

John Mina

Wednesday 25 February 2004 12:27:55 am

HI Iain,
Hope i understood your question well, for example if i have a node named "local_news" as a child of the main node "News", in the content tab of the administrator ste, you will be able to get the node ID by either :
1- go to the child for editing , there you will find in the begining of the page a definistion of the node_id.
2- by getting your mouse above this ndoe in the parent page you will find in the node_id in the status bar as a target href for this link before clicking on it.

hope i was helping.

Iain MacLean

Wednesday 25 February 2004 4:20:05 am

Hi John

Thanks for the suggestion. Unfortunately, I can't use that technique in this situation.

I have implemented the form that allows users to edit their account details from the User site - like in the shop demo. To allow them to be redirected to the page where they can see the information they have just stored in the database, I need to get the node_id while the user is editing in the form so that I can include it in a hidden RedirectURI input field in the form. The default action is to redirect the user to the user group (i.e. the node's parent), which they do not have permission to see on this site. In most cases (and this is the way it is set up in the Shop demo) it seems there is a redirect field that takes them to somewhere else in the site like the root/home page.

If the user discards the version they are editing, they are returned to their details, which is where I would also like them to end up after they have updated their details.

All the sugestions I have tried from the documentation return nothing.

Cheers
Iain

Antonio Cortese

Monday 04 October 2004 10:47:17 am

Hello! I've just had the need to do a similar thing, and managed to get the node_id of an object I was editing.

I was creating a class override template for edit.tpl and found out that in edit templates you can get the node_id using this variable:

$object.main_node_id

If you need other node info, like url_alias, for instance, you can access them like this:

$object.main_node.url_alias

If you want a list of all node info you can access in edit templates, just temporarily insert this in your template to read the output:

{$object|attribute(show)}

If you scroll through the output, you'll get a line that says 'main_node_id' and has the wanted node_id value.
The lines immediately after that one start with a '>' and list several attributes: those are all the attributes that you can access using:

$object.main_node.[insert listed attribute name here]

Hope this can help you (if you still need it).

Antonio

eZ debug

Timing: Jan 19 2025 09:56:49
Script start
Timing: Jan 19 2025 09:56:49
Module start 'content'
Timing: Jan 19 2025 09:56:49
Module end 'content'
Timing: Jan 19 2025 09:56:49
Script end

Main resources:

Total runtime0.1448 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.0859180.8125
Module start 'content' 0.00590.0059 769.898497.9453
Module end 'content' 0.01180.1330 867.8438527.1250
Script end 0.1448  1,394.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.3294200.0002
Check MTime0.00140.9640200.0001
Mysql Total
Database connection0.00070.466010.0007
Mysqli_queries0.098167.71371410.0007
Looping result0.00110.77391390.0000
Template Total0.132691.510.1326
Template load0.00070.471610.0007
Template processing0.131991.062510.1319
Override
Cache load0.00050.331510.0005
Sytem overhead
Fetch class attribute can translate value0.00070.500510.0007
XML
Image XML parsing0.00020.169910.0002
General
dbfile0.00785.3849200.0004
String conversion0.00010.037430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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