|author||Earl Miles||2008-06-12 16:17:00 (GMT)|
|committer||Earl Miles||2008-06-12 16:17:00 (GMT)|
Add a help page describing how to use the templates.
2 files changed, 41 insertions, 0 deletions
diff --git a/help/using-theme.html b/help/using-theme.html
new file mode 100644
@@ -0,0 +1,37 @@
+<!-- $Id$ -->
+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 <a href="http://drupal.org/node/173880">drupal.org theming documentation</a>. That said, these are the important things you need to know:
+<li> 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. </li>
+<li> Clear the theme registry. See the <a href="http://drupal.org/node/173880#theme-registry">instructions</a> for how to do this. </li>
+<li> 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 <strong>views-view-list--foobar.tpl.php</strong> which would work for a view named 'foobar'.</li>
+<li> 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 <a href="http://drupal.org/project/devel">devel module</a> 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:
+<code> <?php drupal_set_message('<pre>' . var_export($row, true) . '</pre>'); ?>
+And it produced this output:
+<code> array (
+ 'nid' => '97',
+ 'title' => 'Scisco Ideo Vicis Feugiat Qui',
+ 'name' => 'luwrepuslan',
+My view had three fields:
+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
+<code><?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 4c22ea3..72bb2b2 100644
@@ -98,5 +98,9 @@ title = "Path options (page display)"
title = "Theme information"
+title = "Using Views templates"
+parent = analyze-theme
title = What are overrides? \ No newline at end of file