Can I use a different template engine?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Can I use a different template engine?

Post by jabeavers »

I was wondering if it is possible to use a different templating engine without entirely rewriting everything. Can that be done with a plugin or does it need to be rewritten to do that. The templating engine I want to use is Savant, in case you were wondering.

John
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Can I use a different template engine?

Post by Timbalu »

Hi

Well, you have to write your own template_api.inc, similiar to the one used in /includes, when you dont want to use smarty at all. I dont think it does make sense to do so using savant, which isnt really proccessing to be a real alternative. Else you could use the template_api and the default-php template to write a template with php only.

Ian
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: Can I use a different template engine?

Post by jabeavers »

Well, the reason I ask is that we use Savant for all the websites we develop, and it would be nice to use Savant for the blog templates, so we can use the same templates (header.tpl, footer.tpl) to make the site and the blog look the same.

I'll give it a try and see how it goes.

Thanks,
John
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Can I use a different template engine?

Post by Timbalu »

Hi

Serendipity will still make use of smarty internally, even if you add savant via a template_api.
I think, it would be a lot easier to convert the savant templates to smarty templates, particulary if you only mean to copy header.tpl and footer.tpl.

Ian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Can I use a different template engine?

Post by garvinhicking »

Hi!
Timbalu wrote:Hi

Serendipity will still make use of smarty internally, even if you add savant via a template_api.
I think, it would be a lot easier to convert the savant templates to smarty templates, particulary if you only mean to copy header.tpl and footer.tpl.

Ian
What do you mean? The template_api completel replaces the Smarty object. No smarty will be involved, if you choose to create a Svant template API model...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Can I use a different template engine?

Post by Timbalu »

Hi Garvin

Yes, in the frontend, AFAIK. The template_api.inc explicitly says

Code: Select all

 The Serendipity Admin backend will still make use of Smarty. It rocks.
Ian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Can I use a different template engine?

Post by garvinhicking »

Hi!

Ah, I think I added that as a general statement to indicate that the backend has special needs and that custom template APIs might not do the job there - and also that the core s9y backend is not really templatized overall. But you're right, it's good to mention this.

The way I understand it though, is that the frontend is more important for jabeavers?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Can I use a different template engine?

Post by Timbalu »

garvinhicking wrote:The template_api completel replaces the Smarty object. No smarty will be involved, if you choose to create a Svant template API model...
What is true now? Is it a complete remove or just a disable and replace for all frontend output?
garvinhicking wrote:The way I understand it though, is that the frontend is more important for jabeavers?
Yes.
Thats why I thought it would be easier to convert savant to smarty, than vice versa.

Ian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Can I use a different template engine?

Post by garvinhicking »

Hi!

The template API only wraps the calls to smarty that are relevant for the frontend. I believe there are some calls that we need in the backend to other methods of the Smarty object, that are not part of Template API (but could be). So actually I would need to study the code for that again, but I'm too short in time right now...

I do understand jabeavers need to have a unified templating structure, so that if multiple people are savy with savant, that they should use this template API instead of Smarty. In the usual case, only frontend templates need adapting, so once the groundwork for a Savant template API class is done, nobody in his team would need to know of Smarty. Also, it would be nice to see someone finally having a stab at the template API for s9y, so that we could maybe improve it to work better with savant and put it up as a plugin/template... :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Can I use a different template engine?

Post by Timbalu »

garvinhicking wrote:The template API only wraps the calls to smarty that are relevant for the frontend.
Good to know. I just wanted to have it clear in this question. :wink:
garvinhicking wrote:Also, it would be nice to see someone finally having a stab at the template API for s9y, so that we could maybe improve it to work better with savant and put it up as a plugin/template...
Yes, that would be nice to have. Please go, jabeavers :!:

Ian :mrgreen:
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: Can I use a different template engine?

Post by jabeavers »

Wow, thanks all for the discussions and tips. I will certainly look at this when I have time. I'll let you know how it goes.

John
Post Reply