Skip Navigation

[Resolved] Displaying Repeatable Group

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 27 replies, has 3 voices.

Last updated by ceciliaW9184 4 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1595663
Clinical Hero Multiple locations.png

That looks great. Thank you!!

Just one more thing. In the Trial called "Pediatrics – Sacramento, Phoenix, Charlotte", the result shows up 3 times. Same for all of the trials with multiple locations.

Option 1:
Is there a way to only have it show up once?

Option 2:
Can I have the RFG custom field='city-state-additional-locations' show up in the loop? I tried to add it but it didn't show up.

#1597583

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The reason why you are seeing the item "Pediatrics – Sacramento, Phoenix, Charlotte" three times because your view is set to query the repeating field group.
=> hidden link

If you check your post "Pediatrics – Sacramento, Phoenix, Charlotte", it has three repeating field group items. That is why you see the "Pediatrics – Sacramento, Phoenix, Charlotte" three times.
hidden link

So, If I understand correctly, you want to do search in repeating field groups address field and want to display related parents?

#1597599

Yes, Pediatrics has 3 entries in the RFG (locations). But in the results, I only want it to show up once. There may be times where I have 150 locations, i don't want the post Pediatrics to show up 150 times. Is it possible to query the RFG but then just show the parent post once?

#1599101

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've added the following code to "Custom Code" Section offered by Toolset:
=> hidden link

add_filter( 'wpv_filter_query_post_process', 'func_gorup_childs_by_parent', 10, 3 );
 function func_gorup_childs_by_parent( $query, $view_settings, $view_id ) {
  
  if ( $view_id == 18676 ) { 
    
    $parent_ids = array();
    if ( !empty( $query->posts ) ) {
         
               $all_posts = $query->posts;
      		foreach($all_posts as $k=>$v):
               
           $get_parent =  toolset_get_related_post($v->ID,'additional-locations');
      
             if(!in_array($get_parent,$parent_ids)){
                	$parent_ids[$get_parent] = $get_parent;
             }else{ 
               unset($all_posts[$k]);
             }
              endforeach;
              $query->posts = array_values($all_posts); 
      	     $query->found_posts = count($all_posts); 
              $query->post_count =  count($all_posts); 
              
    }        
  }
    return $query;
}

More info:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process

#1599189

Thank you for the snippet of code. I see that each trial only appears once now. However, now it is not using all of the RFG locations in the search. It is only pulling up one of the locations per trial.

eg. Pediatrics has 3 locations in the RFG: Sacramento, Phoenix, Charlotte. Only Charlotte is showing up.

Can you have all locations in RFG included in the search?

Thank you again.

#1599203

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The way you want is not feasible.

As the view is set to query RFG and you said you want to group by parent post, so when you group by parent post it will only display one entry.

If you want to display the RFG entries then all RFG entry will be displayed with duplicate parent as all RFG item for single post holds the same parent.

Like this post: hidden link
- It has 3 RFG items.
So, the possibility will be either you can list all 3 RFG items with associated parent (which will be the same for all 3 RFG item).

#1599239

OK. it is more important that it searches all locations in the RFG. I accept that the trial will display repeatedly for each location in the RFG.

Then can i have the City-state field of the RFG show up in the Loop Item.

See LOOP ITEM Section (hidden link):

REPLACE:
[types field="clinical-trial-site-city" separator=" | "][/types] [types field="clinical-trial-site-state"][/types]

WITH THIS:
[types field='city-state-additional-locations'][/types]

I tried but it didn't work. Is there another way to do it?

#1599275

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please chekc: hidden link

I've disabled the code I've added to group post by the parent.

To this view:
=> hidden link

To display the RFT fields, I've added the filed as given under to the content template at the bottom of the content template, you can adjust its position as required.

RFG field: [types field='city-state-additional-locations'][/types]
RFG field: [types field='address-additional-locations'][/types]
#1599285

This is great. Thank you very much!!

#1599289

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that it works and the solution I shared help you to resolve your issue.
'
Please feel free to mark resolve the ticket 🙂

#1601585
CH - Delete RFG data.png
CH - Query FIlter.png

Hi Minesh;

I implemented your fix onto the live site and it worked great. But had 2 other issues come up.

1) Filter (Screenshot: Query FIlter):
I tried to implement the same search feature onto another view (Search Healthy Volunteers with RFG Locations ID: 18750) but it broke because I had a Query Filter applied to that view. How do i apply a filter to this view?

Here is the broken view.
hidden link

2) Deleting entry in RFG (Screenshot: Delete RFG Data):
Another issue i had was that when I deleted a trial, the repeatable field group location did not delete. I found a way around it by deleting each RFG in the trial before deleting the trial. Is there another way to do this? I may have some trials with 150 RFG locations.

Here is the page with the deleted trials.
hidden link

I updated your user and pw.

USER:
Guest

PASSWORD:
c1)M7(%2HtTLtA#i#FWh@$HW

thanks.

New threads created by Minesh and linked to this one are listed below:

https://toolset.com/forums/topic/split-displaying-repeatable-group-live-site-another-issues/

#1602183

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've spit the tickets with your additional questions. As per our support policy we entertain only one question per ticket.

I will follow up with your new question with the following split ticket.
=> https://toolset.com/forums/topic/split-displaying-repeatable-group-live-site-another-issues/

Please feel free to close this ticket.

#1602611

My issue is resolved now. Thank you!