Sounds good!<br><br>Keep up the good work ;-)<br><br>Robin<br><br><div><span class="gmail_quote">On 5/3/07, <b class="gmail_sendername">Earl Miles</b> <<a href="mailto:merlin@logrus.com">merlin@logrus.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Robin Monks wrote:<br>> Hey,<br>><br>> From someone who hasn't really been following the changes, but who
<br>> really hates PHPTemplate (which is designed more toward developers,<br>> rather than graphics artists and end users IMHO) and would much rather<br>> use Smarty... Will Smarty still be available as an option in 6? AKA.
<br>> Will theme engines support still be there?<br>><br>> Robin<br><br>In fact, I believe that smarty will be better (assuming someone maintains it<br>and ports it to Drupal 6) due to these changes.<br><br>The actual code in
phptemplate.engine has been vastly reduced, and much of what<br>it does has been made inherent to Drupal, and it the PHPTemplate renderer has<br>been made the default renderer. Theme engines tell Drupal to use a different
<br>renderer (and, if they like a different extension).<br><br>Additionally, theming with templates has been broken up into two sections, one<br>for pre-processing, which is designed to transform data into something more<br>
suited for presentation (i.e, business logic), leaving the actual presenting to<br>the template (presentation code).<br><br>If you're familiar with the _phptemplate_variables() function in PHPTemplate,<br>what we've done is made it so that *every* theme template gets one (actually, a
<br>series) of these in order to massage the variables so that the template itself<br>can do as little as possible. Let's take a fairly minor example:<br><br>Grabbing a theme function from aggregator module:<br><br>function theme_aggregator_feed($feed) {
<br> $output = '<div class="feed-source">';<br> $output .= theme('feed_icon', $feed->url) ."\n";<br> $output .= $feed->image;<br> $output .= '<div class="feed-description">'.
<br>aggregator_filter_xss($feed->description) ."</div>\n";<br> $output .= '<div class="feed-url"><em>'. t('URL:') .'</em> '. l($feed->link,<br>$feed->link, array('absolute' => TRUE)) ."</div>\n";
<br><br> if ($feed->checked) {<br> $updated = t('@time ago', array('@time' => format_interval(time() -<br>$feed->checked)));<br> }<br> else {<br> $updated = t('never');<br> }
<br><br> if (user_access('administer news feeds')) {<br> $updated = l($updated, 'admin/content/aggregator');<br> }<br><br> $output .= '<div class="feed-updated"><em>'. t('Updated:') . "</em>
<br>$updated</div>";<br> $output .= "</div>\n";<br><br> return $output;<br>}<br><br>That's not terribly bad on its own, but it has a couple of things we really<br>don't like to see at the theme layer, particularly that filter_xss, which is a
<br>real bear when using an alternate theme. The way this will look in Drupal 6<br>will be, approximately:<br><br>/**<br> * All arguments sent to the theme template will be in $variables. The only<br> * argument this template accepts is 'feed', so we'll look there.
<br> */<br><br>function template_preprocess_aggregator_feed(&$variables) {<br> $feed = $variables['feed'];<br> $variables['feed_icon'] = theme('feed_icon', $feed->url);<br> $variables['feed_image'] = $feed->image;
<br> $variables['description'] = aggregator_filter_xss($feed->description);<br> $variables['feed_url'] = l($feed->link, $feed->link, array('absolute' => TRUE));<br> if ($feed->checked) {
<br> $variables['updated'] = t('@time ago', array('@time' =><br>format_interval(time() - $feed->checked)));<br> }<br> else {<br> $variables['updated'] = t('Never');
<br> }<br><br> if (user_access('administer news feeds')) {<br> $variables['updated'] = l($updated, 'admin/content/aggregator');<br> }<br>}<br><br>And then, aggregator_feed.tpl.php will look like this:
<br><br><div class="feed-source"><br><?php print $feed_url ?><br><?php print $feed_image ?><br><div class="feed-description"><br> <?php print $description ?><br></div>
<br><div class="feed-url"><br> <em><?php print t('URL:') ?></em> <?php print $feed_url ?><br></div><br><div class="feed-updated"><br> <?php print t('Updated:') ?></em> <?php print $updated ?>
<br></div><br><br><br>As you can see, this template can be in almost any language, with the exception<br>that it probably should somehow support t(). However, it doesn't have to,<br>because we have preserved and improved the old _phptemplate_variables()
<br>functionality. You can create this function:<br><br>phptemplate_preprocess_aggregator_feed(&$variables) {<br> ...<br>}<br><br>Or<br><br>phptemplate_engine_preprocess_aggregator_feed(&$variables) {<br> ...<br>
}<br><br>Or<br><br>garland_preprocess_aggregator_feed(&$variables) {<br> ...<br>}<br><br>Note that the engine gets its very own preprocess function if it needs it. This<br>isn't used by PHPTemplate at all, at this point, but other templating engines
<br>may need it to do auto-transformation should they so desire.<br><br>}<br></blockquote></div><br><br clear="all"><br>-- <br>Robin Monks<br>@ <a href="http://www.civicspacelabs.org">www.civicspacelabs.org</a><br>@ <a href="http://www.gmking.org">
www.gmking.org</a><br><br>Fax: (419) 791-8076<br><br>"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." ~IRC