Categories
Back to this add-on's main page
View Other Add-ons From Bjorn Borresen
switch-statement in embedded channel:entries-tag
Bug Report
|
Wouter Vervloet
|
| Posted: 22 February 2011 11:09 AM |
|
|
|
|
Hi Bjørn,
I think I’ve found a bug, but I’m not sure… take this snippet of code.
{exp:categories channel='news' show_children='no'} <div class="container"> {exp:channel:entries channel='news' category="{category_id}" dynamic='off' limit='3'} <article class="{switch='one|two|three'}"><h5>{title}</h5></article> {/exp:channel:entries} </div> {/exp:categories}
You would assume it would render something like this:
<div class="container"> <article class="one"><h5>Lorem ipsum dolor</h5></article> <article class="two"><h5>Lorem ipsum dolor</h5></article> <article class="three"><h5>Lorem ipsum dolor</h5></article> </div> <div class="container"> <article class="one"><h5>Lorem ipsum dolor</h5></article> <article class="two"><h5>Lorem ipsum dolor</h5></article> <article class="three"><h5>Lorem ipsum dolor</h5></article> </div> and so on...
Instead, it now returns this:
<div class="container"> <article class="one"><h5>Lorem ipsum dolor</h5></article> <article class="one"><h5>Lorem ipsum dolor</h5></article> <article class="one"><h5>Lorem ipsum dolor</h5></article> </div> <div class="container"> <article class="two"><h5>Lorem ipsum dolor</h5></article> <article class="two"><h5>Lorem ipsum dolor</h5></article> <article class="two"><h5>Lorem ipsum dolor</h5></article> </div> and so on...
Any ideas?
Greetz,
Wouter
|
|
|
|
|
bjornbjorn
|
| Posted: 02 June 2011 10:19 AM |
# 1
|
|
|
Developer
|
Hi Wouter,
sorry - but I saw this now just by accident - the official support for my addons are handled over at GetSatisfaction ... I’ll make sure to add a link in the description of this addon as well :)
Anyway, to answer your question the {switch} statement should work fine .. but I think what is happening here is that the {switch} is wrapped inside an entries tag and thus it will switch relative to that entries tag (and always get “one”) .. if you put the switch outside the entries tag it would work ..
This would probably work although you’d get an article div there even if there were no articles (then you could use the show_empty=“no” parameter I guess to make sure that didn’t happen).
{exp:categories channel='news' show_children='no'} <div class="container"> <article class="{switch='one|two|three'}"> {exp:channel:entries channel='news' category="{category_id}" dynamic='off' limit='3'} <h5>{title}</h5> {/exp:channel:entries} </article> </div> {/exp:categories}
|
|
|
|
|
Wouter Vervloet
|
| Posted: 02 June 2011 10:26 AM |
# 2
|
|
|
|
Hi Bjorn,
If only it did render the switch statement relative to the entries tag.
What I believe is happen is that the categories tag parses all the switch statements first and only after that it starts to parse all the tags (including the entries tag).
Regards,
Wouter
|
|
|
|
|
bjornbjorn
|
| Posted: 02 June 2011 10:38 AM |
# 3
|
|
|
Developer
|
Hmm, you are probably right .. I haven’t tested it with an nested {exp:entries} tag but I know this works:
<ul> {exp:categories category_group_id="3" style="nested"} <li>{category_name} - {switch="one|two|three"}</li> {/exp:categories} </ul>
so .. looks like a bug in EE :-/
|
|
|
|