You are here

README.txt in Content Templates (Contemplate) 5

Same filename and directory in other branches
  1. 6 README.txt
  2. 7 README.txt
Content Template (contemplate) Module for Drupal
by Jeff Robbins | Lullabot | www.lullabot.com
------------------------------------------------

What is the difference between ConTemplate and theming?

In Drupal, the presentational layer (the theme) is a walled-off and separate
entity. Since it is possible for users to choose their own themes or to switch
themes programmatically, Drupal does not make any assumptions about presentation
in the way that it "thinks" about content. This can become a problem when
modules like CCK are adding fields that you may want to show up in specific
ways. Drupal's RSS feeds and search indexing does not run through the theme
layer. This is as it should be because neither of these use presentational
information. However, there are certainly times when you want to rearrange this
content, remove parts of it, or display things in special ways. You can affect
most of the site display using your theme's node templates. But if you would
like to affect the content across multiple themes, multiple sites, or simply
affect the RSS feed and search indexing, you'll want to use ConTemplate.

ConTemplate alters the way that Drupal "thinks" of the content. It alters the
node teaser and/or body fields before the theme is invoked, so it will affect
RSS feed and search index in addition to the $content variable that gets sent to
your theme's node templates.


What does ConTemplate do?

This module allows modification of Drupal's teaser, body, and RSS feed using
administrator defined templates. These templates use PHP code in a manner very
similar to the PHPTemplate theme engine and all of the node object variables are
available for use in each template. An example node object is displayed and it
is as simple as clicking on its properties to add them to the current template.

This module was written to solve a need with the Content Construction Kit (CCK),
where it had a tendency toward outputting content in a not-very-pretty way. And
as such, it dovetails nicely with CCK, adding a "template" tab to CCK
content-type editing pages and pre-populating the templates with CCK's default
layout. This makes it easy to rearrange fields, output different fields for
teaser and body, remove the field title headers, output fields wrapped for use
with tabs.module (part of JSTools), or anything you need.


Disk-based templates

It is also possible to create disk-based template files. To do this, copy the
contents of a contemplate textarea and paste it into a file called
"node-{nodetype}-{field}.tpl.php" where {nodetype} is the content type and
{field} is either "body", "teaser", or "rss". It is also possible to create a
template called "node-{nodetype}.tpl.php" which will affect all cases, and
"node.tpl.php" which will affect all node types.

Place these files into a directory called "contemplates" inside of either your
"sites/all" directory or "sites/{yoursite}" depending on your setup. It is also
possible to have multiple "contemplate" directories with
"sites/all/contemplates" being the fallback for templates the contemplate does
not find in the more specific site directory.

When adding or removing template files, you will need to visit the Content
Templates admin page to refresh the template list cache. You do not need to do
this again when making changes to the content of the templates.

File

README.txt
View source
  1. Content Template (contemplate) Module for Drupal
  2. by Jeff Robbins | Lullabot | www.lullabot.com
  3. ------------------------------------------------
  4. What is the difference between ConTemplate and theming?
  5. In Drupal, the presentational layer (the theme) is a walled-off and separate
  6. entity. Since it is possible for users to choose their own themes or to switch
  7. themes programmatically, Drupal does not make any assumptions about presentation
  8. in the way that it "thinks" about content. This can become a problem when
  9. modules like CCK are adding fields that you may want to show up in specific
  10. ways. Drupal's RSS feeds and search indexing does not run through the theme
  11. layer. This is as it should be because neither of these use presentational
  12. information. However, there are certainly times when you want to rearrange this
  13. content, remove parts of it, or display things in special ways. You can affect
  14. most of the site display using your theme's node templates. But if you would
  15. like to affect the content across multiple themes, multiple sites, or simply
  16. affect the RSS feed and search indexing, you'll want to use ConTemplate.
  17. ConTemplate alters the way that Drupal "thinks" of the content. It alters the
  18. node teaser and/or body fields before the theme is invoked, so it will affect
  19. RSS feed and search index in addition to the $content variable that gets sent to
  20. your theme's node templates.
  21. What does ConTemplate do?
  22. This module allows modification of Drupal's teaser, body, and RSS feed using
  23. administrator defined templates. These templates use PHP code in a manner very
  24. similar to the PHPTemplate theme engine and all of the node object variables are
  25. available for use in each template. An example node object is displayed and it
  26. is as simple as clicking on its properties to add them to the current template.
  27. This module was written to solve a need with the Content Construction Kit (CCK),
  28. where it had a tendency toward outputting content in a not-very-pretty way. And
  29. as such, it dovetails nicely with CCK, adding a "template" tab to CCK
  30. content-type editing pages and pre-populating the templates with CCK's default
  31. layout. This makes it easy to rearrange fields, output different fields for
  32. teaser and body, remove the field title headers, output fields wrapped for use
  33. with tabs.module (part of JSTools), or anything you need.
  34. Disk-based templates
  35. It is also possible to create disk-based template files. To do this, copy the
  36. contents of a contemplate textarea and paste it into a file called
  37. "node-{nodetype}-{field}.tpl.php" where {nodetype} is the content type and
  38. {field} is either "body", "teaser", or "rss". It is also possible to create a
  39. template called "node-{nodetype}.tpl.php" which will affect all cases, and
  40. "node.tpl.php" which will affect all node types.
  41. Place these files into a directory called "contemplates" inside of either your
  42. "sites/all" directory or "sites/{yoursite}" depending on your setup. It is also
  43. possible to have multiple "contemplate" directories with
  44. "sites/all/contemplates" being the fallback for templates the contemplate does
  45. not find in the more specific site directory.
  46. When adding or removing template files, you will need to visit the Content
  47. Templates admin page to refresh the template list cache. You do not need to do
  48. this again when making changes to the content of the templates.