2

I was wondering if there is any other way apart from coding (and, possibly, using the rules module) to make the showing of a field dependent on the existance of another field.
Say you have in a node, a video and a photo. You want to show only the video in teaser but if you have not provided a value for the video, then the video field should not be showing, and instead the photo field should be showing. If you have provided a video, then the photo field should not be showing. Any ideas?

1
  • After lot of experimenting I found out that I cannot use a rule to perform this. Rules does not work with Media file selectors. Actually, the Rules condition returns "false" if the "Entity has field" is about such a field.
    – nikan
    Oct 21, 2011 at 20:02

3 Answers 3

3

The only solutions I know except coding it by yourself its Content Templates module. This module allows you to change the template directly from you back office.

The advantage it's that you don't need to deploy your code if you need small change.

You've also Display Suite that seems promising, I never tried but the description sounds good for what you need.

2
  • Thanks. It's more close to what I am looking for. I've used Content Templates sometime back but I do not remember much. Can I use an 'if' construct or something?
    – nikan
    Oct 20, 2011 at 16:11
  • Seems to be yes, or at list their use a kind of eval function that allows you use PHP.
    – yvan
    Oct 20, 2011 at 16:17
1

I know this is an old question, but I wanted to update this because it could help someone.

I would try Conditional Fields, it does exactly that. Drupal 6 & 7 only.

1
  • It is indeed an old issue and I have move away from drupal since so I can neither confirm nor deny what you say. It has to be left to the rest of the community to decide.
    – nikan
    Sep 16, 2014 at 6:53
0

You should implement template (or possibly module) preprocess to do the checks and assign the html snippet to be outputted to a variable then just output it like this <?php print $mytag; ?> in your node--[type].tpl.php

1
  • Thank you. That would do, but I was wondering about a non coding solution.
    – nikan
    Oct 20, 2011 at 14:47

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.