Rather than specifying a contextual filter, is it possible to specify a contextual filter +1 (i.e. add one to the current filter value?)

If you have a view taking an argument, i understand that you can create a global text field to make a link to a different view using the original argument.

I.e. in view1/arg1 i can have a global text field which outputs as a link to view2/arg1

Is it possible to create a global text field which outputs as a link to view2/arg1+1

i.e. adds one to the current argument?

4 Answers 4


In Views for D7 (not sure about D6) you can add a field of type "Math expression" to do this sort of thing. Enter the expression [!1]+1 (or maybe [%1]+1) in the Math expression field, and then later text fields can refer to this value (in their Rewrite sections) as [expression].


Views PHP normally be my answer, but it appears that it doesn't support PHP in Contextual Filters quite yet...

So you'll need to create yourself a module and then:

I'm assuming your first argument is the one you want to change, and I don't have a view I can test against right now, so you'll need to print_r($query->where[0]);` to see what's going on in there and add to the correct value.


Do something like this.

  $view = views_get_current_view();
  $arg = $view -> args[0];
  $newarg = intval($arg) + 1;
<a href="/view2/<?php print($newarg); ?>">Increment my contextual filter</a>

You can create views template for your views and do something like this below.

<?php $arg = arg(1);  ?>
<a href="<?php print base_path() . 'view2/' . ($arg + 1) ;?>">Link to view</a>  

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.