0

Within the page node is a field for an image that is the page's banner image. We also use Rotor banner to do rotating banner images in the same location. Since I have a default banner set for the page, pages can't have an empty banner field. If a rotor banner view exists, both the page's banner and the rotor banner display stacked on top of each other.

How can I test to see if the rotor banner view has any results and determine whether or not the field banner for the page should display or not? If there is a rotor banner to display, I want to hide or remove the field banner from display.

Both the field banner and rotor banner are living as blocks in the same region. I would like to come up with something for the "Page specific visibility settings" for the blocks, but I'm thinking I will have to do it some how within the theme.

I can't figure out how to see what nodes have been loaded other than using Firebug. If I could access those nodes in a variable accessible to the block or the theme, I could detect if there are rotor items loaded.

Does anyone have any ideas?

2 Answers 2

1

You can display the image field of the node if the rotator banner is empty by outputting that field into the Empty Text field of the view that you are displaying. So you would only need the view's block in the region that you have both blocks currently. Make sure you have PHP input enabled in your empty text.

If the banner content is exclusive to that node's page, you can add a Node Reference CCK to the banner content type and tie the nid argument in views the the node reference field by adding that node reference field as a relationship in your view.

6
  • I like your idea of putting the banner image in the Empty Text field. I added PHP to print the node token for the banner image, but I don't quite follow the node reference instructions. The banner image is a field, a part of the node, and not it's own content type. How can I output the specific node field inside the empty text on the view? Do I need the Node ID listed as an argument? Commented Aug 22, 2011 at 20:30
  • You can use tokens in your empty text, so I would add the banner image field to your list of fields in the view, and check the "Exclude from Display" option for that field. Now that field's token should be available to you. For some reason the full list of available tokens isn't displayed in the token list for the empty text, but when I put drop in the token of the hidden field it outputs just fine.
    – user2014
    Commented Aug 22, 2011 at 20:47
  • Thanks for your help, but because it is a block view, I can't add the banner image field as a Field. I can add it to Arguments and output the fid number, but I can't get it to output the field. I've tried using the nid with node_load() and the fid with field_file_load() but I can't get anything to output. I feel so close. Any ideas? Commented Aug 24, 2011 at 19:28
  • Try using the Views Custom fields module and do the node_load() stuff in that field to get the image you want...hide that field from normal dispaly and then see if you can use that token in your empty text...i haven't tried it but I think it would work.
    – user2014
    Commented Aug 24, 2011 at 20:36
  • I just figured out I can't add fields to the view because the style is Rotor instead of HTML List or Table. If I change it, it doesn't display properly. I'm going to have to investigate this a little further. Thanks for your help. Commented Aug 24, 2011 at 20:50
0

Okay, here's my solution:

I added display:none; to my CSS for the block that displays the CCK banner image field. In the rotor block view's Empty Text, I added display:block; for that CCK banner image field. Seems like a bit of a hack, but it works. Thanks for all of your help.

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.