xoops forums

srmcatee

Just popping in
Posted on: 2006/8/2 11:28
srmcatee
srmcatee (Show more)
Just popping in
Posts: 63
Since: 2005/8/22
#1

Smarty Templates - Auto Recompile

Hello,

I'm working with Smart templates and I wonder if there is anyway to "auto-recompile" them. When I make a template change the onlyway to see it is to run an update of my module from the administrator screen.

Is there any easier way to do this?
Steve
ChurchLedger.com - A Xoops Module Developer

McNaz

Just can't stay away
Posted on: 2006/8/2 12:58
McNaz
McNaz (Show more)
Just can't stay away
Posts: 574
Since: 2003/4/21
#2

Re: Smarty Templates - Auto Recompile

Hi,

Xoops Admin -> General Settings -> Check templates for modifications ? set to yes. This will recompile any changed smarty template files.

HTH.

srmcatee

Just popping in
Posted on: 2006/8/3 1:44
srmcatee
srmcatee (Show more)
Just popping in
Posts: 63
Since: 2005/8/22
#3

Re: Smarty Templates - Auto Recompile

Hi,

I'm referring to the templates directory under modules. Not the templates directory in themes.

Is there a setting to recompile the templates in this directory?
Steve
ChurchLedger.com - A Xoops Module Developer

McNaz

Just can't stay away
Posted on: 2006/8/3 7:17
McNaz
McNaz (Show more)
Just can't stay away
Posts: 574
Since: 2003/4/21
#4

Re: Smarty Templates - Auto Recompile

Quote:
I'm referring to the templates directory under modules.


I was referring to BOTH the theme templates AND module templates. This setting recompiles both.

Dave_L

XOOPS is my life!
Posted on: 2006/8/3 11:22
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#5

Re: Smarty Templates - Auto Recompile

At some point, that behavior was changed.

In XOOPS 2.0.14, that setting causes recompilation of all templates, including module templates.

In XOOPS 2.2.4, module templates do not get recompiled.

I've been planning to figure out why, but haven't got around to it.

kaotik

Just can't stay away
Posted on: 2006/8/3 15:23
kaotik
kaotik (Show more)
Just can't stay away
Posts: 861
Since: 2004/2/19
#6

Re: Smarty Templates - Auto Recompile

I'd also like to know how to fix this in 2.2.4 I've been going through the code tring to find where templates are checked. I'll post here if I find a solution.

conrad10781

Just popping in
Posted on: 2006/8/4 13:03
conrad10781
conrad10781 (Show more)
Just popping in
Posts: 2
Since: 2006/8/1 1
#7

Re: Smarty Templates - Auto Recompile

Quote:

kaotik wrote:
I'd also like to know how to fix this in 2.2.4 I've been going through the code tring to find where templates are checked. I'll post here if I find a solution.



I am a 2.0 User, but know SMARTY, etc... There is a smarty command

$smarty->force_compile true


Will overwrite template files each time they are called normally this is for a development server and should not be used on a live server.. You should be able to include the smarty class into your module php file, and then run that command.

I am pretty sure that is the code that is behind 2.0's admin setting

Dave_L

XOOPS is my life!
Posted on: 2006/8/4 19:30
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#8

Re: Smarty Templates - Auto Recompile

In XOOPS 2.2.4, I've tried setting force_compile = true in various places, without any effect. I suspect it may be the way that XOOPS overrides Smarty's template handling (the source templates are stored in the database). The force_compile variable may cause the template to get recompiled from the database, but what needs to happen is forcing the template stored in the database to get updated from the file on disk.

birdseed

Just popping in
Posted on: 2006/8/5 10:19
birdseed
birdseed (Show more)
Just popping in
Posts: 59
Since: 2005/2/26
#9

Re: Smarty Templates - Auto Recompile

Hi

In order to have auto compilation for 2.2.4, you have to make a hack...

In class/smarty/plugins/resource.db.php

Change every line

if ($conf_theme != 'default') {

to

if(!in_array($conf_theme, 'default', 'your theme'))

This allows to keep 'your theme' templates in the modules/xxx/template dir

greetings
bsm

Dave_L

XOOPS is my life!
Posted on: 2006/8/5 15:31
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#10

Re: Smarty Templates - Auto Recompile

Thanks, birdseed.

I just did a test (without your hack), and found that the problem does not occur with the default theme, but only with other themes.