Support

Home Forums Event Espresso Premium Changing Columns in the Table Template

Changing Columns in the Table Template

Posted: November 7, 2018 at 5:53 pm

Viewing 8 reply threads


fishwinkmarketing

November 7, 2018 at 5:53 pm

Hello!

We are using the Event Espresso Table Template to display our events. Is it possible to change the columns of the template to display different information? We would like to change the Venue column to Teacher instead. We have the teacher’s assigned through the People add-on for each class, and the venue isn’t as important.

Thanks!
Jessica


Tony

  • Support Staff

November 8, 2018 at 4:08 am

Hi Jessica,

It is possible, but you’ll need to be comfortable with PHP to pull in the details you need.

Are you using a custom theme on your site? If not you’ll need to set up a child theme so that you can load a custom version of the table view template from that and it wont be lost when you update the theme.

Take a look here: https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

So before going further, is that something you are comfortable with?


fishwinkmarketing

November 8, 2018 at 8:49 am

Hi Tony,

Thanks for getting back to me so quickly.

I do know a little bit of PHP so hopefully I can figure this out. We also already have a child theme setup.

Would you be able to give me some instructions on loading the custom version of the table view template and how to pull the instructors into a column instead of the venue?

Thanks!


Tony

  • Support Staff

November 8, 2018 at 9:10 am

I do know a little bit of PHP so hopefully I can figure this out. We also already have a child theme setup.

Great!

Would you be able to give me some instructions on loading the custom version of the table view template

With your child theme thats easy, grab the template from the add-on and place it in the root directory of the child theme.

So /wp-content/plugins/eea-events-table-view-template/templates/

The default template is espresso-events-table-template.template.php

Copy that and place it in your child theme /wp-content/themes/{child_theme}/

You’re now loading a custom version of the template.

how to pull the instructors into a column instead of the venue?

It really depends on how you want to display it, but as an example.

Line 46-48 will be:

<?php if( $show_venues ) { ?>
    <th class="th-group"><?php _e('Venue','event_espresso'); ?></th>
<?php } ?>

To repurpose the venue column to instructor, change all of that to just:

<th class="th-group"><?php _e('Instructors','event_espresso'); ?></th>

The venue column now has an ‘Instructors’ heading.

Assuming ‘Instructors’ is a ‘People type’, go to Event Espresso -> People Admin -> Types

Find your instructor type and note the ID number, you’ll need it below.

Within the template file is a loop, anywhere in the loop add this:

$people = EE_Registry::instance()->load_model('Person')->get_people_for_event_and_type( $post->ID, {type_id_number}) );

{type_id_number} needs to be changed to the ID number, lets say its 3, in that case, it would be:

$people = EE_Registry::instance()->load_model('Person')->get_people_for_event_and_type( $post->ID, 3) );

$people will be an array, it will be an empty array (no instructors assigned to the event), or an array of EE_Person objects.

You can loop over the array and either echo out the Person details, or make another array with the details, implode it and echo that.

For example:

$peoples_names = array();
foreach($people as $person ) {
//Check we have an EE_Person object.
    if( $person instanceof EE_Person ) {
	//Add the persons name and type to the peoples_names array
	$peoples_names[] = $person->full_name();
    }
}

Then change lines 114-116, from:

<?php if( $show_venues ) { ?>
    <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
<?php } ?>

To:

<td class="instructors event-<?php echo $post->ID; ?>">
<?php if( !empty($peoples_names) ) {
    echo implode( ', ', $peoples_names);
}; ?>
</td>

Note the above is untested but should be enough for you to work on ๐Ÿ™‚


fishwinkmarketing

November 8, 2018 at 9:55 am

Hey Tony,

Thank you so much! That worked perfectly! ๐Ÿ™‚ One more question for you…

For some reason, the table view will only show 10 events and the pagination won’t work. I have tried adjusting the parameters in the shortcode ([ESPRESSO_EVENTS_TABLE_TEMPLATE category_slug=art category_filter=false table_pages=30]) but it still only shows 10 on only 1 page. Here is a link to the ==> Art page. There should be roughly 27 art classes but only 10 show up and no pagination.

Please help!


Tony

  • Support Staff

November 8, 2018 at 9:59 am

table_pages=30 is for the footable views, try limit=30

That should show all of the events on the table for your.

The footable paging is basically paging on the current event limit, the limit is the query limit. We are working on adding some better paging to the table template.


fishwinkmarketing

November 8, 2018 at 10:01 am

Ok I gotcha. I just updated to [ESPRESSO_EVENTS_TABLE_TEMPLATE category_slug=art category_filter=false limit=30] and it still just shows the 10… any other ideas?


fishwinkmarketing

November 8, 2018 at 11:32 am

Thanks again for your help with the table view. I will just post this new issue in a separate ticket. Cheers!


Tony

  • Support Staff

November 8, 2018 at 3:44 pm

You’re most welcome, I’ll close this thread out so we can troubleshoot in the other here:

https://eventespresso.com/topic/event-table-template-list-only-showing-10-events-instead-of-all-of-them/#post-281545

Viewing 8 reply threads

The support post ‘Changing Columns in the Table Template’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso