1

I need to verify, in page.tpl file, if page is currently showing a node for viewing, editing, or deleting purposes.

I found I can write arg(2)=="edit" to verify if it is in "edit mode", but how to do for delete (arg(2) is empty such as for view).

What is the correct way to get this information?

Thank you

3
  • The path for deleting the nodes is actually /node/%node/delete. What do you mean by arg(2) is empty for such page? Mar 25, 2016 at 9:48
  • Sorry, my error about delete... So your suggestion is only to verify arg(2) and, if it is empty, I can be sure I'm in "view mode"? This means arg(2) always contains the action? Or is there other ways (e.g. specific variables in the page scope) to get it properly? Mar 25, 2016 at 10:00
  • I posted a bunch of these rules - hope that helps :) Mar 25, 2016 at 10:15

1 Answer 1

3

Here's how to check against all paths related to nodes:

Node view:

arg(0) == 'node' && arg(1) && is_numeric(arg(1)) && !arg(2)

Node edit:

arg(0) == 'node' && arg(1) && arg(2) == 'edit'

Node delete:

arg(0) == 'node' && arg(1) && arg(2) == 'delete'

Node add "landing" page from where you choose which content type you want to create:

current_path() == 'node/add'

Node add page for a specific content type:

current_path() == 'node/add/YOUR_CONTENT_TYPE'

All node add pages:

arg(0) == 'node' && arg(1) == 'add' && arg(2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.