I have a Views block listing a certain amount of nodes, and I've added a header field: Global: Result summary.

I am on the page: http://myexample.com/node/145 for example and with the header field, I want to link to: http://myexample.com/node/145/events. I have put the following code in the field:


But this omits the nid and goes directly to: http://myexample.com/node/events.

Does anyone know how to pass a URL argument for that field? I would ideally want to use arg(1).

  • use % instead and what is @total !! – user23288 Sep 20 '15 at 8:06
  • @total is just what Views tells me to use (indicates the total number of items in the view). – Pierre_colin Sep 20 '15 at 8:34
  • % doesn't work here, because I am advised to use HTML for this field... – Pierre_colin Sep 20 '15 at 8:38

Because the header uses the default Drupal PHP interpreter, Views variables aren't available there like they are in the arg php code. You can get them by doing something like this:

global $current_view;
print $current_view->args[0];

Update: If you want to use PHP in views header, you can go to configure header, select "Global: Text area" and have to change text format to PHP code; you have to first install the PHP filter module.

Also if you use Global: Text area with PHP filter enabled this should work:

<a href="%/events">@total</a>
  • When I do this: <a href="<?php global $current_view; print $current_view->args[0];?>/events">(@total)</a>, it interprets the first '->' as the end of the link tag... how can I prevent that? – Pierre_colin Sep 20 '15 at 9:30
  • You need to print your HTML using php echo – user23288 Sep 20 '15 at 10:22
  • Could you provide the full html code, please? As of now your answer is not working because the Global: results summary is a HTML field only. – Pierre_colin Sep 20 '15 at 10:30
  • Please search on google or ask on stackoverflow, I'm not sure how it will be since I'm not a php developer, so I might be wrong, sorry. – user23288 Sep 20 '15 at 11:50

You don't get to add [nid] there.However you can use wildcard %.In your field of Global:Result Summary write like this

<a href="%/events">@total</a>

Hope it works for you.

  • Sorry, but this does not work. It sends me to node/%/events... – Pierre_colin Sep 20 '15 at 9:24
  • look at my updated answer, it should work if you use the proper Global header. – user23288 Sep 20 '15 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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