Page 1 of 1

"Smarty" Templates

Posted: Sat Apr 23, 2005 4:11 pm
by Collectonian
Why did you guys have to change the system to use these hidious things? They suck. :(

I use a custom template on my site and I'm trying to get the thing upgraded to use those Smarty ones, based off the default, but when I try to do an include of the common header/footer of my site, it just breaks everything. I was able to do it no problem with the old system. How can I do it with the new one, or barring that, how can I fix the old layout.php file so it displays everything correctly again (now all the right side stuff is at the bottom)

Edit: After finding Smarty's documentation and doing some tweaking, I got most of it looking right. However I can't get it to include a menu file. I tried using the {php}{/php} thing from Smarty's documentation, but its just ignoring my includes. Any ideas?

Re: "Smarty" Templates

Posted: Mon Apr 25, 2005 11:11 am
by garvinhicking
Smarty does not suck, in fact it's the most popuplar templating system and we defintely needed to provide our users with it.

Having said this, it is abosolutely possible to achieve EVERYTHING you did with an old layout.php method on the new Smarty setup.

You can echo/output any stuff that has been previously echo'ed in layout.php via either exactly this layout.php file. But migrating to Smarty is really easy

If you'd tell us how exactly you did the include of your header/footer, I can tell you what you did wrong. And if your layout.php does not work currently, just provide a link to it here (to a nopaste-service, or a URL on your blog so I can see the code) - I will gladly look at it and tell you what you may need to modify. :)

The Smarty {php} tags are deactivated because of security issues. You can surpass this by creating a config.inc.php file in your template directory and use this:

Code: Select all

$serendipity['smarty']->security_settings[PHP_HANDLING] = true;
$serendipity['smarty']->security_settings[PHP_TAGS] = true;
Smarty, after some basic work, is really a simple and cool templating system, much easier than fiddling with PHP code for newbies :)

Have fun,
Garvin :)

Posted: Mon Apr 25, 2005 2:53 pm
by Collectonian
I reactivated the PHP code like you suggested and that worked, for the most part. My CSS is coming out a little screwy, but I can get that fixed now that I can see it. :D

As for Smarty, it may be popular, though I wouldn't say most popular; its certainly not used in any other PHP programs I use now or have ever used (or would ever used unless its like with this and "snuck up" on me. I still don't like it and I still think it sucks, but just my humble opinion. Then again, I have a low opinion of complex templating to begin with (I prefer a simple header and footer file that you pop your code into, and bam, site matches design...that is really MUCH easier for newbie PHPers than any templating system).

Anyway, thanks for the tip on help on getting the PHP turned back on.

Posted: Mon Apr 25, 2005 3:04 pm
by garvinhicking
I really see your point about the Smarty templating, that's why we tried to make old layout.php codes still work :)

BTW, it would be easy to add in any other Templating System into Serendipity. It would just mean to add another set of API calls and you could use PHPTAL, PHPLIB templates or any other system. I could implement any other templating system in maybe 1-2 days, so everyone could implement his or her own system by providing wrapper functions to the $serendipity['smarty'] object. :)

But for now, Smarty is our way to go (TM, R) ;-))

Regards and have fun,
Garvin