|
View:
New views
15 Messages
—
Rating Filter:
Alert me
|
|
|
Challenging an Assumption About What an Easy tpl.php Looks LikeGang,
Every tpl.php file that I've seen in any theme is written in html with php interspersed for putting in variables. I think part of the reasoning for this approach is that it would be easier for non-geek designers to read such pages. I want to challenge that. I think all those php open-close and all the "print" commands makes for very hard-to-read code. Tonight, as an experiment, I rewrote the node.tpl.php file from Zen from html to php. I think it is a lot easier to read. And it's sure a lot easier to comment. I pasted my rewritten version and the original from Zen onto a pastebin: http://pastebin.ca/1614186 Anyway, I'd be curious what other's opinions are on this. best, Shai _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeWhile "easier to read" is probably a personal preference, it can be a real pain to track down extra/missing single quotes.
On Sun, Oct 11, 2009 at 7:46 PM, Shai Gluskin <shai@...> wrote: Gang, -- Email is not a secure form of communication! Drupal Consultant http://www.hazelconsulting.com/ 253.686.0296 dave@... skype: hazelconsulting gtalk:kananii http://www.facebook.com/davidhazel ICQ: 366587185 _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeAgreed. I prefer the way it's usually done.
----- Cameron Eagans Owner, Black Storms Studios, LLC http://www.blackstormsstudios.com On Sun, Oct 11, 2009 at 9:02 PM, David Hazel <dave@...> wrote: While "easier to read" is probably a personal preference, it can be a real pain to track down extra/missing single quotes. _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeI think when you factor in the perspective of
whom may be making the changes, the question of ‘easier to read’ may change. With the full PHP version I think it is less
clear where non-geek HTML designers should make the changes, since it is all
PHP code. In the HTML with PHP mixed, at least it is
clear that the designer should make any changes inside the <?php … ?> regions, while there fewer clear indicators
where HTML updates should be make, or how to visually find them. As an aside, the indenting of the HTML by DIV
level is lost in the full PHP version which I think designers were feel keenly. Also the difference between single and double
quotes may be lost of a designer, as well as escaping characters (if needed). My 2 cents of course. Greg From: consulting-bounces@...
[mailto:consulting-bounces@...] On
Behalf Of Shai Gluskin Gang, _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeAnyway, I'd be curious what other's opinions are on this. I find it harder to read. It may be just what I am used to after 6 years of Drupal. I think php blocks are sometimes more readable than interspersed HTML and PHP, but this is only when you have a lot of control statements and such. A mere <?php print $foo ?> is acceptable to intersperse with HTML IMO. Khalid M. Baheyeldin 2bits.com, Inc. http://2bits.com Drupal optimization, development, customization and consulting. Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra Simplicity is the ultimate sophistication. -- Leonardo da Vinci _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeDavid Hazel wrote:
> While "easier to read" is probably a personal preference, it can be a > real pain to track down extra/missing single quotes. > > Not only that, but in my experience, once the template is complete, it will more often be the case that new HTML needs to be dropped in than the PHP being changed, and having the HTML as strings makes that very time consuming, where being able to just paste it or type it can be a few minutes' work. _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeIs there a difference between the two as to whether the file can be
loaded and safely edited in Dreamweaver in WYSIWYG mode? (I don't use DW, but I know many (/most?) designers do.) Also, I showed these to my wife, who can read & edit basic HTML, but not PHP. I asked her if she'd be comfortable with moving the taxonomy terms to display after the node contents. First seeing the PHP version, she did not think she could safely do it. Then seeing the original, she immediately point to the correct block of three lines, and said she'd copy and past them to line 71. Perfect. An unscientific test for sure, but I'd definitely side with the traditional form. Best, Matt Shai Gluskin wrote: > Gang, > > Every tpl.php file that I've seen in any theme is written in html with > php interspersed for putting in variables. I think part of the > reasoning for this approach is that it would be easier for non-geek > designers to read such pages. > > I want to challenge that. I think all those php open-close and all the > "print" commands makes for very hard-to-read code. Tonight, as an > experiment, I rewrote the node.tpl.php file from Zen from html to php. > I think it is a lot easier to read. And it's sure a lot easier to comment. > > I pasted my rewritten version and the original from Zen onto a pastebin: > http://pastebin.ca/1614186 > > Anyway, I'd be curious what other's opinions are on this. > > best, > > Shai > ------------------------------------------------------------------------ > > _______________________________________________ > consulting mailing list > consulting@... > http://lists.drupal.org/mailman/listinfo/consulting > consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.phpLooks LikeShai,
I absolutely agree with you on the readability aspect. I, too, rewrote several
tpl.php files before I stumbled across a post on DO somewhere that said the
interspersed technique was as much as 4 times faster to execute. However, we
still see "print" used exclusively when "echo" is faster...
Nancy E. Wichmann,
PMP
Injustice
anywhere is a threat to justice everywhere. -- Dr. Martin L. King,
Jr.
_______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
|
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeShai,
When a designer is not involved I almost always use php only versions of tpl files, but I do find designers are much more comfortable with the mixed technique. As to Matt's question about Dreamweaver, the assumption is correct, you cannot view the php only versions in "design view" where you can with the mixed method, however, given there is no css available to the tpl files in design view, I'm not sure designers would ever use design view, so it might not be an issue. What I do find a lot more readable in the mixed method is instead of all those <?php print $terms ?> statements is the simple <?=$terms ?> but I guess there's some good reason that method isn't used. Sam On Mon, Oct 12, 2009 at 8:59 AM, Shai Gluskin <shai@...> wrote: Gang, _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeOn a somewhat disconnected note, on highly customized themes, as a
project manager or lead developer, you can plug a plain html file into the theme, and it 'works' if not dynamically. Then you can assign a dev to go back and 'plug in' the php. With the php-only approach you need to convert a plain html file into the new style. I don't know how everyone else works, but whereever possible I get an html mockup from the designers, and it just doesn't make sense to add the extra step. I suppose this approach is fine for a developer translating photoshop mockups, but I don't think it would be feasible after you scaled to having designs provided as html/css. Thanks. -Sam _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeOne thing this discussion seems to miss is that there are both
functions and template files that can be used. If you are going to use the PHP approach, using the function makes more sense. _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeSteve,
Can you give a little more detail here. To which function are you referring? Shai _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks LikeOn Tue, Oct 13, 2009 at 12:09 AM, Sam Cohen <sam@...> wrote:
The syntax you refer to is called "short tags", and is not universally supported (it has to be turned on in your php config). I think there may also be arguments about performance on short tags, but the main issue is the cross platform support.
This is also reflected in the coding standards, which may point to some more detailed discussions if interested. _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
|
|
Re: Challenging an Assumption About What an Easy tpl.php Looks Like
http://pastebin.ca/1616950 offers an alternative to that, using
<<<OUTPUT ... OUTPUT; so you can just paste in the php
variables to print.
I noticed that this tpl file uses a lot of PHP functionality besides printing variables, which, as I understand, is to be avoided where possible. Perhaps the Zen theme should be doing a lot of the t(' in ') and if statements in a template preprocess function anyway, to clean things a little better for theming? Aaron Shai Gluskin wrote: Gang, -- Aaron Winborn Advomatic, LLC http://advomatic.com/ Drupal Multimedia available in September! http://www.packtpub.com/create-multimedia-website-with-drupal/book My blog: http://aaronwinborn.com/ _______________________________________________ consulting mailing list consulting@... http://lists.drupal.org/mailman/listinfo/consulting |
| Free embeddable forum powered by Nabble | Forum Help |