That's what SMARTY were designed for...



  • I've been recently fixing a cms written in PHP using SMARTY tpl's... well, it was one of the requirments to do so. I fixed few bugs, and started checking for optimization, and I've found that page template looks like these:

    {$page_text}

     The whole content was generated using PHP, and SMARTY... well, they wanted them, so here they are, with their whole functionality 😉



  •  TRWTF is Smarty.  Why do we need a template language for PHP which is itself a template language?  Fuck it.


  • Discourse touched me in a no-no place

    @morbiuswilters said:

     TRWTF is Smarty.  Why do we need a template language for PHP which is itself a template language?  Fuck it.

     

     Because useless wanker web devs can't figure out how to not break PHP.



  • @Weng said:

     Because useless wanker web devs can't figure out how to not break PHP.



    And how do you "break" PHP? If you acctually meant breaking the application then i'm afraid smarty isn't going to help you.



  • @stratos said:

    @Weng said:
     Because useless wanker web devs can't figure out how to not break PHP.
    And how do you "break" PHP? If you actually meant breaking the application then i'm afraid smarty isn't going to help you.
     

    Maybe he means graphics designers? In my personal experience the vast majority of their expertise lies in using Dreamweaver and the like. Asking them to add their HTML to the PHP framework is usually like giving a 7 year old gunpowder and telling him to build his own fireworks. Even if he can figure it out, it will most likely end in tears.

    Unfortunately I have yet to meet a graphics designer that's interested in learning to use a template system, Smarty or otherwise. Their philosophy is usually "If I can't drag-n-drop, I aint using it".

    As for the OP... I hope they don't ask you to update the HTML.



  • My philosophy is "if you can't do html and css by hand, I am not working with you".



  •  Slightly side-tracking a bit, you just reminded me of the time I got called out- to remove a smarty from a USB socket. It's amazing what you find in there sometimes. I was so gobsmacked (This was an adult shop) that I took a picture- I'll have to go find it!



  • @DOA said:

    Maybe he means graphics designers? In my personal experience the vast majority of their expertise lies in using Dreamweaver and the like. Asking them to add their HTML to the PHP framework is usually like giving a 7 year old gunpowder and telling him to build his own fireworks. Even if he can figure it out, it will most likely end in tears.

    Unfortunately I have yet to meet a graphics designer that's interested in learning to use a template system, Smarty or otherwise. Their philosophy is usually "If I can't drag-n-drop, I aint using it".

    The one who should be electroshocked here is the person who asks a graphic designer to do any development at all. They are graphic designers. Not developers. A graphic designer -by definition- cannot do development, and a software developer cannot do graphic design. That's the whole point of specialization. It is just unfair to expect people to do stuff they are not trained to or don't have the affinity to do. Personally, I never will be able to sell cars, neither to catch criminals, nor to design graphics. That's because software development is my profession and I suck at everything else, including Photoshop, Dreamweaver and the rest.

    To be honest, I am sick of the arrogant elitist mentality of "everybody else is stupid" in the IT/Software Development Industry. It is really unprofessional and should be grown out already.



  • @DrJokepu said:

    To be honest, I am sick of the arrogant elitist mentality of "everybody else is stupid" in the IT/Software Development Industry. It is really unprofessional and should be grown out already.
    Yeah. But the question then remains... I got these fancy graphics here, and this nicely stable website that works great. Who is going to put them in the same jar and stir till it's one?



    The "I do software development, nothing else" mentality is also stupid. Someone has to put it all together. I've been a solo coder in a UT2004 mod (as hobby project), and while we had a few graphic artists, some modelers and a few people that build maps. I was the one that had to put it all together, rescaling models, fixing animations, exporting files to the right formats, fixing up maps, and tieing it all together in a final installer. In the end I had a 3D Studio Max, Photoshop and UnrealEd open, next to my coding tools (a text editor). Unless someone is getting out of that little box, you'll never get anywhere. Of course I'll never become a real artist, but I surely know the tools of the rest of the team.



  • @DrJokepu said:

    The one who should be electroshocked here is the person who asks a graphic designer to do any development at all. They are graphic designers. Not developers. A graphic designer -by definition- cannot do development, and a software developer cannot do graphic design. That's the whole point of specialization. It is just unfair to expect people to do stuff they are not trained to or don't have the affinity to do.
    Sounds good in theory, but in a project where a developer builds the code and the graphics designer does the HTML/CSS someone had to do the integration at the end. And when the graphics change and the graphics designer produces a new batch of HTML/CSS someone has to do it all over again. In practice it's the developer that has to do this mind-numbing grunt work. Which is why people have come up with template systems like Smarty.  And let's face it, using the HTML side of Smarty is not exactly rocket science. We're not asking graphics designers to track down a memory leak here.

    Even if it were unfair to ask graphics designers to use a template system, it's definately not as unfair as having a developer do cut-and-paste HTML grunt work. I don't see why both parties can't agree to use a template system and meet in the middle. 



  • Speaking of graphic designers, the one who works for my company had a real hard time learning PHP, and by learning, I mean learning about includes. She still often creates header.inc files (which can typically just be opened like text files across the web) and tons of other files. It's still an improvement when she first started working for me and was putting ASP in all of the files. I forgive all of this because she makes wonderful designs and templates.



  • urmmm, like someone already said. smarty is a tempalte language, and HEY what do you know, PHP is also a template language.

    <? FOREACH ( $items as $item): ?>

    <? IF ($item['special'] == true): ?>  special <? ENDIF; ?>

    <? ENDFOREACH; ?>

    vs.

    {foreach from=$items item=item}

    {if ($item.special == true) }  special {/if}

    {/foreach}

     

    No really what a big difference.



  • @stratos said:

    urmmm, like someone already said. smarty is a tempalte language, and HEY what do you know, PHP is also a template language.
    I don't understand. Do we have something better than Smarty and like for the separation of PHP from HTML/CSS in a way that can be maintained without the developer having to muck about with HTML/CSS?



  •  Dear Sir,

    I have be the requirement to write a Web 2.0 website in AJAX, SMARTY, PHP and CSV. SNARTY  says

    Smarty error: problem creating directory "templates_c/239/239105369"

    Smarty error: problem creating directory "templates_c/239/239105369"

    Smarty error: problem creating directory "templates_c/239/239105369"

    Could you tell me what the problem is? Please send me your code to hkhan@yahoo.co.in



  • @DOA said:

    I don't understand. Do we have something better than Smarty and like for the separation of PHP from HTML/CSS in a way that can be maintained without the developer having to muck about with HTML/CSS?

    Just use PHP.  Seriously, Smarty is just a slightly modified and weaker PHP syntax.  Your templates should mostly be HTML, CSS and JS anyway, with some variables pulled in and maybe a little bit of conditional logic or looping.  This is what Smarty does.  This is also what PHP does.  Why would you install a separate application to essentially emulate PHP-lite on top of PHP?



  •  @morbiuswilters said:

    Just use PHP.  Seriously, Smarty is just a slightly modified and weaker PHP syntax.  Your templates should mostly be HTML, CSS and JS anyway, with some variables pulled in and maybe a little bit of conditional logic or looping.  This is what Smarty does.  This is also what PHP does.  Why would you install a separate application to essentially emulate PHP-lite on top of PHP?
    Ah, I see. Well, assuming we have a graphics designer that would add his own stuff, I'd have to go with a template system because of the greater separation of presentation from code. Template systems tend to keep presentation in separate files which is good for graphics designers whose eyes understandably glaze over when confronted with the usual spaghetti of code and presentation you'd find a single PHP file (we're talking heavy-duty admin pages and the like here). Not only that but the more you have to deal with internationalization the more handy a template system becomes.

    That said, if I could find a graphics designer that's unfazed by the prospect of manouvering through code to make his changes (and can do so without messing up the code) I'd be more than happy to forego the template system and let him have a go at the .php files.



  •  Ummm, so you need a third party application to put your presentation code into another file?



  • @DOA said:

    Ah, I see. Well, assuming we have a graphics designer that would add his own stuff, I'd have to go with a template system because of the greater separation of presentation from code. Template systems tend to keep presentation in separate files which is good for graphics designers whose eyes understandably glaze over when confronted with the usual spaghetti of code and presentation you'd find a single PHP file (we're talking heavy-duty admin pages and the like here). Not only that but the more you have to deal with internationalization the more handy a template system becomes.

    That said, if I could find a graphics designer that's unfazed by the prospect of manouvering through code to make his changes (and can do so without messing up the code) I'd be more than happy to forego the template system and let him have a go at the .php files.

    Seriously, what the hell are you talking about?  PHP is a templating language, in addition to many other things.  If your pages are spaghetti logic all crammed into one file, that is your fault.  Ideally you would have PHP template files with well-constructed business objects kept completely separate.  There is no need for Smarty to accomplish this.



  • @morbiuswilters said:

    Ideally you would have PHP template files with well-constructed business objects kept completely separate. There is no need for Smarty to accomplish this.
    If like you said I'm going to have a separation of logic and presentation then someone has to build that architecture. Why would I opt for the not-invented-here option by building my own when an existing template system like Smarty can do it for me?



  • @DOA said:

    Why would I opt for the not-invented-here option by building my own when an existing template system like Smarty can do it for me?

    Why would I opt for the not-invented-here option by building my own
    when an existing template system like PHP can do it for me?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.