For this purpose I came up with this:
- Code: Select all
<ul class="slides">
[[ assign var=count value=0 ]]
[[ subweblog name="standard"]][[ literal ]]
[[ if ($count<4) ]]
[[ if $entry.extrafields.a ]]
[[ include file="`$templatedir`/_sub_gallery_entry.tpl" ]]
[[ assign var=count value=$count+1 ]]
[[ /if ]]
[[ /if ]]
[[ /literal ]][[ /subweblog ]]
[[ subweblog name="standard"]][[ literal ]]
[[ if ($count<4) ]]
[[ if ($entry.extrafields.b and !$entry.extrafields.a) ]]
[[ include file="`$templatedir`/_sub_gallery_entry.tpl" ]]
[[ assign var=count value=$count+1 ]]
[[ /if ]]
[[ /if ]]
[[ /literal ]][[ /subweblog ]]
[[ subweblog name="standard"]][[ literal ]]
[[ if ($count<4) ]]
[[ if (!$entry.extrafields.a and !$entry.extrafields.b) ]]
[[ include file="`$templatedir`/_sub_gallery_entry.tpl" ]]
[[ assign var=count value=$count+1 ]]
[[ /if ]]
[[ /if ]]
[[ /literal ]][[ /subweblog ]]
</ul>
Here i have simply defined two extrafields a and b, which may be set or not. I want a total of 4 entries in the slider. I would prefer entries, where a is set. If there are not enough of these, I will take some with b and if I still have too few, I will take some where neither a nor b is set. BUT under all circumstances I want a maximum of 4 entries. Therefore I define a variable $count. Each time, when I find a suitable entry this counter is increased.
This is only an example of course. It could also be that I would prefer entries with extra.imagefield filled or anything else.
But my problem is that each time I start a new run through the weblog, the counter is reset to 0. So what I get is up to 4 entries of type a followed by up to 4 entries of type b etc. This looks like something with the scope of this variable. As if its scope is only within the subweblog-tag. I tried to play with the scope-parameter of assign (global, root or parent), but that does not change anything. What am i doing wrong?