| 1 |
|
$Id: phptemplate.engine,v 1.69 2007/10/02 16:19:23 dries Exp $ |
| 2 |
|
|
| 3 |
|
*** IMPORTANT NOTE - DRUPAL v6 BETA *** |
| 4 |
|
If you are using this with Drupal v.6 Beta 2 or older you must apply the following patch in |
| 5 |
|
includes/theme.inc function drupal_find_theme_templates (see http://drupal.org/node/184876): |
| 6 |
|
|
| 7 |
|
REPLACE |
| 8 |
|
$template = substr($template, 0, strpos($template, '.')); |
| 9 |
|
WITH |
| 10 |
|
if (strpos($template, '.') !== FALSE) { |
| 11 |
|
$template = substr($template, 0, strpos($template, '.')); |
| 12 |
|
} |
| 13 |
|
END |
| 14 |
|
|
| 15 |
This Theme Engine for Drupal allows you to use Smarty templates in a fully integrated and |
This Theme Engine for Drupal allows you to use Smarty templates in a fully integrated and |
| 16 |
seamless fashion. It expects a Smarty installation in the ./libs directory - you must obtain |
seamless fashion. It expects a Smarty installation in the ./libs directory - you must obtain |
| 17 |
this and extract it here yourself. It is not included by default as a policy of the Drupal.org |
this and extract it here yourself. It is not included by default as a policy of the Drupal.org |
| 18 |
contributions repository. |
contributions repository. |
| 19 |
|
|
| 20 |
Most code is largely drawn from the PHPTemplate engine code. Credit belongs to its authors. |
Since Drupal 5, and even more so for Drupal 6, this template engine has become technically much |
| 21 |
|
simpler because of the improvements in Drupal's own themeing/templating system. |
| 22 |
|
|
| 23 |
The 'default' theme for this engine is 'box_grey_smarty'. |
The 'default' theme for this engine is 'box_grey_smarty', but this is not yet updated for Drupal 6. |
| 24 |
|
|
| 25 |
Alternate downloads: http://download.berlios.de/drupal-smarty/ |
Alternate downloads: http://download.berlios.de/drupal-smarty/ |
| 26 |
- Find the appropriate download here and skip steps two and three. |
- There is no package for v5 or v6 yet at berlios.de |
| 27 |
- These links include the Smarty Template Engine. |
- Find the appropriate download here and skip steps two and three. |
| 28 |
|
- These links include the Smarty Template Engine. |
| 29 |
|
|
| 30 |
Installation: |
Installation: |
| 31 |
1. Extract tarball in (drupal_base)/themes/engines/ |
1. Extract tarball in (drupal_base)/sites/all/themes/engines/ |
| 32 |
2. Extract Smarty Template Engine tarball from - http://smarty.php.net/download.php |
2. Extract Smarty Template Engine tarball from http://smarty.php.net/download.php |
| 33 |
to a temporary location. |
to a temporary location. |
| 34 |
3. Copy the 'libs' subdirectory from the temporary location to |
3. Copy the 'libs' subdirectory from the temporary location to |
| 35 |
drupal_base/themes/engines/smarty/libs |
(drupal_base)/sites/all/themes/engines/smarty/libs |
| 36 |
Smarty.class.php should be located at |
4. Check that Smarty.class.php is located at |
| 37 |
'(drupal_base)/themes/engines/smarty/libs/Smarty.class.php' |
(drupal_base)/themes/engines/smarty/libs/Smarty.class.php |
| 38 |
4. Ensure templates_c directory is readable and writable by the web server process. |
5. Ensure (drupal_base)/themes/engines/smarty/templates_c directory is readable and writable by |
| 39 |
|
the web server process (you might have to give it permission 777). |
| 40 |
|
|
| 41 |
Notes: |
Notes: |
| 42 |
Includes Smarty plugin assign_adv from |
- You can put plugins in the (drupal_base)/themes/engines/smarty/plugins directory. If you |
| 43 |
http://smarty.incutio.com/?page=AdvancedAssignPlugin |
download the full package from http://download.berlios.de/drupal-smarty/ this directory |
| 44 |
|
will already include the following useful plugins: |
| 45 |
|
- Smarty plugin assign_adv from http://smarty.incutio.com/?page=AdvancedAssignPlugin |
| 46 |
|
- There might be a problem with clashes with functions called smarty_foo (Drupal might |
| 47 |
|
discover them as potential theme_foo functions) so try and avoid this. |
| 48 |
|
- The way Smarty plugins/'wrapper' functions work has changed. Create a function |
| 49 |
|
mytheme__register_smarty_functions in your theme's template.php which returns an array |
| 50 |
|
like the array $plugins in function &_smarty_get_object |
| 51 |
|
- smartytemplate.php is no longer used. Put a template.php file in your theme instead |
| 52 |
|
|
| 53 |
Help/Problems: |
Help/Problems: |
| 54 |
For problems or help: |
For problems or help: |
| 55 |
First search drupal.org for problems and look through drupal.org forums before |
First search drupal.org for problems and look through drupal.org forums before |
| 56 |
contacting through email. |
contacting through email. |
| 57 |
|
|
| 58 |
Author email: travis dot cline at gmail dot com |
Author email: djnz at |
| 59 |
|
travis dot cline at gmail dot com |
| 60 |
Original author email: lobo at yahoo dot com |
Original author email: lobo at yahoo dot com |
| 61 |
|
|
| 62 |
Please include 'drupal smarty engine question' or something of the sort in the subject. |
Please include 'drupal smarty engine question' or something of the sort in the subject. |
| 70 |
tacker |
tacker |
| 71 |
Goba |
Goba |
| 72 |
tclineks |
tclineks |
| 73 |
|
djnz |
| 74 |
|
|
| 75 |
License: |
License: |
| 76 |
Distributed under GPL - see LICENSE.txt |
Distributed under GPL - see LICENSE.txt |
| 77 |
|
|
| 78 |
|
// TODO theme building documentation |
| 79 |
|
// - note changes for Drupal 6 |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
Template variables available |
| 83 |
|
---------------------------- |
| 84 |
|
$layout - none, left, right or both |
| 85 |
|
$id - count for the number of times the hook has been called |
| 86 |
|
$zebra - odd/even zebra count for the number of times the hook has been called |
| 87 |
|
|
| 88 |
|
$directory - path to the current theme |
| 89 |
|
$is_front - front page flag |
| 90 |
|
$logged_in - TRUE if not anonymous |
| 91 |
|
$is_admin = TRUE if admin user |
| 92 |
|
$head_title - title for <title> tag |
| 93 |
|
$base_pat - base url of site |
| 94 |
|
$breadcrumb - themed breadcrumbs |
| 95 |
|
$feed_icons |
| 96 |
|
$footer_message - from site information |
| 97 |
|
$head - other stuff for <head> |
| 98 |
|
$language - language object |
| 99 |
|
$help |
| 100 |
|
$logo |
| 101 |
|
$messages |
| 102 |
|
$primary_links - array of primary links |
| 103 |
|
$secondary_links - array of secondary links |
| 104 |
|
$search_box - themed search box |
| 105 |
|
$site_name |
| 106 |
|
$mission |
| 107 |
|
$site_slogan |
| 108 |
|
$help |
| 109 |
|
$logo |
| 110 |
|
$messages |
| 111 |
|
|
| 112 |
|
$css - ? css ) Not sure what the difference |
| 113 |
|
$styles - css files ) is here? |
| 114 |
|
$scripts - javascript to load in <head> |
| 115 |
|
$tabs - themed tasks |
| 116 |
|
$title - page title (for html title tag) |
| 117 |
|
$closure - theme('closure'); |
| 118 |
|
|
| 119 |
|
$body_classes - for insertion in <body$body_classes> |
| 120 |
|
|
| 121 |
|
$template_files - an array of potential template files - not much use to a template? |
| 122 |
|
|
| 123 |
|
For node.tpl |
| 124 |
|
$node - the raw node object |
| 125 |
|
$teaser - TRUE if the content is a teaser (?? is this right?) |
| 126 |
|
$content - the $node->teaser or $node->body as appropriate |
| 127 |
|
$date - formatted creation date |
| 128 |
|
$links - themed links |
| 129 |
|
$name - themed user name of creator |
| 130 |
|
$node_url - the url to display the node |
| 131 |
|
$taxonomy - taxonomy links |
| 132 |
|
$terms - themed taxonomy links |
| 133 |
|
$title - the node title (plain text, so not sure how &,',? etc. are treated) |
| 134 |
|
$submitted - themed submission user/time |
| 135 |
|
$picture - themed avatar |
| 136 |
|
|
| 137 |
|
$... - an explosion of the $node[...] array - lets hope there are no clashes! |
| 138 |
|
|
| 139 |
|
For block.tpl |
| 140 |
|
$block_zebra - 'odd' or 'even' for instances of a block in a region |
| 141 |
|
$block_id - counter for block in a region |
| 142 |
|
$block - the block object |
| 143 |
|
|
| 144 |
|
Note that the smarty template engine no longer sets the following additional variables: |
| 145 |
|
$user - use {$smarty.globals.user} if you must, or { |
| 146 |
|
$path_to_theme - this is now replaced by {$directory} which is set by |
| 147 |
|
Drupal core |
| 148 |
|
$base_path - but this can still be used as it is now set by Drupal core |