Skip Navigation

[Resolved] Using Types to create Events

This support ticket is created 6 years, 4 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#949374

We are using Types to create a CPT for Events. Within the Events CPT, we have setup a Repeatable Group to allow locations/dates to be added to an Event as some Events will have multiple dates and/or locations.

My question is how we can set this up on the front end to sort the events by date entered within the Repeatable Group. This means we may have something like this:

Event A
August 1, 2018
Philadelphia, PA

Event A (same event as above, just different date/location)
August 2, 2018
Harrisburg, PA

Event B (different event)
August 5, 2018
Philadelphia, PA

Event A (same event as the first two)
August 6, 2018
Philadelphia, PA

Any suggestions?

#950169

Hello,

I assume we are talking about a post view, querying "Events" posts, and you are going to order the result by date field of "Repeatable Group".

The Repeatable Group of Toolset is based on posts, so each item of Repeatable Group is a single post, since the view is querying "Events" posts, but there isn't date field in "Events" post, it will conduct unexpected result:
No item found

More help:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
'meta_value' - Note that a 'meta_key=keyname' must also be present in the query.

In your case, you try these:
1) Create a post view, query posts of the "Repeatable Group"
2) Order by custom date field,
3) Display the related "Events" post information
See our document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

#950362

Luo,

Thanks so much for the response. I've put together the Post View and it is loading the repeatable group info for location, date and time but I can't figure out how to get it to load the Title and Permalink from the parent event.

See hidden link for a better illustration of what is displaying.

The code in the template I've setup looks like this:

<div class="events-result-item" data-item-type="[types field='event_category'][/types]" data-capabilities='[]' data-people='[]'>
<div class="details">
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-calendar.svg" alt="calendar">
<span class="date">[types field='event_date' style='text' format='M j, Y'][/types]</span>
</div>
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-clock.svg" alt="clock">
<span>[types field='event_time'][/types]</span>
</div>
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-location.svg" alt="location">
<span>
<span>[types field='event_location'][/types]</span>
</span>
</div>
</div>
[wpv-post-title]
</div>

#951084

In the view loop, you can display the parent "Events" post information by adding attribute to item="@RFG-SLUG.parent"
for example, your repeatable field slug is "event-group", then you can display the "Events" post link as below:
[wpv-post-link item="@event-group.parent"]
Post title:
[wpv-post-title item="@event-group.parent"]

#951460

Luo,

Perfect... that did the trick.

The remaining question I have might be a bit trickier though.

As you saw in the code, we have three data- tags (data-item-type, data-capabilities, data-people) on the parent div which we use for filtering/sorting on the page. I can load the event category into the data-item-type fine but the data-capabilities and data-people tags will take more action.

On the events CPT we have two ACF relationship fields which load dynamically in the list of practice areas and attorneys so we can toggle on the capabilities and people associated to the event. These are categories that we allow the page to filter on so I need to get the values from the ACF fields loaded.

Normally we'd do this via PHP:

$posts = get_field('practice_areas');
if( $posts ):
foreach( $posts as $post):
setup_postdata($post);
$pa_title = get_the_title();
echo "$pa_title ";
endforeach;
wp_reset_postdata();
endif;

How can I do this via the View Template section since we need to use that to tie into the repeatable groups for types?

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

https://toolset.com/forums/topic/split-using-types-to-create-events/

#952028

I assume the original question of this thread has been resolved already.

For the new question, I have created a new thread for it, that will help other users to find the answers. you will get the answer here:
https://toolset.com/forums/topic/split-using-types-to-create-events/