I am using views and I want to put a dynamic link in the header. The link is http://www.example.com/node/add/album/31 The number 31 varies depending which node it is viewing so I want it to change to whatever node id it is viewing. I'm not a coder so can anyone give me code?

Comments

peterjlord’s picture

Put something like this in the view header and save as php making sure you have php filter module installed

<?php
  $nid = arg(1) // This is the argument number  example.com/node/31
  echo l(t('Add to Album'), 'node/add/album/ ' . $nid);

ruriko’s picture

Another question. How can I make it work if the node url is like this http://www.example.com/series/31/images

peterjlord’s picture

<?php
  $nid = arg(1) // This is the argument number  example.com/node/31
  echo l(t('Add to Album'), 'node/add/album/ ' . $nid);

As the 31 is the second one arg(0) - series, arg(1) - 31, and arg(2) - images