Forums / Cotonti / Support / cache in tpl include.... seriously!

tensh
#1 2013-01-02 14:12

Hi;

I can't stand the caching in tpl file include. The code like this:

{FILE "./themes/{PHP.cfg.defaulttheme}/inc/{PHP.pag.page_MYEXTRAFIELD}"} doesn't work since the values are cached and aren't dynamic.

Not to mention that the code:

{FILE "./themes/{PHP.cfg.defaulttheme}/inc/{PAGE_ANYTAG}"}

doesn't work at all since {PAGE_ANYTAG} is empty.

Can you please give me any fix/solution? I wanted to include a template based on extrafield value (path), and I'm in a serious trouble now.

Macik
#2 2013-01-02 15:06

Similar question had been discussed somewhere on forum… You can not use «dynamic» FILE statments. 

As a solution bring template logic to your TPL files rather creating separate TPL files for any case. So you need to include one file:

{FILE "./themes/{PHP.cfg.defaulttheme}/inc/extrafields.tpl"}

and then in file use IF blocks:

<!-- IF {PHP.pag.page_MYEXTRAFIELD} == 'some value' -->
  you template here
<!-- ENDIF -->
<!-- IF {PHP.pag.page_MYEXTRAFIELD} == 'other value' -->
  you second template here
<!-- ENDIF -->

 

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
tensh
#3 2013-01-03 10:05

Yeah, you're right, but I have to know the values and so the whole thing isn't dynamic. :(

Trustmaster
#4 2013-01-03 11:26

You can just disable tpl cache then if having dynamic includes is so important.

May the Source be with you!
Macik
#5 2013-01-03 12:59
#36683 tensh:

Yeah, you're right, but I have to know the values and so the whole thing isn't dynamic. :(

 

Can you explain your case more detailed ?  Why you need dynamic and how you are using it?

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F