• Hi Mikko

    This is likely beyond Relevanssi support, but consider it a challenge.

    Take a site using toggles or accordions, like this:
    https://www.elegantthemes.com/preview/Divi/accordion/
    Now open the “Can I use your themes with WP.com?” accordion. It contains the word “HostGator”

    Now imagine I use the site search feature to search for “HostGator”. The result is:
    https://www.elegantthemes.com/preview/Divi/?s=HostGator

    The Accordion page is listed. BUT… If clicking the link, there is not clue that I must open the “Can I use your themes with WP.com?” accordion item to see the text containing the search phrase?

    Is that problem possible to solve with Relevanssi Pro?

    • This topic was modified 7 years, 6 months ago by Bjarne Oldrup.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi doesn’t know anything about the accordions. The way I see it, Relevanssi’s responsibilities end just before the search results page, and whatever comes after that falls under the responsibility of the theme.

    Now can this be done? Perhaps. You’d probably need two things:

    1. PHP code that reads in the search terms from HTTP_REFERER and places them in variables on the page for easy javascript access. See relevanssi_highlight_in_docs() in /lib/excerpts-highlights.php for an example on how to do that.
    2. Javascript that goes through the page content and finds all the search term matches, figures out if they’re inside an accordion element and if they are, opens the accordion.

    I can help you with the first bit, but you can probably sort that out from the relevanssi_highlight_in_docs() example. I have little skill – and to be honest, little interest – in figuring out the second part.

    Thread Starter Bjarne Oldrup

    (@oldrup)

    Thank you Mikko for pointing me in the right direction. This “issue” is clearly not directly limited to Relevanssi or Divi, but as far as I can see, a problem with any implementation of accordions, toggles and tabs where user interaction is required to see the content. Something to be aware of when structuring the content really.

    I recon it to some degree can be improved by a skilled programmer, toggles can be opened by javascript, but when it comes to tabs? – I can’t imagine how that should be solved elegantly – only one tab can be active.

    Thanks again for providing this great plugin to the community. I’ve been implementing a few tricks to improve the search when using the Divi theme quite a lot. The solution includes Relevanssi, and I hope to find time to write a blog post about it when I’m done..

    A great day to you Mikko.

    /Bjarne

    • This reply was modified 7 years, 6 months ago by Bjarne Oldrup.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Searching, finding and opening Toggles and Accordions?’ is closed to new replies.