By: mgb
Date: 2007-10-30
Time: 16:15
|
Conditional problems
I have this php code:
$__section = 1;
$_menu[0] = array('section'=> 1,'url'=> 'index.php','title'=> 'index.php');
$_menu[1] = array('section'=> 2,'url'=> 'toplist.php','title'=> 'toplist.php');
$_menu[2] = array('section'=> 3,'url'=> '#','title'=> '');
$_menu[3] = array('section'=> 4,'url'=> '#','title'=> '');
$_menu[4] = array('section'=> 5,'url'=> '#','title'=> '');
$_menu[5] = array('section'=> 6,'url'=> '#','title'=> '');
$_menu[6] = array('section'=> 7,'url'=> '#','title'=> '');
$_menu[7] = array('section'=> 8,'url'=> '#','title'=> '');
$__tbs->MergeBlock('tabmenu',$_menu);
|
And this template
<tr>
<td style="width: 122px;">[tabmenu;block=td;when[tabmenu.url]='#'] </td>
<td>[tabmenu;block=td;when[tabmenu.section]=var.__section]<img src="images/topmenu[var.__section]3.jpg"></td>
<td>[tabmenu;block=td;when[tabmenu.section]!=var.__section]<a href="[tabmenu.url]" class="menu[tabmenu.section]"><img src="./images/pix.gif" alt="[tabmenu.title]" title="[tabmenu.title]"></a></td>
</tr>
|
What I dont get it that when this is merged it merges all them 3 at the time giving me this result
<tr>
<td style="width: 122px;"> </td>
<td><img src="images/topmenu13.jpg"></td>
<td><a href="#" class="menu3"><img src="./images/pix.gif" alt="" title=""></a></td>
<td style="width: 122px;"> </td><td><img src="images/topmenu13.jpg"></td>
<td><a href="#" class="menu6"><img src="./images/pix.gif" alt="" title=""></a></td>
<td style="width: 122px;"> </td><td><img src="images/topmenu13.jpg"></td>
</tr>
|
when what I wanted what this
<tr>
<td><img src="images/topmenu13.jpg"></td>
<td><a href="toplist.php" class="menu3"><img src="./images/pix.gif" alt="" title=""></a></td>
<td style="width: 122px;"> </td>
<td style="width: 122px;"> </td>
<td style="width: 122px;"> </td>
<td style="width: 122px;"> </td>
<td style="width: 122px;"> </td>
</tr>
|
what I want tbs to do is
if (url = '#') {
// do this
} else {
if(section == _section)
//do this
else
//do this
}
|
I hope someone can help me
Thanks in advance
|
By: Skrol29
Date: 2007-10-30
Time: 23:16
|
Re: Conditional problems
Hi,
First, you have to write "when [" instead of "when[".
It must have a space after the "when".
I also suggest that you put string delimiters in both side of the equal symbol or none. This is a bug I'm working on. (TBS 3.2.0)
For example you should code
when [tabmenu.url]=#
or
when '[tabmenu.url]'='#'
Regards,
|
By: mgb
Date: 2007-10-31
Time: 10:40
|
Re: Conditional problems
Thanks again Skrol29,
I guess I just stared my self blind and didnt see the missing space.
btw it works with only quotes around the #, but I will remove them just in case :)
I think tbs rocks, but I have some hardcore python fans that are hard to convince as there is no python port of tbs. Do you know if anyone is working on this?
|
By: mgb
Date: 2007-10-31
Time: 10:51
|
Re: Conditional problems
I guess I was a bit to fast there.
It works but not a 100%
<td style="width: 122px;">[tabmenu;block=td;when [tabmenu.url]=#] </td>
<td>[tabmenu;block=td;when '[tabmenu.section]'!='var.__section']<a href="[tabmenu.url]" class="menu[tabmenu.section]"><img src="./images/pix.gif" alt="[tabmenu.title]" title="[tabmenu.title]"></a></td>
<td>[tabmenu;block=td;when '[tabmenu.section]'='var.__section']<img src="images/topmenu[var.__section]3.jpg"></td>
|
It never hits the 3rd option even though tabmenu.section == var.__section I tried both with quotes and without. I also tried changing the order so of the whens. Nothing worked :(
|
By: Skrol29
Date: 2007-10-31
Time: 11:33
|
Re: Conditional problems
>I think tbs rocks, but I have some hardcore python fans that are hard to
> convince as there is no python port of tbs. Do you know
> if anyone is working on this?
I've heard about TBS for asp.net, but nothing about Python.
|
By: Skrol29
Date: 2007-10-31
Time: 12:09
|
Re: Conditional problems
The expression
'[tabmenu.section]'!='var.__section' |
is no correct, it should be
'[tabmenu.section]'!='[var.__section]' |
|
By: mgb
Date: 2007-10-31
Time: 12:15
|
Re: Conditional problems
Thank you, I will correct it as soon as I finished slamming my head into the table.
***SPOILER***
Right now I am looking at a subblock implementation
so most likely I have have a question later today too...
but I will give it a go my self first :)
|
By: mgb
Date: 2007-10-31
Time: 12:17
|
Re: Conditional problems
I guess I will have to tell my snaky friends to stop bitching and write a port them selfs :)
|
|
Posting in progress.
Please wait...
|