Search results page layout - missing assignment conditions

Hi all,

I’m currently trying to setup a new search results page using the Layout Builder for the search results from the Modern Events Calendar plugin, but i’m struggling to assign it the correct conditions to show at the moment. I’ve found from another post - Layout builder - Search results advice that the conditions of “Search Results: Is being viewed” may be required, however when I go to the conditions on my Layout Builder, it’s missing the “Search Results” condition, and even the “Blog” condition?

Any ideas why these aren’t showing please?

Thanks,
Kind regards,

Hi @Keanu,

Thanks for reaching out.
It seems that you are using the Layout type Single, the Blog and the Search Result condition is only available in the Archive type layouts.

Screenshot-1130-

Hope it helps.
Thanks

1 Like

Evening @tristup,

I just knew I was being dumb here haha! Thank you for the help. Please consider this solved.

Thanks again,
Kind regards,

Just one (hopefully) final question.

Is there a way to hook onto the search results from the Modern Events Calendar? I’ve got the search results showing from a normal search, but for some reason can’t get the mec-events ones to show.

Thanks,
Kind regards,

Hey @Keanu,

By default, the MEC events will not display in the search results. Perhaps this thread might interest you:

Cheers.

1 Like

Morning @ruenel,

Thank you for that, it really did help. I’ve managed to get it working using “String” as the looper provider, with a delimiter of “Newline” (Else it repeats it constantly.)

One thing I haven’t been able to figure out is how to remove the results and replace it with “Nothing found” if nothing is found - else it will show the results box that I setup.

Would there be a way to do this using the conditions? e.g. only display this row if a result is found, else hide it?

Apologies for all the questions - quite new to the looper provider / consumer / conditions side of things!

Thanks again,
Kind regards,

//edit

Thought I managed to crack it using “Provider output” “is empty”, but it hides the box for everything sadly. Really thought that would work.

Hey @Keanu,

Provider output is empty is correct but there’s currently a bug that causes it not to work. The bug will be fixed in the next release of Pro.

Please try adding the following code in the PARENT THEME’S functions.php file. The reason why you need to add this in the parent theme is that it will be overwritten during the update.

add_filter('cs_condition_rule_archive_post_type_with_term', function( $show, $args ) {
  list($post_type, $taxonomy, $term) = $args;

  $queried_object = get_queried_object();

  if ( !is_a( $queried_object, 'WP_Term' )) {
    return false;
  }

  if ( $taxonomy === 'category' ) {
    return $term ? is_category( $term ) : is_category();
  }

  if ( $taxonomy === 'post_tag' ) {
    return $term ? is_tag( $term ) : is_tag();
  }

  return is_tax( $taxonomy, $term );
},10,2);

1 Like

Afternoon @christian,

Thank you for sending that through. Glad to see that I was on the right path at least!

I’ve added it to the Pro themes functions.php at the end, but it doesn’t appear to have fixed the issue sadly. I have attached the relevant info into the secure note in case you wanted to take a look!

Just a quick overview of the setup - I’ve got the looper provider on the row, i’ve a consumer on a column beneath that row that has the condition “provider output is not empty” , and i’ve got another column with a condition of “provider output is empty” and some text in it. Is that correct?

Thanks,
Kind regards,

Hey @Keanu,

It looks like there’s also a bug with the Provider Output Condition so we’ll use the Number Condition instead.

image

The Condition of the Column that holds the result must be

{{dc:query:found_posts}} > 0

The “No Results” Column must be

{{dc:query:found_posts}} == 0

I tested it on your site and it works.

Hope that helps.

1 Like

Hi @christian,

Absolutely amazing, thanks for applying it too. Please consider this issue resolved.

Thank you all again!
Kind regards,

Hi @Keanu,

You’re welcome! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.