Hiya,
Hopefully this is an easy one for someone to answer.
I am currently making a plugin and I would like to utilise :
{if no_results}
Sorry no results here!!
{/if}
I tried this in a plugin :
function Test_plugin(){
global $TMPL;
return $TMPL->no_results();
}
with obviously the rest of the needed plugin code around it such as class etc but all I get is an empty page spat out. Nothing in the source code apart from the rest of the HTML markup that I have placed in there.
I just need to be able to create a no_results conditional so that if my plugin has no results then I can place a message on the screen. I had seen this done in other plugins / extensions and can’t really see where I am going wrong. I thought it was just as simple as placing :
return $TMPL->no_results();
into my plugin and then the text between my conditional tag in the template would show but it seems like there must be more to it than that as nothing is being spat out to the page at all.
Any help with understanding this would be greatly appreciated.
Thanks in advance for any help on this one.
Best wishes,
Mark
Hmm slight update.
Out of sheer frustration I was just coding all things that I know about plugins etc (which at this moment in time I don’t think is much! 😉 ) and tried this :
$this->return_data = $TMPL->no_results();
This works fine and in my template I can now use :
{if no_results}
There's nothing to see here!!
{/if}
Just wondering if this is okay to do or not? It seems to work fine but I had noticed in other peoples extensions and plugins that all they had ever done is :
return $TMPL->no_results();
This is even in the mod.weblog.php file and I am just wondering why it wouldn’t work in that way for me and I had to place more code in front to get it to work.
Any information as to whether I have done this right or wrong or how I should be doing it or why it does / doesn’t work would be great thanks as I am really trying to get my head around understanding all of this.
Thanks.
Best wishes,
Mark
Hey Mark,
From the docs:
There are two ways to return a value depending on whether your tag has three segments or two.
Two Segments ex: {my:plugin} must use:
this->return_data = 'foo'
but three segments ex: {my:plugin:method} can return the value directly
return 'foo';
For more information visit: http://expressionengine.com/docs/development/plugins.html and search for: “Returning A Value”
Cheers Leevi
No worries mark… I know how after staring at a screen for so long things can just cbecome a blur 😊
So you at least get a blur eh?
My screen (or is it my brain) just goes completely blank sometimes!! 😉 😊 😉
Thanks again for the pointers, much appreciated. Hope things are going well for you.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.