I'm trying to display one entry with the search:field_name parameter of ExpressionEngine. This works fine, but I can't get the no results tag to work. I have tried a lot of things, including the use of other things then exp:channel:entries. This is my current code:

        {exp:channel:entries
            channel="projecten"
            dynamic="no"
            search:project_trackcode="={freebie_2}"
            limit="1"
            require_entry="yes"
        }
            test
            {if no_results}
               Geen resultaten
            {/if}
        {/exp:channel:entries}

It doesn't matter if I set require entry to yes or no. The code does return entries if available, but when it doesn't find an entry, it doesn't even seem to enter the {exp:channel:entries}.

  • Why are you setting a limit on a tag you are using to display search results? If you need a search, I'm betting the {exp:search:simple_form} and {exp:search:search_results} tags will be your friend. – jrothafer Jun 22 '15 at 14:10
  • I don't see how that question is relevant to this. It doesn't matter what I use, no_results doesn't work either way. – Arvenzis Jun 22 '15 at 14:13
  • No offense, but have you ever dug into the EE core? The {exp:search} tags could likely use different class and methods for searching, and you may be running into a bug. Also, questioning your parameter set up on that tag is very relevant to trying to help you :) – jrothafer Jun 22 '15 at 14:25
  • I'm not actually searching. I'm just displaying a result based on a variable in the URL, which is why I'm using freebie. This should only be one result and that's why I limit it to 1. The limitation should however not be necessary since the trackcode that I'm using in the url is unique. – Arvenzis Jun 22 '15 at 14:28
  • However you did give me an idea which I'm going to try. I'll let you know how it works out. – Arvenzis Jun 22 '15 at 14:31

Late to the party here but my guess is because you have dynamic="no" so it will always return a result.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.