Rewrite output for view field only when certain condition is met?


You can do this with the UI with some of my favorite Views trickery.

  1. Go to your content type, click the Boolean field and change its Off value to 0.

  2. Create a new view and add the Title field twice. Rewrite the link for one of them, and Exclude both from Display.

  3. Add your Boolean field to the view and..

a. Rewrite the title of this field: [title]

b. No Results behavior: [title_1]

c. Count the number 0 as empty: ✓

d. Hide rewriting if empty: ✓

Because you changed the Off value of the field to 0, you can make Views trigger the No Results Behavior for the field. I've just tested this and it works fine so ask if you have any trouble.

Tags: Drupal 7 / Views

Similar questions

replace template with other when conditions are met
I want to add a record do theme_hook_suggestions variable but only when specific conditions are met, especially when system is going to use a specific template in theme. In effect I want to replace one template with other. I.e. - when user sees node with id = 50 and view mode == teaser and user has set some specific parameters system should use tem...
Rules module doesn't send emails to user roles once conditions are met
I'm working in drupal 7 and I've configured the rules module to send emails you specific user roles when content is created. For some reason I'm getting inconsistent results, sometimes not receiving any emails. Any insight to why rules isn't generating emails would be helpful. Here's my Rule:
How to set the filter condition by default for specific condition in view
How to set the filter condition by default for specific condition in view i,e i have view with the filter condition STATUS drop down list has 1]live 2] discard,so here i want to filter by default for live status when i open this view can any please tell me how to do this? Thanks a lot in advance.
Drupal on IIS 7: URL Rewrite vs. ISAPI Rewrite modules
I'm preparing to install Drupal 6 on an Win2k8 server. I'm still on the fence about using IIS 7 exclusively as the web server, or installing Apache and avoiding IIS 7 altogether. I work on a campus with a lot of different networks & system which mostly run on Windows servers, so I fear that not utilizing IIS 7 in some form may come back to bite...
Help understanding rewrite log (want to internally rewrite a page when requested from specific HTTP_HOST)
I have a Drupal site,, and our client has a campaign that they're promoting for which they've bought a new domain name, I'd like it so that a request for internally rewrites to a particular page of the Drupal site. Note Drupal uses an .htaccess file in the document root. The normal Drupal rewrite is I added the f...
Htaccess Mod rewrite Drupal URL clean-up code stopping my redirect rewrite rules
I'm trying to set-up some 301 redirects after a site redesign. Using the following code with the rewrite tule works fine in a test environment But when I move this code to the htaccess file in the new site directory, the redirect pages return a 404. As though the redirect code is not even being looked at. Is it possible that the L flag in the clean...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.