ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Is the no_results variable supposed to work with dynamic parameters?

April 11, 2012 12:04pm

Subscribe [1]
  • #1 / Apr 11, 2012 12:04pm

    trif3cta

    148 posts

    I’m using dynamic parameters to allow users to filter what Channel Entries get returned. I’d like to return a message to the user when nothing shows up. Currently {if no_results} comes back blank, as does {count} when nothing matches.

    Is this supposed to work in this context? How might I tell the user that nothing matches those params?

    (BTW, I’ve tried adding require_entry to no avail).

    Thanks!

  • #2 / Apr 12, 2012 11:50am

    Dan Decker

    7338 posts

    Hi trif3cta,

    That is odd, I would expect {no_results} to be triggered.

    Can you share with me your “results” template?

    There may be some other factors in play here. In the meantime, are you using dynamic=“no”?

    I look forward to your reply!

    Cheers,

  • #3 / Apr 12, 2012 12:32pm

    trif3cta

    148 posts

    Thanks for the reply Dan, much appreciated. When there are matches, results come back fine, otherwise it’s totally blank. Here’s my Channel Entries tag:

    {exp:channel:entries
     channel="awesomeness"
     dynamic="no"
     limit="5"
     dynamic_parameters="category|author_id|year"
     paginate="bottom"
     require_entry="yes"
    }
    
     {!-- markup/channel fields --}
    
      {if no_results}
       Sorry, you got nuthin…
      {/if}
    
      {!-- pagination --}
    {/exp:channel:entries}
  • #4 / Apr 13, 2012 4:11pm

    Dan Decker

    7338 posts

    Hi trif3cta,

    Looking this over, this note in the User Guide may be relevant:

    NOTE: This feature will only work if page caching is turned OFF for the template in which it is being used.

    Have you checked that caching is off for this template?

    Are you sure to submit a value for each dynamic parameter, even a default value?

    The other note is relevant as well, as it addresses pagination:

    Note: If you have pagination links on your page they will not retain the page layout options created dynamically using this feature.

    The other thing that stands out is the use of dynamic=“no” and require_entry=“yes” - Those 2 are somewhat mutually exclusive. dynamic tells ExpressionEngine to ignore the URL, require tells it to look *exclusively* to the URL - see the conundrum?

    Take them both out for a quick test and let me know what you see.

    Cheers,

  • #5 / Apr 22, 2012 1:15pm

    trif3cta

    148 posts

    Sorry for the delay, I went out of town.

    Looks like I’m in business, I was not submitting proper default values for the select options.

    Won’t work:

    <option value="Sort by Author:">Sort by Author:</option>
    <option>Sort by Author:</option>


    Works:

    <option value="">Sort by Author:</option>
    <option value="not 9999">Sort by Author:</option>

    Thanks Dan!

  • #6 / Apr 24, 2012 5:51pm

    Dan Decker

    7338 posts

    Hi trif3cta,

    Awesome to hear!

    If you need anything else, just let us know!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases