Forums

[Plugin: Relevanssi] Indexing wp-table-reloaded with relevanssi (18 posts)

  1. whiteorb
    Member
    Posted 1 year ago #

    I use the popular plugin wp-table-reloaded to give my internal users the ability to create pre-formatted tables. It's excellent and well thought out. Has anyone tried to find a way to index the data after it's been added to the page?

    I have an example at the bottom of this page.

    Thanks a ton!

  2. msaari
    Member
    Posted 1 year ago #

    WP Table Reloaded is one of the best plugins ever. There's a problem with it and Relevanssi, though... I was doing some advanced hacking with WP Table recently and I found out the shortcodes WP Table uses aren't even registered on the admin side of WordPress.

    So, when Relevanssi does the indexing and tries to expand the table shortcodes, nothing happens. I had to take some extra turns and twists to make it work, and I'm not sure if that's something that can work in Relevanssi. I'll have to see if it's possible to make the two plugins work together, it would be neat.

  3. whiteorb
    Member
    Posted 1 year ago #

    I'll happily hack anything and wait for the official fix. Would you mind walking me through the steps?

  4. whiteorb
    Member
    Posted 1 year ago #

    I also posted the question to his thread

  5. msaari
    Member
    Posted 1 year ago #

    The trick is to include the WP Table code:

    include_once(WP_TABLE_RELOADED_ABSPATH . 'controllers/controller-frontend.php');
    $My_WP_Table_Reloaded = new WP_Table_Reloaded_Controller_Frontend();

    Do this before indexing... you could try adding this to relevanssi_build_index() function.

  6. TobiasBg
    Member
    Posted 1 year ago #

    Hi,

    this is indeed a tricky thing. msaari is right, WP-Table Reloaded does not register its Shortcodes on the admin side (as there's usually no need for them there).

    If something requires them however, one can change this behavior, by either using msaari's suggestion, or by adding a small change to the main file of WP-Table Reloaded, namely wp-table-reloaded.php. It should be enough to remove the else { (after the } which needs to stay) in line 58 and the closing bracket for this else in line 120.

    Best wishes,
    Tobias

  7. whiteorb
    Member
    Posted 1 year ago #

    This is great, thank you both very much. I was trying to determine how to add $MY_WP_Table_Reloaded to the relevanssi_build_index function and I seem to have a knack for breaking it. I think I'm simply confused by why where it needs to go.

    I went ahead and removed the else and it's corresponding brackets, rebuilt the index, and verified. It didn't seem to index any data from within the table(s). You can see that here.

  8. msaari
    Member
    Posted 1 year ago #

    The code needs to be included before the relevanssi_index_doc() function processes the documents, but only once should be enough. Thus relevanssi_build_index().

    Have you enabled expanding the shortcodes in Relevanssi settings?

  9. whiteorb
    Member
    Posted 1 year ago #

    I went ahead and added the code to the relevanssi_build_index function. Expand shortcodes is set on. and I've removed the else from wp-table-reloaded. It doesn't seem to be indexing any of the table data though.

    function relevanssi_build_index($extend = false) {
    	include_once(WP_TABLE_RELOADED_ABSPATH . 'controllers/controller-frontend.php');
    	$My_WP_Table_Reloaded = new WP_Table_Reloaded_Controller_Frontend();
    
    	global $wpdb, $relevanssi_table;
    	set_time_limit(0);
  10. msaari
    Member
    Posted 1 year ago #

    Well, if that doesn't work, I'm out of ideas.

  11. heather.m
    Member
    Posted 10 months ago #

    I realized that my site was having the same problem, and stumbled on this post. Did anyone ever find a way to make the two plugins work?

    I did find something of a work-around(with some results) by adding a custom field to each page where I had inserted a table. I could then copy all the text from my table and drop it in the field on each page. By including it in the Indexing Options, the search results started picking up these pages.

    What was surprising is that in the excerpt, it shows all the data straight from the table (as a long messy paragraph with no line breaks, of course), including text that I had removed when pasting it to the custom field. So, for example, in the excerpt, you see:

    ImageItem/DescriptionMSRPEducation Price Drop-In Ceiling Projector MountPerfect projector mounting for suspended ceilingsAVM-PRO-DCP-UNV202-SVSilverAVM-PRO-DCP-UNV202-BKBlack$160.00$160.00$99.00$99.00

    I don't know if this helps at all for coming up with a solution of sorts, but I thought I'd post what I found.

  12. lroberts
    Member
    Posted 5 months ago #

    I was able to make msaari's code shown above work with WP-Table_reloaded and it does search the table data.
    I added the code to the relevanssi_build_index() function and I did not need to make any changes to WP_Table_Reloaded.
    I had to Build the index before search would search the tables, however.

  13. TobiasBg
    Member
    Posted 5 months ago #

    Hi,

    thanks for sharing this! Good to hear that this works so easily!

    Best wishes,
    Tobias

  14. adeens
    Member
    Posted 3 months ago #

    This thread just saved my skin!

    I noticed however that this only searches within table content and NOT within th tags. Is there a way to search th as well?

    Thanks!

  15. TobiasBg
    Member
    Posted 3 months ago #

    Hi,

    are you sure about that?

    I'm not familiar with the way Relevanssi works, but I don't see a way that it would only search within <td> tags...

    Regards,
    Tobias

  16. adeens
    Member
    Posted 3 months ago #

  17. adeens
    Member
    Posted 3 months ago #

    Actually, if I search for one of the nonsense words inside a td in the first table - for example גכעגכע - that page still doesn't show up in the search results and I get another one instead. After doing a few more tests it looks like I can only get a one-post result in search results. Is there anything I can add to msaari's code to fix the weirdness?

  18. TobiasBg
    Member
    Posted 3 months ago #

    Hi,

    thanks for your further investigations. Unfortunately, I won't be able to help with this, as I have no experience with Relevanssi. Thus, I don't know what is necessary to make this work better, sorry.

    Regards,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Topic