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

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 19 2025 07:22:43
Script start
Timing: Jan 19 2025 07:22:43
Module start 'layout'
Timing: Jan 19 2025 07:22:43
Module start 'content'
Timing: Jan 19 2025 07:22:44
Module end 'content'
Timing: Jan 19 2025 07:22:44
Script end

Main resources:

Total runtime0.8670 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 596.0469152.6406
Module start 'layout' 0.00470.0033 748.687539.4766
Module start 'content' 0.00800.8577 788.1641526.8359
Module end 'content' 0.86570.0014 1,315.000012.1250
Script end 0.8670  1,327.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3840160.0002
Check MTime0.00160.1845160.0001
Mysql Total
Database connection0.00070.085810.0007
Mysqli_queries0.806593.0202620.0130
Looping result0.00070.0814600.0000
Template Total0.831295.920.4156
Template load0.00180.205320.0009
Template processing0.829495.657920.4147
Template load and register function0.00020.021110.0002
states
state_id_array0.00060.066910.0006
state_identifier_array0.00110.128720.0006
Override
Cache load0.00150.1738370.0000
Sytem overhead
Fetch class attribute can translate value0.00170.193030.0006
Fetch class attribute name0.00090.105440.0002
XML
Image XML parsing0.00030.039030.0001
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00070.0786100.0001
String conversion0.00000.001240.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
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs