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.

Query no_results Not Working

July 25, 2012 10:12pm

Subscribe [1]
  • #1 / Jul 25, 2012 10:12pm

    Geoff Towle

    330 posts

    I have this query in a template. The idea is that it will embed an empty Safecracker form if an entry for that user doesn’t already exist, but it does not work. If there are no results, nothing happens. Not sure why. It does display an entry if one exists.

    {exp:query sql="SELECT entry_id FROM exp_channel_titles WHERE channel_id = '18' AND author_id = '{member_id}'"}
     {embed="dashboard/.profile" entry="{entry_id}"}
     {if no_results}
      No results.
     {/if}
    {/exp:query}
  • #2 / Jul 27, 2012 10:32am

    Kevin Smith

    4784 posts

    Hi Geoff,

    Have you turned on the Output Profiler yet? That’ll let you see the actual query that’s being run, and I suspect you’ll see what the problem is.

    Without looking at your actual site and template, my guess is that because the {member_id} is parsed very late in the parsing order, it’s not available yet when the Query module needs it. Therefore the query isn’t actually what you expect it to be.

    I’m not 100% sure about this, but have you tried using the {logged_in_member_id} variable instead? I think that one parses sooner than {member_id}, so that might work.

  • #3 / Jul 27, 2012 11:13am

    Geoff Towle

    330 posts

    Kevin,

    We’re thinking it’s possibly a User module issue. I’ll report back as I learn more. Thanks.

    Geoff

  • #4 / Jul 27, 2012 6:54pm

    Kevin Smith

    4784 posts

    Sure thing, let me know when you find something!

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

ExpressionEngine News!

#eecms, #events, #releases