- Moderated by:
- Support
-
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Hey all onto my next hill so I finally figured out how to get my items to display from my query ( god bless the Smarty docs ) but now I want to use some if elseif statements in my template, but I am having an issue where things aren't working the way I want them to.
I have my template setup like this right now:
Code
<table style="text-align:center;width:100%;" border="0">
<tr>
<th><!--[pnml name="_pnChangeSTEPS"]--></th>
<th><!--[pnml name="_pnChangeTASKS"]--></th>
</tr>
<!--[section name="pnChangeitems" loop=$pnChangeitems]-->
<tr>
<td><!--[$pnChangeitems[pnChangeitems].0|pnvarprephtmldisplay]--></td>
<td><!--[$pnChangeitems[pnChangeitems].1|pnvarprephtmldisplay]--></td>
</tr>
<!--[/section]-->
</table>
This works and will display the things needed, but I want to be able to test $pnChangeitems[pnChangeitems].0 for the value and per that value I want to display some other text, so right now it works like this:
Code
Change Management Item Name Change Management Item Data
prep tar content up
proced untar tar ball
test test site for login
backout shut down server ( new )
followup contact NOC with status
so the end I want to be able to do is to test for things like "prep,proced,test,backout, and followup" and if the test is true for that dispaly Preparation Steps Procedure Steps etc.
I tried the method on the Smarty page and this did somewhat work, but it printed out my if statement also, so I took a look at the example module and tried the method used in the display template and no dice there so here I am after trying several things any help you all may offer would be great.
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
To make testing easier, try assigning the variables to a shorter name. Like $pnChangeitems[pnChangeitems].0 to Zero.
Then you should be able to do this:Code
<!--[if $Zero eq "prep"]-->
<!--[pnml name="_IMAPREPPY"]-->
<!--[elseif $Zero eq "proced"]-->
<!--[pnml name="_PROCED]-->
<!--[/if]-->
It sounds like you might have missed a [] or something. I do that. Drives me nuts! -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Ok so that kinda works, but for some reason when testing it only loops once and then we get nothing else printed out, example below:
template file
Code
<table style="text-align:center;width:100%;" border="0">
<tr>
<th><!--[pnml name="_pnChangeSTEPS"]--></th>
<th><!--[pnml name="_pnChangeTASKS"]--></th>
</tr>
<!--[section name="pnChangeitems" loop=$pnChangeitems]-->
<tr>
<td>
<!--[if $pnChangeitems[pnChangeitems].0 == "prep"]-->
<!--[pnml name="_PREP"]-->
<!--[elseif $$pnChangeitems[pnChangeitems].0 == "proced"]-->
<!--[pnml name="_PROCED"]-->
<!--[elseif $$pnChangeitems[pnChangeitems].0 == "test"]-->
<!--[pnml name="_TEST"]-->
<!--[elseif $$pnChangeitems[pnChangeitems].0 == "backout"]-->
<!--[pnml name="_BACKOUT"]-->
<!--[/if]-->
</td>
<td><!--[$pnChangeitems[pnChangeitems].1|pnvarprephtmldisplay]--></td>
</tr>
<!--[/section]-->
</table>
Display now:
Code
Change Management Item Name Change Management Item Data
Change Preparation Steps tar content up
untar tar ball
test site for login
shut down server ( new )
Any ideas on this one??
Thanks
-SUNADMN -
- rank:
-
Professional
- registered:
- April 2004
- Status:
- offline
- last visit:
- 21.01.08
- Posts:
- 2723
Keep in mind that this (ie):
$pnChangeitems[pnChangeitems].0 ...
...should be something like...
$pnChangeitems.pnChangeitems.0 ...
;)
Change all instances and see what you come up with...
--
Photography | PHP | Other -
- rank:
-
Professional
- registered:
- April 2004
- Status:
- offline
- last visit:
- 21.01.08
- Posts:
- 2723
...but then again, that shown above would seem a strange way to arrange the array (ie, double-nested)...
...did you mean this:
... if $pnChangeitems.0 ....
?
--
Photography | PHP | Other -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
it was a typo when I was writing things out lastnight Mark I had been up for 24 hours with no sleep so I missed that, but caught it this morning. On a side note to this I just posted a question under the Xathnia pnRender forum about problems do regex inside the template if any of you have a sec maybe you can hop over and take a look and tell me if it is even possible to do what I want to do.
Thanks all
-SUNADMN
