Hiya,
Hopefully a very quick one this. I am trying to create an exceptionally simple plugin which basically performs a database query and then the result will either be one row of data or none.
What I then want to do within my plugin is :
If there is a result then carry on and spit out the tagdata using :
$this->return_data = $tagdata;
If there isn’t a result then I want to display some text or code or whatever is placed in between :
{if no_results}
<p>Text to show if no results</p>
{/if}
The problem that I have though is that this plugin is placed within a weblog entries tag so I am ending up with something like this :
{exp:weblog:entries weblog="default_site" disable="member_data|trackbacks|pagination|categories|category_fields"}
{exp:my_plugin entry_id="{entry_id}"}
{if no_results}
<p>No results here I'm afraid</p>
{/if}
<p>This will show if there are results</p>
{/exp:my_plugin}
{/exp:weblog:entries}
Basically this will be going on a single entry page so (without giving too much away about the plugin if I may) I will be passing in the entry_id from the weblog entries tag and then using that in a simple database query which will then either return a result or not return a result.
I think the problem I have though is that I can’t use the no_results function as that is used in the weblog entries tag and so it is interfering with when I want to use it.
I then tried making my own conditional variable which sort of works so when there is a result the tagdata is spat out just as though the plugin wasn’t there but when there isn’t a database query result then I not only get the conditional results but also the plugin output too.
Is there any easy way of using the no_results function inside a plugin which is placed inside of a weblog entries tag?
Thanks for any help on this one.
Best wishes,
Mark
