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