I have created a view with a page and a block. Also i have created a new content type by creating a new node--news_page.tpl.php file and a page--news.tpl.php file so as to display my block there. What am i trying to do is to edit the way news are displayed. To accomplish that i need to add my html code to the page the view created. How do i do that using drupal 7 and views3 module?
1 Answer
In your view on the right-hand side there is an 'advanced' link.
When you click this it will display a number of advanced options.
The option you want is 'Theme : information".
Click on information and you will presented with a number of template suggestions to help you theme your view.
To determine what template to use you basically need to think what level you want to theme at.
Example: If you click the link 'Display output' and copy/paste the code into one of the suggested file names i.e. views-view--[YOUR_VIEW].tpl.php, this is the top level you can theme at.
If you wanted to theme a particular field you will find that further down in the suggestions.
-
Ok i get it. So i have to locate the views-view--[MY-VIEW].tpl.php file and add my html code there? Do i need to leave some of the code there? Or i can remove anything from there? Thanks– paranodCommented Aug 22, 2012 at 8:10
-
You just need to leave the logic and be careful if removing some of the markup in case the view requires a class on that markup. Commented Aug 22, 2012 at 8:18
-
ok. Thanks. Btw i cannot find the views-view--[MY-VIEW].tpl.php file in my directory and i cannot edit the file trough drupal user interface. Do i need to change access rights or is it stored somewhere in my directory?– paranodCommented Aug 22, 2012 at 8:21
-
You just need to create a new file in the templates folder of your theme. This 'views-view--[MY-VIEW].tpl.php' is just made up, an example. If you view was called 'bananas' then your template name for a 'Display Output' would most likely be 'views-view--bananas.tpl.php You just need to pick one from the suggestions given to you. Commented Aug 22, 2012 at 8:59
-
hmm...and inside my div element i will put <?php print $output; ?> like the example drupal is giving. But will this be recognized depending the element. For example i wish the Post date to be inside a span class and the body inside to a paragraph. How will this be possible?– paranodCommented Aug 22, 2012 at 9:26