Hi, I'm new to Drupal and (therefore) new to the Views module. This is a rather verbose post, but please bear with me...
I'm ok with limited PHP, but I'm finding theme development to be rather difficult (for me). This is probably because the HTML designs for my site are quite different from a 'regular' Drupal site -- they don't need to show most of the stuff that an off-the-peg Drupal site will show, their visual layout is very different, and each section of the site has its own differing layout. Yeah, I'm not making it easy on myself...
Please help, if you can, with this issue:
One section of my site will have pages for 'Artists'. So I've used the CCK to create a content type called 'Artist', with a few fields (name, info, etc). I'm using PHPTemplate, so I have a node-content_artist.tpl.php file and a page-artist.tpl.php. My main page.tpl.php includes the right page-whatever.tpl.php based on $node->type.
Here's the thing: as well as the webpage for each artist, the site needs one page that lists all the artists (just a list of their names will do) - kind of like a menu. I need this to be an automatically-maintained page, not a manually-maintained 'proper' Drupal Menu. And its HTML is potentially rather different from a single Artist page (or, er, node?).
So, I've created a View using the Views module: it's just a sorted view of all the published nodes that have the 'Artist' content type. It's set to provide a 'page view'.
In short, my question is this: where do I put the HTML and/or php for this 'page view'?
I've spent quite a bit of time browsing and searching the documentation and snippets etc, and it seems like I might need a views-list-Artists.tpl.php file.
But how does the rest of the theme, or the engine, find that file? Does that file then hold the main page structure, such as the element, the way a file like page.tpl.php does? Or do I still need something like a page-artists.tpl.php - but if I do, how would my main page.tpl.php know to include it, if a view is not itself a node?
Any pointers or clues would be gratefully received. I feel like I'm nearly there but I'm missing some key steps. I'm really struggling with this very 'programmatic' theming style...
Many thanks in advance, and much respect for what is clearly a very powerful (but complex!) CMS :)
Oh, and thanks for listening ;)
em
Comments
It is confusing, and a bit
It is confusing, and a bit roundabout. But you're almost there.
Put this code in your template.php file:
That's from this page (http://drupal.org/node/42597)
It takes all the values that your view has retrieved and cleans them up and puts them in variables, and looks for a file called
views-list-VIEWNAME.tpl.php.
Then in views-list-VIEWNAME.tpl.php --- all of the fields that your view retrived will be available as variables. So if the first for artist name is "field_artist_name" then you put
in the view file to print it out.
Thanks :)
That did help me get over a few conceptual gaps, and I've now got the view showing up in my page. In the end I setup the view as a block, not a page in itself, then forcibly included it in the relevant page-whatever.tpl.php like this:
Maybe that's not very elegant, but it works! Although it now means I have to learn about theming blocks as well... *sigh* ;)
Many thanks again for your help.
hi please help me to understand this code
hello..
I have created many views for example
News
Latest_Videos
Cheats etc
And i want to display them without using region means directly by php code....
So please help me...
What is the code for display latest news (title) in page using this code...
Thanks
sumit