This members-only tutorial provides the steps to register a custom condition to be applied on elements inside an Oxygen Template that applies to search results.

The condition lets us conditionally output elements depending on whether there is at least one search result or not.

Use Case

This condition can be used in conjunction with the How to create a Search Results page in Oxygen tutorial so that a message can be shown when there are 0 search results.

When there's at least 1 search result:

When there's no search results:

To set this up, you would move everything inside the Template for search results from the other tutorial inside a Div and set this condition on that Div:

After that you would create another Div alongside (at the same level as) the earlier Div and add Heading/Text/Search Form telling the user that there are no results for the term they searched for. Then you'd apply the condition on this Div like so:

Step 1

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: [Condition] At Least 1 Search Result

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($27/month).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: