By rgraves on
I have a view that grabs the most recently added nodes from the content type 'news' and presents it in a list.
I need to add the ability to include 1 or 2 photos to the left and right of this list. Each news story would have a CCK field for staff to optionally include a photo.
Mockup:
http://www.lib.uwo.ca/files/mockup.gif
I've been able to statically include the photos through the use of views template files, but this requires me going in and changing the photos whenever staff request it. I'd like it to be automated like the news listing is.
Does anyone know how I can accomplish this?
Comments
hey I have an idea...but
hey I have an idea...but wait, there is something strange in the logic of your need:
I your mockup I see 2 pictures for a group of news, but you want each news to have its own picture. So, wich pictures you want to display at the left and right? random? the pictures from the first two news?...
I'm thinking the best
I'm thinking the best approach would probably be having the photos for the top two stories appear. The first story would be on the left and the second story would be on the right.
mmm... one solution would be
mmm...
one solution would be to create 2 views:
One with the list of latest news (display 10 items?).
Other with the picture of latest news (display only 2 items).
Then edit the CSS.
another solution would be to call the 10 items(with picture) and edit the template file of the view, go to "theme: information" link when editing the view.
Your second solution was what
Your second solution was what I was thinking. I tried it earlier and didn't have much luck with it. I'll try again and see if I can get it to work. I was just curious to see if there was an obvious solution that I'm missing.
Thanks for your advice.
Caching Issues
Well, I tried editing the theme's list template file to parse through and find images in the view's output. I then placed the two first images it found on the left and right side. This worked properly when I was logged in but when I tried accessing the view anonymously (with caching enabled), the caching was causing it to not display properly.
Any other ideas on how to accomplish this?
maybe disable cache for that path?
You could always disable the cache for that page, might be worth a shot.
http://drupal.org/project/cacheexclude
Spoke Too Soon
Actually, I spoke too soon. I realized none of my CCK fields were displaying to anonymous users anywhere on our test site. I was playing with CCK's Content Permissions module a few days ago so I disabled that module and the news photos now appear properly with no caching issues. My CCK fields on other parts of the site are also appearing again.
Thanks for the CacheExclude module though - that may come in handy for other projects in the future.