Archive for January 13th, 2009
More about VIEWS tpl.php files
After a couple of hours I’ve managed to float my way around in VIEWS and CCK and suggestions. I’ve found it… cumbersome – mostly because of the selector names that VIEWS and drupal output into the markup. But I’ll take it for the power (I think) it gives me.
One thing: once you’ve taken a views-based tpl.php file and put it into your theme folder, the option to use Unformatted, Grid, List, and Table is no longer functional. This makes sense, since those options refer to styling and I’m sure VIEWS flips in and out of different tpl files to give you those various options.
That’s okay – gives direct power to me with respect to the layout, which I like.
(I hope).
Add comment January 13, 2009
tpl.php vs. Views “style”
So I made a new View called “art_news.” I made the path=”art_news” and saved it. I have a content type called “art_news” too. Did some content filtering so my view would display all content of that content type, pointed a link to it and, bingo – there it all was. But it was ugly. I wanted more control over the display than I could currently get.
tpl.php
I made a template suggestion in the form of node-art_news.tpl.php and tried it out. Bingo! Drupal is reading from it when I’m at the path “art_news.” As it should. But I’ve generated this path and view through the VIEWS module. Could there be a conflict? Didn’t appear to be. But I realized that I wasn’t really able to style the content with my tpl.php file – I was only hitting the surrounding architecture. So I went to:
node.tpl.php
And it worked. I was able to hit the node content and style away. But I was still suspicious of the power of VIEWS while retaining regular tpl.php theming. Was I on to something? (well, truth be told – I wasn’t suspicious so much as just stumbled upon it). The crucial settting in views is:
Row Style = Fields
Your two options for Row Style are “Fields” and “Node.” Selecting “Node” tells VIEWS to use Drupal’s typical node display functionality. Selecting “Fields” overrides that functionality with VIEWS’ own. This gives you the ability to select whether your fields display their labels, what order they display in, and some other stuff. BUT – node-art_news.tpl.php no longer “hits” the art_news content type. Now you gotta use the Views based tpl files. If you click Theme: Information, you’ll see the various tpl files that you can use to theme your fields and views – just copy the php, open a new file in your them folder and name it appopriately, then edit away.
1 comment January 13, 2009