We’re working on a module which provides pagination and sorting options to a channel:entries loop.
It wraps the exp:channel:entries tag, grabs the tag data using $this->EE->TMPL->tagdata and makes updates to the exp:channel:entries params according to user selection. It then returns the updated tag data to the template for EE to parse in its usual
It’s all working well except for one thing, the no_results tag is not returned by $this->EE->TMPL->tagdata.
For example, my code look like this:
{exp:ep_paginate:build parse="inward" show_sort_by="yes"}
{exp:channel:entries channel="case_study" orderby="date" sort="desc" dynamic="no" limit="10" disable="member_data|pagination|category_fields" offset="0"}
{if no_results}
Sorry, there are no case studies associated with this category
{/if}
{if count == "1"}
<ul class="listing">
{/if}
<li class="group">
{if editorial_feature_image}
{exp:imgsizer:size src="{editorial_feature_image}" width="100" height="80"}
{sized}
{/exp:imgsizer:size}
{/if}
<a href="http://{page_url}<?php">{title}</a>
{exp:char_limit total="120"}{editorial_copy}{/exp:char_limit}
</li>
{if count == total_results}
</ul>
{/if}
{/exp:channel:entries}
{/exp:ep_paginate:build} [/code]
Pretty much the first line of the build method grabs the tagdata using this code:
[code]$tagdata = $this->EE->TMPL->tagdata;If I then swap curly brackets for square so EE won’t parse anything and return what I get, this is the output:
[exp:channel:entries channel="toolkit" orderby="date" category="" sort="desc" dynamic="no" limit="10" disable="member_data|pagination"]
[if count == "1"]
<ul class="listing">
[/if]
<li class="group">
[if pub_res_image]
[exp:imgsizer:size src="[pub_res_image]" width="100" height="80"]
[sized]
[/exp:imgsizer:size]
[/if]
<a href="http://page_url">"][title]</a>
[exp:char_limit total="120"][pub_res_description][/exp:char_limit]
</li>
[if count == total_results]
</ul>
[/if]
[/exp:channel:entries]My no_results tag is not there.
Am I doing something wrong or is this designed behaviour. Without my no_results tag my lists won’t format correctly when there are no results. I can resolve this another way but would rather use EE proprietary behaviour.
Any direction would be a great help.
Many thanks,
Malcolm
Hi Malcolm,
Sorry for the delay - sure you’ve worked through this by now, but I’ve just hit this myself on a plugin.
Basically the no_results is being thrown or not by the channel:entries loop and, as that is returning something the no_results isn’t being tripped.
If you embedded things so that your plugin was in a separate template to the channel:entries I suspect you’d get a different result.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.