3

Using Playa setup in a standard way… (ex. I have a channel of Videos and a channel of Papers. In the Video entry, the admin has a playa where they drag over any related Papers.)

The issue I've noticed is that if there is a change to a Paper's Title, the related Video's searchable data doesn't pick up that change (ex. have an existing relationship between Video/Paper, change the paper title, the new title will be right when output in the template, but native search does not reflect the new title where it's related — so a search for the new title doesn't help you find the video.)

This makes sense as my understanding is that: * You create a relationship in an entry * When you save that entry Playa copies the Title of the related item into exp_channel_data for search purposes

The problem is I need to make sure that exp_channel_data gets updated when that related title of the related item changes to keep native search working correctly.

Has anyone else run into this/found a workaround? The only thing I've found is to re-save all the entries after a Title change, but that's really not a sustainable fix :/

Tks in advance.

1

I've run up a test and can confirm this bug.

Additionally I can see that if you edit/submit (no change) the parent (playa holding) entry the child title is updated.

So in order to fix I beleive the easiest approch would be to develop an extension, look for entry_saved events on entries with ID's that are in the exp_playa_relationships.child_entry_id column, and if so 'touch' the parent too.

And of course, report it to P&T as a bug...

Related Posts : How can I bulk update the Matrix search index without re-saving each entry? (same effect, different module!)

Found a nice little bit o info to help you out, you'll have to create your extension, hook the entry_submission_end event in your extension, then you'll need a function like this :

function _ChekcUpdateParentChannelData($entryId, $meta){
    $res = ee()->db->select('parent_entry_id')
                   ->where('child_entry_id', $entryId)
                   ->get('playa_relationships');
    if ( $res->num_rows() > 0 ) {
        //aha, this is a child entry, get all the children of the parent!
        //you'll need to fetch ALL the child entry_id's, url_titles and 
        //Titles, assuming we have these in an array now called $children

        //from ft.playa.php line 2714, this is the code that sets the channel_data table
        $keywords = "";
        foreach ($children as $entry)
        {
            $keywords .= ($keywords ? "\n" : '') . "[{$entry['entry_id']}] [{$entry['url_title']}] ".str_replace('\'', '', $entry['title']);
        }

        //we now have a data to stick back into the channel_data
        //so here write an update query, where entry_id = parent 
        //entry_id set the field_XX to $keywords 

    }
}

Lots to fill in there, but you should get there. Let us know if you contact P&T and if they are going to patch or not. If they don't I might be inclined to write a 3rd party utility for this, and also for grid n matrix too if they still exhibit the same behaviour!

3
  • Thanks for running a test to confirm. I have a bug report into P&T and will let you know what I hear (if they don't post here directly). – philzelnar Jun 10 '15 at 14:28
  • Thanks for the update, out of curiosity, did you ever try rolling your own baed onthe snippet above? If not did you get a solution / workaround?? P&T do visit this board regularly (Brandon usually!) so they may spot this here too. – Blatant Jun 10 '15 at 14:45
  • Just heard from P&T this morning, and haven't done anything on my side yet. They said that the quickest solution would be to write an extension (read as: it doesn't sound like they intend to tackle this on their side). Do you think you'll be writing a utility for this? If so maybe I can be your first user :) – philzelnar Jun 11 '15 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.