Hopefully this is an easy task and I am just too much a beginner to solve it ...

I use a slideshow that can be configured using views. Slideshow uses the following fields: Title, nid, and Slideshow image.

Is it possible to introduce an extra field (checkbox -> boolean) to page/article and then to exclude the title from being displayed if the boolean checkbox is checked? To be precise; intrudicing the checkbox is easy, but I do not know how to evalute it then to exclude title in slideshow if checkbox is checked.


3 Answers 3


Yes. Assuming your view is displaying fields (under Format > Show), you'd follow these steps:

  1. Install the views_php module.
  2. Edit your view, adding the fields you wish to display all the time.
  3. Add the boolean field to the view, checking the "exclude from display box."
  4. Add the title field to the view, checking the "exclude from display box."
  5. Add a new field "Global: PHP" to the view. In the "output code" field, enter in the following code:

$title = NULL;
if ($data->field_field_show_title[0]['raw']['value'] === "1") {
  $title = $row->title;

echo $title;

This code assumes your boolean field is called field_show_title. Note that, for whatever reason, $row->field_show_title reports the node ID instead of the value of the field, so I had to dig it out of the data object instead.

Beneath the "output code" field you'll find an "available variables" section which describes the data that views makes available to your PHP snippet.

You may order the fields however you like, of course.

  • Thanks a lot! How can I access information about the datastructure in $data? Because the example you provided does not work. I know the function dpm(). But I guess I can not use it here? Additionally, I guess I ran into the same problem as with the solutino from "Sumit Madan". How do I make sure that the echoed value is used as a substitution to the title. Because if I just do 'echo "test";' the string is written outside of the slideshow. And I still have NO clue how to work with "Style settings" to change that... :-(
    – Michael
    Commented Nov 6, 2014 at 14:17
  • 1
    You could do this: file_put_contents('/tmp/drupal.debug', var_export($data, TRUE)); This will create a file called /tmp/drupal.debug which contains a dump of the $data variable. Commented Nov 6, 2014 at 15:42
  • hmpf... exact same problem as I had with the solution below (from "Sumit Madan"): It basically works now, but the text is displayed below the slideshow. I guess that is because I just "echo" it. What do I have to do to make it appear like the title? Why is this so f*** complicated :-(
    – Michael
    Commented Nov 6, 2014 at 16:49
  • 1
    For it to match in styling/appearance, it needs to match whatever mark-up the slideshow was generating before you changed the output. You might simply do this: in your edit views screen, click on the title field (the original one, which we've set to "exclude from display"). Uncheck the "exclude from display" box. Load your view and using your DOM Inspector of choice, see how the title is wrapped. It might be wrapped in a div with a class field-content. Hide that field again, then update your output on the conditional field to match. Commented Nov 6, 2014 at 23:39

The very simple way of doing this without using views_php module is in following steps :

  1. Add Title field in View and exclude it
  2. Add the Boolean type field in view
  3. Rewrite Boolean field value and use title token there
  4. Select hide if empty and count 0 as empty from No Result Behaviour fieldset of boolean field

and It is done in very simple steps. :)

  • Hmmm... your solution seems almost to work. But the title is now shown as unformatted text below the slideshow. (I also have to invert the logic, but that should be manageable)
    – Michael
    Commented Nov 5, 2014 at 22:42
  • 1
    Yep you have to add the style settings for that boolean field. Style settings of title will not work. Commented Nov 6, 2014 at 4:30
  • OK, uhhmmm... How do I do that :-( I guess I have to somehow copy the style settings from the title. But where do I find them? Also, I have a responsive theme. Might there a problem regarding that?
    – Michael
    Commented Nov 6, 2014 at 11:43
  • 1
    In the Style Settings fieldset. Commented Nov 6, 2014 at 11:52
  • Sorry, I am quite a noob: How can I mimic the title settings there? I tried some stuff. But the title is still shown OUTSIDE of the slideshow. Do I need to check "Use filed template" (actually I tried that). Is there a good source that explains the concepts?
    – Michael
    Commented Nov 6, 2014 at 12:51

Probably the only way to do precisely what you want is to exclude all of the fields from the display and use Global PHP instead.

However, I think an easier way to accomplish this might be to add a text field to your content type called something along the lines of “Slideshow Title.” Use this field to type in whatever you want the slideshow to use for the title, and just leave it blank if you do not want it to use one. (You of course do not need the Boolean field if you use this method.) Then tell Views to use that field rather than the proper Title field.

This wouldn’t be as elegant as the Boolean checkbox solution, but these slideshows can get complicated when you have to display them with Global PHP. This solution would also allow you to use something other than the title of the node if you ever want to customize what is displayed in the slideshow.

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.