0

I have a view created which has a column 'Price'. I also I have another column 'Special Price' in the same view, but 'exclude from display' is selected.

In views, click the price field > rewrite results > Rewrite the output of this field > I added the below:

$[field_price]

Special $[field_special_price]

I would like to display the special price only if the special price field has a value. If the special price field has no value, I only want to display the price field value. I am not sure how I can modify it ?

Thanks, D


I am new to drupal. Sorry if I am not clear. In the views, I would like to put price and special price in the same column. I will add some css to special price. If I un-selected exclude from display for special price, then special price will be in another column which I do not want to do.

Please visit the page and see the price column.

http://bettylist.com/ac/myview

Thanks.

2 Answers 2

0

Then dont exclude special price from display and customize that field. There's an option @ No results behavior, where you need to check Hide if empty.

THEN, all you need to do is to style the two fields where they're both present.

That's the simplest way. There is another way, where you exclude both from display and add another field at the end "Global text area", where you can play with the tokens and rewrites.

0

Follow these steps:

  1. Rewrite output of [field_special_price]
  2. Make it Special $[field_special_price]
  3. Make sure that under no results behavior, "hide rewriting if empty" is checked.
  4. Now rewrite the output of [field_price].
  5. Make it [field_price]<br/>[field_special_price]

Also [field_special_price] should have weight less than [field_price]. I think you know this well.

5
  • Thank you Himanshu. I was able to follow your instruction and got what I needed. My site now shows simply both prices when both are present. Another question I have is how to cross out the price amount if there is a special price? I guess I need some css for that. If you can provide some help, it will be great.
    – autop
    Commented Apr 7, 2015 at 14:05
  • sorry not getting exactly your requirement Commented Apr 8, 2015 at 6:18
  • Now, that I can see special price column only if special price has value. I like to know if special price has value, how can I cross out the price value? If there is not special price, then do not cross out the price value. Do I need some IF ELSE statements somewhere? Ex: If special price > 0 then <strike> price </strike> End If. Please help
    – autop
    Commented Apr 8, 2015 at 14:43
  • Never mind. I was able to figure this out. Thank you again.
    – autop
    Commented Apr 8, 2015 at 17:51
  • Nice, saw your comment just now. You're champ :) Commented Apr 9, 2015 at 6:24

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.