We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Usage of no_results in a nesting situation

Development and Programming

Mirage's avatar
Mirage
273 posts
16 years ago
Mirage's avatar Mirage

Hi -

I’m writing my first plugin and I’m having trouble with no_results functionality. The problem only occurs when my tag is nested in another tag. Most notably weblog:entries:

The following outputs ‘Nothing found.’

<div>{exp:retail_locator:results}{if no_results}Nothing found.{/if}{/exp:retail_locator:results}</div>

This is expected since the plugin function results currenly just call $TMPL->no_results(); … I’m just testing.

The following doesn’t output anything

{exp:weblog:entries weblog="pages" limit="1"}
<div>{exp:retail_locator:results}{if no_results}Nothing found.{/if}{/exp:retail_locator:results}</div>
{/exp:weblog:entries}

I assume the output is blank because EE interpreted the no_results condition for the weblog:entries tag scope and since the entry was found no_results doesn’t apply and so it’s not output.

I’ve proven this theory by doing this: The following outputs ‘Nothing found.’

{exp:weblog:entries weblog="pages" limit="1"}
{if no_results}No such blog entry.{/if}
<div>{exp:retail_locator:results}{if no_results}Nothing found.{/if}{/exp:retail_locator:results}</div>
{/exp:weblog:entries}

This makes my tag work nested inside weblog:entries.

So the 500 million dollar question is: is there anything that I can work around here? Or do I need to provide my own no_result functionality? What gives?

Thanks, Juergen

       
Mirage's avatar
Mirage
273 posts
16 years ago
Mirage's avatar Mirage

Ok, after some more searching I found the answer here:

http://ellislab.com/forums/viewthread/91543/

Fine, I can agree with Derek on this. But I now have to ask another related question:

Does EE provide a global memory caching / registering facility?

I know I can create my own and I can use global variables. Of course, I try to avoid this. There’s just so much to read and learn about EE right now that I’m taking the opportunity to ask experienced EE users for tried and true approaches.

The way I’d use such a (non-persistent) cache would be primarily to avoid having to recast my queries all the time when my plugin tag is called repeatedly (due to flattening the nesting) of container tags.

Thanks for any advice, Juergen

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Hey Mirage, have a look at $SESS->cache.

       
Mirage's avatar
Mirage
273 posts
16 years ago
Mirage's avatar Mirage

Awesome, thanks for the pointer Derek

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.