diff --git a/help/using-theme.html b/help/using-theme.html new file mode 100644 index 0000000000000000000000000000000000000000..5f9a7f9f5ce74ed222dc4792c2e07b4907b9d4bb --- /dev/null +++ b/help/using-theme.html @@ -0,0 +1,37 @@ + +Views theme templates are straightforward to use with the Drupal theming system. If you are unfamiliar with the theming system at all, you should probably at least read drupal.org theming documentation. That said, these are the important things you need to know: + +
    +
  1. Copy a base Views template to one of the names provided from the Theme: Information section of the View. Copy this template right into your theme directory.
  2. +
  3. Clear the theme registry. See the instructions for how to do this.
  4. +
  5. Your new template should now operate; assuming you picked a nicely named template that includes the view name, that template should now be active for your view. A good example is views-view-list--foobar.tpl.php which would work for a view named 'foobar'.
  6. +
  7. You can now modify this template all you like. +
+ +For any template that uses fields, the fields will be in array. In order to use this effectively, you will need to understand enough PHP to fetch data from an array. This is a place where the devel module can really help you, because you can use its dsm() function right in your template to see what variables it uses. There is an alternative to dsm() that works without devel module, but it's a bit longer to use. + +For example, I placed the following code inside a loop in views-view-table.php.php: + <?php drupal_set_message('<pre>' . var_export($row, true) . '</pre>'); ?> + + +And it produced this output: + array ( + 'nid' => '97', + 'title' => 'Scisco Ideo Vicis Feugiat Qui', + 'name' => 'luwrepuslan', + ) + + +My view had three fields: +Node: Nid +Node: Title +User: Name + + +The contents of the $row variable included these fields, in precisely the order that I had arranged them to using the Views rearrange link. Also worth noting, though, is that each field also has an identifier so it can easily be pulled out of the row should I want to display it differently. Using +<?php print $row['title']; ?> + + +Would print just the title for that row. Please remember that I'm doing this inside the loop, so this will get repeated for every row of the view. + +The important thing here is that Views does provide IDs. Views doesn't tell you what these IDs are, but it's easy to get them by dumping the row data and doing a simple visual inspection. Views does guarantee that these IDs will not change, unless you actually add a new field and remove the existing one (in which case 'title', above, would become 'title1'). diff --git a/help/views.help.ini b/help/views.help.ini index 4c22ea378944c97b6ff67563bd69920b0378678e..72bb2b24034b220d36bd811a51f1dab080f16a53 100644 --- a/help/views.help.ini +++ b/help/views.help.ini @@ -98,5 +98,9 @@ title = "Path options (page display)" [analyze-theme] title = "Theme information" +[using-theme] +title = "Using Views templates" +parent = analyze-theme + [overrides] title = What are overrides? \ No newline at end of file