Categories > TinyButStrong general >

condision on template load

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: kasper
Date: 2007-03-06
Time: 16:55

condision on template load

isn't i posible to make something like this [onload;file='tema/[var.varTema]/kategorier.tpl';when [var.varCkat]=1;subtpl; getbody;]

it not reaction on the "when" statment
By: Bob
Date: 2007-03-06
Time: 20:53

Re: condision on template load

Hi Kasper,

Parameter "when" is ignored if the TBS tag is not a block tag.
This should work :
[onload;file;if [var.varCkat]=1;then 'tema/[var.varTema]/kategorier.tpl';subtpl; getbody;]

Not tested but it should work because:
1) [onload] is called as a fields with empty value ('').
2) Parameter "if" is processed before "file".
3) When parameter "file" exists but without value, then the value of the field is taken for the path. Typically: [var.path;file]
4) If the file to merge is empty ('') then nothing is include and no error is displayed.
By: Bob
Date: 2007-03-06
Time: 20:58

Re: condision on template load

PS : it would be more appropriate to manage this at the PHP side.

$path = ($varCkat==1) ? 'tema/'.$varTema].'/kategorier.tpl' : '';

[onload;file=[var.path]]
or
[onload.path;file]
By: kasper
Date: 2007-03-07
Time: 00:10

Re: condision on template load

[onload;file;if [var.varCkat]=1;then 'tema/[var.varTema]/kategorier.tpl'; else '';subtpl; getbody;]

when i use this tbl still tryes too load 'tema/[var.varTema]/kategorier.tpl' even when var.var.Ckat is 0, what can be the reason for that.

i see what u mean abot doing it on the php side, but here it would be much better if i could get it work on the html side, because its code for skinnig a system. so on another skin  could be using another file in sted of kategorier.tpl. (var.varTema is telling what skin is being used). Making it work on html would make the system more flexible and open for new skinning ideas. the reason for all of this is pure performans, i'm telling on php side then varCkat isn't 1 that the system doesn't need to include some of the code files, and that gives faster performance especial with many users.
By: kasper
Date: 2007-03-07
Time: 10:41

Re: condision on template load

sorry it workes fine i was just looking a wrong place