views:

50

answers:

2

Hi,

The problem is the next: I have a recipe with images, and I have a video with node reference to the recipe (so I can hav a one to many). (see here)

When there is a video, it should not show an image, when there is no video, it should show the image.

I created a block for displaysuite, and attached the video to it.(see here), in 2 displays.

Now all i want is a theming function where all the image and video's are in so I can do some logic and format everything, but the video's and images are processed sepperately.

Can anyone help me out please ?

A: 

Not totally sure what I am missing, but assuming your view works and you have a display that shows all of the proper fields, it should just be a matter of creating an instance of views-view-fields.tpl.php for your particular view and/or display, and putting your logic there. If you click on the Theme link on the view, it will show the view template suggestions.

MPD
won't views-view-fields create a general template for all views ?
Nealv
Yes it will but views supports the template suggestion system, and has a hierarchy for effecting as many or as few views are you need. Edit the view, then click the Information under Basic Settings: Theme. You will see what template file is being used (the name is bolded), as well as other potential files (from least to most specific). If you upload a file to your theme with one of the more specific names, and rescan, the view will use that template.
MPD
A: 

At the moment, I did it this way:

I get all the video's and images from a Node. Because the images and videos are different displays (video's is an attachement) they are rendered by different template functions. So in the functions a create an object in the $GLOBALS variables, that stores all the videos and images.

Then I create a template that renders the entire node, and I check the images and video's in the $GLOBALS with some if else's.

Looks like a dirty method (it probabely is) but it works

Nealv

related questions