1

I've got a node that has a deadline date field. I am configuring a view that shows a list of all the nodes.

If we are past the deadline for a given node, I want to show "closed" text. If not, I want to show a link that says "Apply".

I suspect that I may have to use views_php but I'm not sure exactly how to do this, and I also want to make sure there isn't another way to do it without the performance hit of views_php.

1 Answer 1

1

There are three ways to do this kind of conditional logic:

  1. Use the views_php module
  2. Make a views field template
  3. Write a views widget (or formatter, or something - what is the correct terminology?)

I ended up taking a bit of a shortcut and going ahead with views_php for now. I'm never going to be dealing with more than a few hundred rows, so I'm not to shaken up over the poor performance of views_php.

This module is pretty easy to use. Add a "Global: PHP" field. I found dpm( $data ) and other variations to be very useful.

1
  • 1
    Really though, it's just as fast if not faster to put a global text field and override it with a field template. Better performance and no need for views PHP.
    – leexonline
    Commented Mar 13, 2014 at 20:15

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.