[themes] shortcut for phptemplate variable printouts
Bèr Kessels
ber at webschuur.com
Sat Jun 24 12:48:07 UTC 2006
Op vrijdag 23 juni 2006 19:04, schreef Farsheed:
> Hi,
>
> In order to minimize the php code seen by a themer, I
> was wondering what people thought of making simple
> aliases for basic printouts of phptemplate variables.
> The phptemplate engine would go in and find these
> aliases and convert them to their actual values.
>
> BEFORE:
> <?php print $content ?>
> <?php print $sidebar_left ?>
>
> AFTER:
> {$content}
> {$sidebar_left}
>
> Just looking to reduce the amount of potentially
> intimidating code for new themers. Of course regular
> PHP should still work.
Two reason why this is a bad idea:
Aliases are bad. PHPtemplate already offers far too many "ways to Rome". Work
out *one* way in detail, make sure its documented WELL. As opposed to: offer
a gazillion tricks and hidden gems, that are neither documented nor obvious
to newbies and gurus. I theme with PHPT daily, yet still cannot grok certain
thingies, because these thingies can be done in fourteen different ways, you
need to know all fourteen, and remember all their specifics, pros and cons.
PHP is *not* intimidating. I have yet to find the designer who finds <?php
print $content ?> less obvious, or harder, or more intimidating then
{{content}}.
This statement becomes more obvios, when you need more complexity, like
conditions:
{{[[if:content!=""]]
<div>{{content}}</div>
}}
As opposed to:
<?php if ($content): ?>
<div><?php print $content ?></div>
<?php endif; ?>
But most important: There are a gazillion books, tutorials, helpers, courses,
schools, manuals etc on PHP. PHP works with most editors, Dreamweaver, yes
even photoshop support PHP. But some DrupalSyntax is not supported, let alone
that people can learn it outside of Drupal. Let alone that someone wants to
invest in learning something that he/she can only ever use with Drupal.
We should not try to invent some new things, but rather make the current
system a tad simpler and more obvious. Document it better, make behaviour a
lot more consistent. Why do I, as Drupal-nitwit, need to print sometimes
$name, other times $title, sometimes $comment->subject and again other times
$object->title? For drupal devels this is obvious (we know that a term is
like $term->name, while a node like $node->title, but a comment gets
$comment->subject). Why do I sometimes need some code in template.php, but in
other cases just use a box.tpl.php? Again: we know it, because we know the
code behind PHPtemplate. But we have to admit that it is *far* from logic if
you dont know that.
I am certain that if we focus our energy on these weird things, or
inconsistencies we gain a LOT more then if we invent Yet Another Scripting
Language.
Bèr
More information about the themes
mailing list