I am currently trying to change the ordering of my display on my webpage. My current code is the following.
<div class="itemtitle">
[% IF session.Type.match('B|N|H|BI') %]
[% session.TitleVal %]<br>
[% IF slot.getLocationString %]<div class="location">Location: <span>[% slot.getLocationString %]</span></div>[% END %]
[% ELSE %]
<a href="[% session.webprogram.getFilename %]">[% session.TitleVal %]</a><br>
[% IF slot.getLocationString %]<div class="location">Location: <span>[% slot.getLocationString %]</span></div>[% END %]
[% IF session.getParentsCollection('Program', ['ReadOnly','Y']) %]
<div class="sessionsponsor">Hosts: <span>(Joint
[% FOREACH parent IN session.getParentsCollection('Program') %]
[% IF loop.last && loop.first %]with [% END %][% IF !loop.last && loop.first %]between [% END %][% IF loop.last && !loop.first %]and [% END %]the [% IF loop.first %]<strong>[% END %][% parent.Title %][% IF loop.first %]</strong>[% END %][% IF !loop.last %]; [% END %]
[% END %])</span></div>
[% ELSE %]
[% IF session.program.Title %]<div class="sessionsponsor">Host: <span><strong>[% session.program.Title %]</strong></span>[% END %]</div>
[% END %]
[% END %]
The first IF statement code block I always want to display at the top of the div on the webpage regardless of the scenario. Basically whenever session.type = B N H or BI. However the way it is currently happening is the second part is displaying on top of the div "the first else". I have been struggling with a way to make this execute properly and have been going in circles for some time. I am starting to suspect I may need to dig deeper to get to the root of the problem. But figured I would see if anyone knew of a way to do this here first. If anyone has some suggestions I would be greatly appreciated. How the output looks currently is if the session is equal to those args then it is on the bottom of the div. With the first else block sitting at the top of the div. I would like to reverse this some how.
<div class="itemnumber">
<a href="Session36494.html">2WxClimate Poster Session</a>
</div>
<div class="itemtitle">
Formal Poster Viewing with Coffee Break<br>
<div class="location">Location: <span>Hall C3 (The Georgia World Congress Center )</span></div>
Where it says 2wxClimate that is the else block that executes when a session.type is not equal to B N H or BI. The second block shows up when session.type is equal to those values. Presently where it is showing Coffee Break, I want this to display in opposite order.
</div>
Your problem doesn't come from the code that you are showing us.
When that TT code you are showing us is processed, you will get output from either the outer [% IF %]
or the outer [% ELSE %]
block. You won't get both.
It looks to me as though the sample output you have shown us has a block that is generated by the [% ELSE %]
branch followed a block that is generated by the [% IF %]
branch. The only way that this can happen is if all of the code in your example is processed twice. So I'm guessing that there is some kind of loop around this code. The first time round the loop, the [% ELSE %]
block is run and the second time round the loop the [% IF %]
block is run.
So fixing your problem has nothing to do with the code you are showing us. It is a problem with the code (or data) that drives your loop. If your session
variable is populated from an array, then you need to sort the array before you start the loop so that the elements you want to display first come first in the array.