How do you use $TMPL->no_results()?
Posted: 18 July 2008 04:26 AM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006

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}
<p>Sorry no results here!!</p>
{/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

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 18 July 2008 05:06 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006

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! wink ) and tried this :

$this->return_data = $TMPL->no_results();

This works fine and in my template I can now use :

{if no_results}
<p>There's nothing to see here!!</p>
{/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

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 18 July 2008 08:59 PM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

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

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 20 July 2008 12:23 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006

Hi Leevi,

Thanks for that. Must have blinked when reading the documents as I never saw that. Thanks for the pointers and the documentation link. Will try to remember that for the future now wink

Thanks again.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 21 July 2008 07:50 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1076
Joined  01-24-2006

No worries mark… I know how after staring at a screen for so long things can just cbecome a blur smile

 Signature 

VOTE FOR LG Addons in the Mashable Open Web Awards!


Newism - Newcastle Web Design & Development


LG Better Meta now w/ Sitemap Meta & XML Generator | LG Polls | LG .htaccess Generator

Profile
 
 
Posted: 21 July 2008 10:27 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006
Leevi Graham - 21 July 2008 07:50 AM

No worries mark… I know how after staring at a screen for so long things can just cbecome a blur smile

So you at least get a blur eh?

My screen (or is it my brain) just goes completely blank sometimes!! wink grin wink

Thanks again for the pointers, much appreciated. Hope things are going well for you.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64933 Total Logged-in Users: 54
Total Topics: 81900 Total Anonymous Users: 32
Total Replies: 440261 Total Guests: 264
Total Posts: 522161    
Members ( View Memberlist )
Newest Members:  Kathryn DaviesPetrovichusharurblaisdellLevagstudioigotthelemonmileswkakiharaAurels