Hi all. Drupal noob trying my best!
I would like to build a view that lists the 6 most currently either published or uploaded News items. I say published or uploaded because my user would like to easily publish simple news stories, but also have the option to upload things like PDF press releases. I am currently going about things this way: Two content types - one called "News" and one called "News Document."
A News content type is just your basic published node with a title and body field.
A News Document content type is basically just a holder for an uploaded PDF or Word doc. It has a title, but no body, and a CCK field for uploading a file.
I would like the view to show the post date and title for the 6 most current news things. If the item is a News content type, I would like the title to link to the node. If the item is a News Document, however, I would like the title to link directly to the uploaded file (so that if its a PDF, you click the title and it opens the PDF). It would be really cool if I could keep the little PDF or Word icon next to the title so people know what they are clicking on.
Am I going about this the right way? Is this possible with Views?
I really appreciate any comments or suggestions.
Cheers,
TJEngel
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | recent-news-view.png | 13.09 KB | TJEngel |
Comments
Comment #1
TJEngel commentedStill struggling with this issue. Can anyone give me some direction? I've attached a graphic in order to illustrate my dilemma more clearly. Sorry for bugging. This is an essential feature for my site, and I am unable to give it legs.
Thanks!
Comment #2
dawehnerI doubt that it helps to push issues :)
If you want to do things like this you have either use theming or use the "views custom field" module.
Comment #3
TJEngel commentedRight, sorry for pushing...
I received some help from a fellow Drupal-er and we figured this out. For anyone interested:
Here are the essential fields in replicating this:
Node: Type Type
Node: Nid Nid
Content: Document Generic files
Node: Title Title
The first three are excluded from display. None of the fields have replacement text, links, or are linked to a node from within Views UI. Very, very stock except for the Excludes as noted.
So the last step could be handled in a custom module or in the template.php of your active theme. Here's something like what you'd do in the latter case for a view named "my_news" with a display of type Page. The content type with the doc is called "news_doc" and I'm using filefield (not core Upload). The name of that field, if you're looking to replicate this exactly, is "field_news_doc" (which is represented below by its internal name, "node_data_field_news_doc_field_news_doc_fid").
It's important to note that you need to create the file "views-view-fields--my_news--page.tpl.php" in your theme's directory or this will not work. Just copy and paste the "views-view-fields.tpl.php" file from the views module directory into your theme's directory and rename it.