• Hey, it looks like the search is not working in tabs. Is there a way around this? If you take a look at my example link, I have a lot of code snippets ordered into different tabs. It would be great if the plugin could find them.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 31 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi can find content inside tabs, but that depends a bit on how the data is organized. If the data is in post content and divided into tabs with shortcodes, Relevanssi can find the content, no problems. In some cases the tab content is stored in custom fields, in which case all it takes is to make Relevanssi index the right custom fields.

    On your site, the search does seem to find posts by tabbed content. For example, you can search for “noteDao” and find the post you linked to.

    Now Relevanssi can’t open up the correct tab when the visitor enters the page – that’s beyond the scope of what Relevanssi is supposed to do, and Relevanssi simply doesn’t know anything about any tabs. You can use the highlighting to pass the search term as a parameter and then write some javascript that figures out which tabs contain the search term and then open one of them, but Relevanssi won’t do that for you.

    Thread Starter flizzywp

    (@flizzywp)

    Thanks for the quick response!
    Indeed, noteDao seems to work. I was trying it with “coordinatorlayout” and a few other keywords and there it didn’t work.
    For example here in the “activity_main.xml” tab I have a CoordinatorLayout XML tag which it can’t find:
    https://codinginflow.com/tutorials/android/dodgeinsetedges

    Any idea why that could be?

    Plugin Author Mikko Saari

    (@msaari)

    If I search for “coordinatorlayout”, Relevanssi does find that post, and everything does seem to work as expected.

    If I search for “dodgeinsetedgesexample” which appears only inside the activity_main.xml tab, Relevanssi still finds the post and even shows the tab content in the excerpt.

    So what exactly are you expecting to happen here that does not happen? As far as I can tell, Relevanssi is working exactly as expected, so obviously you’re expecting something else. What exactly?

    Thread Starter flizzywp

    (@flizzywp)

    Sorry I was not clear enough.
    Yes, it finds that page for “coordinatorlayout”, but it reads the word from the description box above the tabs, not from within the tabs.
    I have other pages that contain CoordinatorLayout only in the tabs and they are not shown.

    This page for example also uses a CoordinatorLayout in the activity_main.xml tab:
    https://codinginflow.com/tutorials/android/room-viewmodel-livedata-recyclerview-mvvm/part-10-listadapter

    • This reply was modified 6 years, 3 months ago by flizzywp.
    Plugin Author Mikko Saari

    (@msaari)

    Let me guess: you have the “Keyword matching” setting set to “Whole words” or “Partial words if no matches for whole words”? That post doesn’t have CoordinatorLayout by itself, just as a part of a phrase. If you switch that setting to “Partial words” and try again, does it then work better?

    Thread Starter flizzywp

    (@flizzywp)

    I changed it to partial words, but it still only finds this 1 result for “coordinatorlayout”. I made sure I saved the setting.

    Plugin Author Mikko Saari

    (@msaari)

    Next explanation: the word appears elsewhere in <android.support.design.widget.CoordinatorLayout or something like that. Relevanssi looks at that, thinks that it’s a HTML tag, and skips indexing it.

    You could try a simple filter that removes the < signs so that Relevanssi doesn’t remove your code as tags:

    add_filter( 'relevanssi_post_content', 'rlv_remove_brackets' );
    function rlv_remove_brackets( $content ) {
        $content = str_replace( '<', ' ', $content );
        return $content;
    }

    If you add this to theme functions.php and rebuild the index, does that improve the results?

    Thread Starter flizzywp

    (@flizzywp)

    I’ve never added anything to the theme functions.php. Is there a way without coding? Otherwise I have to figure out how to do that first.

    Plugin Author Mikko Saari

    (@msaari)

    No, there’s no other way unfortunately. But all it takes is adding this one function to the theme functions.php –?preferably in your child theme, but if your main theme doesn’t get updates, the main theme functions.php is also fine.

    Thread Starter flizzywp

    (@flizzywp)

    I added the code snippet with the “Snippets” plugin, but it still doesn’t work.
    I also rebuild the index and tried setting custom fields to visible.
    Any other idea?

    Plugin Author Mikko Saari

    (@msaari)

    Where is the tab content stored? In custom fields or in post content? The function only works if the tab content is stored in the post content.

    If the tab content is in custom fields, this is the function you need:

    add_filter( 'relevanssi_custom_field_value', 'rlv_remove_brackets' );
    function rlv_remove_brackets( $content ) {
        $content = str_replace( '<', ' ', $content );
        return $content;
    }
    Thread Starter flizzywp

    (@flizzywp)

    I add the tabs with the Shortcode Ultimate plugin into my page and the code is then also wrapped into the Crayon Syntax Highlighter.

    It looks like this:

    [su_tab title="activity_main.xml" disabled="no" anchor="" url="" target="blank" class=""]
    <pre class="lang:xhtml decode:true " title="activity_main.xml"><?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="https://schemas.android.com/apk/res/android"
        xmlns:app="https://schemas.android.com/apk/res-auto"
        xmlns:tools="https://schemas.android.com/tools"
        android:layout_width="match_parent"
    [...]
    

    I don’t think I use custom fields.
    Edit: It automatically replaces “& l t ;” (without the spaces) in what I pasted above.

    • This reply was modified 6 years, 3 months ago by flizzywp.
    • This reply was modified 6 years, 3 months ago by flizzywp.
    • This reply was modified 6 years, 3 months ago by flizzywp.
    • This reply was modified 6 years, 3 months ago by flizzywp.
    • This reply was modified 6 years, 3 months ago by flizzywp.
    • This reply was modified 6 years, 3 months ago by flizzywp.
    Plugin Author Mikko Saari

    (@msaari)

    Hmm, in that case the first code should work, unless the brackets are stored as entities. You can try this:

    add_filter( 'relevanssi_post_content', 'rlv_remove_brackets' );
    function rlv_remove_brackets( $content ) {
        $content = str_replace( '<', ' ', $content );
        return $content;
    }
    Thread Starter flizzywp

    (@flizzywp)

    Nope, nothing changes. I always only get my 1 result for CoordinatorLayout.

    Plugin Author Mikko Saari

    (@msaari)

    If you add this code:

    add_filter( 'relevanssi_post_content', 'rlv_test' );
    function rlv_test( $content ) {
        var_dump( $content );
        exit();
    }

    and go save the post, what does it print out? After you’ve checked that, remove the code and save the post again.

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Not working in tabs?’ is closed to new replies.