Support

Home Forums Event Espresso Premium Shortcode for EventList description display?

Shortcode for EventList description display?

Posted: April 9, 2013 at 2:34 pm

Viewing 30 reply threads


mpalmer

April 9, 2013 at 2:34 pm

Hello.

I know that in the settings I can choose to display the description of an event when I use the EVENT LIST shortcode. However I have a category called archive where I want to display all of the past events, but I don’t want the description to appear on this page diplay, I just want to show the title (which would link to the full description). I was wondering if there was a shortcode parameter that could do this (description=false) or if there is a way to go about it? Thank you!


Dean

April 10, 2013 at 6:03 am

Hi

There isnt a shortcode that does this out of the box, but it is doable. My thoughts would be to look at using the Custom Files add on, particularly the ESPRESSO_TABLE shortcode. You would need to modify the espresso_table.php template to remove aspects of the table like the register column though.


mpalmer

April 10, 2013 at 8:53 am

Thanks, Dean. I’ve been trying the ESPRESSO_TABLE shortcode. When I filter by category, it shows all of the events, not the ones set with my category “archive”. I also searched the forum and saw that the shortcode should use “category_identifier” and not “category_id” but neither of those worked for me. This is the shortcode I’m using:

[ESPRESSO_TABLE category_identifier=”archive” max_days=”360″ qty=”100″ order_by=”start_date”]

Is there a different way to filter the category? Thanks!


Josh

  • Support Staff

April 10, 2013 at 10:03 am

Hi there,

I checked this on my test site and it looks like the category_identifier needs to match the unique category identifier set in the category manager. The category name doesn’t seem to work.

As an aside, ‘qty’ isn’t a valid parameter. You can use ‘limit’ instead to limit the number of events displayed. Also please note that you’ll need to ‘show_expired=true’ parameter to show the expired events.


mpalmer

April 10, 2013 at 11:35 am

Hi Josh,

My unique category identifier is also “archive” – unless I am missing something? I’m in Manage Event Categories >Edit Category archive

and cat name is archive and so is the unique category identifier. I changed the un. cat. id to archive1 and updated the shortcode and it still didn’t work. I also did change qty to limit, thank you – and added the show_expired=true  as well. Still nothing is coming up. Here is my new shortcode:

[ESPRESSO_TABLE category_identifier=”archive1″ show_expired=”true” max_days=”360″ limit=”100″ order_by=”start_date”]

and here is the page it is on:

http://www.still-point-press.com/TRC/event-archives/

Thanks for your continued help!


Josh

  • Support Staff

April 10, 2013 at 12:16 pm

Hi there,

Can you try turning on wp-debug by editing the wp-config.php file? There may be an error that will display to help narrow down the issue.

Also, can you post the contents of the espresso_table.php file that you have set up into a pastebin? I’d like to compare it the version I’m using just to make sure we are dealing with the same code.


mpalmer

April 10, 2013 at 12:43 pm

This is what I got when I turned wp-debug on:

Warning: mysql_connect() : Access denied for user ‘x’@’localhost’ (using password: x) in /moderated/wp-includes/wp-db.php on line 1141

Contents of espresso_table.php to follow…


mpalmer

April 10, 2013 at 12:44 pm

<?php
/*
Shortcode Name: Espresso Table
Author: Seth Shoultes
Contact: seth@eventespresso.com
Website: http://www.eventespresso.com
Description: Only show events in a CATEGORY within a certain number number of days into the future and a qty. The example below only shows events in a certain category that start within 30 days from the current date.
Usage Example: [ESPRESSO_TABLE max_days="30" qty="3" category_id="gracecard" order_by="state"]
Custom CSS for the table display
Notes: This file should be stored in your "/wp-content/uploads/espresso/templates/" folder and you should have the custom_includes.php files installed in your "/wp-content/uploads/espresso/" directory.
*/
function espresso_display_table($atts){
global $wpdb;
$org_options = get_option('events_organization_settings');
$event_page_id =$org_options['event_page_id'];

global $load_espresso_scripts;
$load_espresso_scripts = true;//This tells the plugin to load the required scripts
extract(shortcode_atts(array('event_category_id'=>'NULL','category_identifier' => 'NULL','show_expired' => 'false', 'show_secondary'=>'false','show_deleted'=>'false','show_recurrence'=>'true', 'limit' => '0', 'order_by' => 'NULL', 'max_days'=>''),$atts));

if ($category_identifier != 'NULL'){
$type = 'category';
}

$show_expired = $show_expired == 'false' ? " AND e.start_date >= '".date ( 'Y-m-d' )."' " : '';
$show_secondary = $show_secondary == 'false' ? " AND e.event_status != 'S' " : '';
$show_deleted = $show_deleted == 'false' ? " AND e.event_status != 'D' " : '';
$show_recurrence = $show_recurrence == 'false' ? " AND e.recurrence_id = '0' " : '';
$limit = $limit > 0 ? " LIMIT 0," . $limit . " " : '';
$order_by = $order_by != 'NULL'? " ORDER BY ". $order_by ." ASC " : " ORDER BY date(start_date), id ASC ";

if ($type == 'category'){
$sql = "SELECT e.* FROM " . EVENTS_CATEGORY_TABLE . " c ";
$sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.cat_id = c.id ";
$sql .= " JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = r.event_id ";
$sql .= " WHERE c.category_identifier = '" . $category_identifier . "' ";
$sql .= " AND e.is_active = 'Y' ";
}else{
$sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e ";
$sql .= " WHERE e.is_active = 'Y' ";
}
if ($max_days != ""){
$sql  .= " AND ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date ( 'Y-m-d' )."' ";
}
$sql .= $show_expired;
$sql .= $show_secondary;
$sql .= $show_deleted;
$sql .= $show_recurrence;
$sql .= $order_by;
$sql .= $limit;

echo espresso_get_table($sql);

}
//Events Custom Table Listing – Shows the events on your page in matching table.
function espresso_get_table($sql){
global $wpdb, $org_options;
//echo 'This page is located in ' . get_option( 'upload_path' );
$event_page_id = $org_options['event_page_id'];
$currency_symbol = $org_options['currency_symbol'];
$events = $wpdb->get_results($sql);

$category_name = $wpdb->last_result[0]->category_name;
$category_desc = $wpdb->last_result[0]->category_desc;
$display_desc = $wpdb->last_result[0]->display_desc;
if ($display_desc == 'Y'){
echo '<p>' . stripslashes_deep($category_name) . '</p>';
echo '<p>' . stripslashes_deep($category_desc) . '</p>';
}
?>
<table class="espresso-table" width="100%">

<thead class="espresso-table-header-row">
<tr>
<th class="th-group"><?php _e('Course','event_espresso'); ?></th>
<th class="th-group"><?php _e('Location','event_espresso'); ?></th>
<th class="th-group"><?php _e('City','event_espresso'); ?></th>
<th class="th-group"><?php _e('State','event_espresso'); ?></th>
<th class="th-group"><?php _e('Date','event_espresso'); ?></th>
<th class="th-group"><?php _e('Time','event_espresso'); ?></th>
<th class="th-group"><?php _e('','event_espresso'); ?></th>
</tr>
</thead>
<tbody>

<?php

foreach ($events as $event){
$reg_limit = $event->reg_limit;

$event_desc = wpautop($event->event_desc);

$register_button = '<a id="a_register_link-'.$event->id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'&regevent_action=register&event_id='.$event->id.'&name_of_event='.stripslashes_deep($event->event_name).'">View Event Details</a>';

//Check to see how many open spots are available
$open_spots = get_number_of_attendees_reg_limit($event->id, 'available_spaces') == 'Unlimited' ? 999 : get_number_of_attendees_reg_limit($event->id, 'available_spaces');
//echo $open_spots;

if ( $open_spots < 1 ) { $live_button = 'Closed';  }

?>
<tr class="espresso-table-row">
<td class="td-group">
<?php echo $event->event_name ?>
</td>
<td class="td-group">
<?php echo $event->address ?>
</td>
<td class="td-group">
<?php echo $event->city ?>
</td>
<td class="td-group">
<?php echo $event->state ?>
</td>
<td class="td-group">
<?php echo event_date_display($event->start_date, $format = 'l, M d, Y') ?>
</td>
<td class="td-group">
<?php echo espresso_event_time($event->id, 'start_time', get_option('time_format')) ?>
</td>

<td class="td-group">
<?php echo $register_button ?>
</td>
</tr>
<?php } //close foreach ?>
</tbody>
</table>

<?php
}


Josh

  • Support Staff

April 10, 2013 at 12:58 pm

The mysql connect error is a bit strange. I did test out the code you posted and it does work on my site.

Do you get the mysql connect error if you try [ESPRESSO_TABLE] and do any events display when it’s just the [ESPRESSO_TABLE] shortcode (no added parameters?)


Josh

  • Support Staff

April 10, 2013 at 1:31 pm

Actually, it looks like the database password line might have been changed accidentally when the wp-config.php file was edited. You’ll need to re-enter the correct password that was there before to bring the site back up.


mpalmer

April 10, 2013 at 1:32 pm

I get the mysql error on any page it seems…. is that something I should run by my host? It’s a bit out of my expertise.


mpalmer

April 10, 2013 at 1:33 pm

Oops just saw your other reply. I will look into that right now.


mpalmer

April 10, 2013 at 1:40 pm

OK my wp-config file was strange, I don’t know how it was working before but the user names had dashes instead of underscores, and I think it was just working by chance until I did the debug thing. Then it stopped because the database fields were incorrect originally… ! Anyway, I now have the debug working and you can view all of the errors here

http://www.still-point-press.com/TRC/event-archives/


mpalmer

April 10, 2013 at 1:40 pm

In case it’s easier; here are the event espresso specific ones:

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 63

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 63

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 64

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 64

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 65

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 65


Josh

  • Support Staff

April 11, 2013 at 10:47 am

Hi there,

You’ll likely see those errors go away if you add another category into the system. You will not need to assign any events to the other category. Can you try that and see if that makes a difference?


mpalmer

April 12, 2013 at 8:59 am

I added a new category and these errors were returned (and it did not return any content):

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 63

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 63

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 64

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 64

Notice: Undefined offset: 0 in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 65

Notice: Trying to get property of non-object in /home/stillpoi/public_html/TRC/wp-content/uploads/espresso/templates/espresso_table.php on line 65


Josh

  • Support Staff

April 12, 2013 at 3:41 pm

Hi there,

I’m sorry that the espresso_table shortcode isn’t working as expected for you. I’m not sure why it’s not working in this case. It might be a better solution to add a conditional check to the event_list_display.php template where it pulls the description and make it not display the description for your archive page.

Something like this will do the trick:

//Show short descriptions
if (!empty($event_desc) && isset($org_options['display_short_description_in_event_list']) && $org_options['display_short_description_in_event_list'] == 'Y'){
?>
	<?php if (!is_page('event-archives')) { ?>
	<div class="event-desc">
	<?php echo espresso_format_content($event_desc); ?>
	</div>
	<?php
	}
}
	?>

The you can use the standard [EVENT_LIST] shortcode with a category parameter to display your list.

You can copy the modified event_list_display.php template to your active theme’s folder and it will load from there and not get overwritten on an update.


mpalmer

April 16, 2013 at 10:43 am

Thanks, Josh! I’ll try that. I appreciate all of your time and help.


Josh

  • Support Staff

April 16, 2013 at 10:58 am

You’re welcome. Sorry the other shortcode didn’t work out.


mpalmer

April 16, 2013 at 11:40 am

So…. using your code (thanks again!) the description does not show on the “archive” page – however I am using this shortcode [EVENT_LIST show_expired=true  category_id=archives1]  and it is showing -all- of the events, including current events, not just the ones that are expired / in the category “archives1” – any idea why that filter isn’t working? Thanks!


Josh

  • Support Staff

April 16, 2013 at 12:20 pm

Hi there,

It looks like that’s not quite the correct way to specify a category. It should be either “category_identifier” or “event_category_id”.

Please see this section of the shortcode documentation for more info:

https://eventespresso.com/wiki/shortcodes-template-variables/#event-list


mpalmer

April 16, 2013 at 12:58 pm

I had tried [EVENT_LIST show_expired=true  category_identifier=archives1] and I get no results, and when I had tried [EVENT_LIST show_expired=true  category_identifier=archives1] I get all results, including current events that are not categorized as archives1.  I just tried those two shortcodes again and got the same results.


Josh

  • Support Staff

April 16, 2013 at 1:34 pm

Hi there,

It sounds like either the category isn’t getting saved in the database correctly, or the relation between the category and the event isn’t getting pulled. Is it possible for someone from support to get an export of the events tables from the database so we can investigate further?


mpalmer

April 16, 2013 at 1:38 pm

Yes I can try and get that to you. What’s the best way – do you want me to just paste it here once I export?


Josh

  • Support Staff

April 16, 2013 at 2:05 pm

That would be a lot to copy and paste here. You could either email the file to support@eventespresso.com or upload the file to something like Dropbox and send the link to the Dropbox URL.


Josh

  • Support Staff

April 16, 2013 at 3:02 pm

Thanks for sending.

I imported the tables onto a local test site and created a page and put this shortcode on it:

[EVENT_LIST event_category_id=archive1 show_expired=true]

When I view the page, it’s displaying two events:

screenshot

So it looks like the category/events data is okay. Can you try the shortcode I used?


mpalmer

April 16, 2013 at 3:10 pm

Wow – this is so strange! I put that code that worked for you into my page and it’s still displaying everything:

http://www.still-point-press.com/TRC/event-archives/

BUT when I use the sidebar widget to display only the archive/expired events it works… Just in case, I reverted to the original event-list-display.php page (In case I had done something wrong there) but even the default file returned all of the results, not the filtered results. Wish I had some other ideas….


Josh

  • Support Staff

April 17, 2013 at 10:47 am

Hi there,

It might be good to see what happens if the copy of event_list.php that’s in /wp-content/uploads/espresso/templates is removed or renamed. The event_list.php template handles the category filtering for the event list.

Aside from that, it might be a plugin or theme conflict that could be ruled out by temporarily switching to the default WordPress theme and temporarily deactivating other plugins.


mpalmer

April 17, 2013 at 11:53 am

Hi Josh, When I removed event_list.php from the uploads/espresso/templates folder on the server the archive page actually worked….but without my display changes. So now the problem is that I made many display changes to event_list_display.php – and according to what is happening (and your documentation) the two files have to “go together” in order for the event_list_display.php template file of mine to be accessed and used on the site. Is there a solution for this new issue? Thanks!


Josh

  • Support Staff

April 17, 2013 at 12:17 pm

Yes there are two:

1) Copy over a fresh copy of event_list.php from the Event Espresso plugin to /wp-content/uploads/espresso/templates.

-or-

2) Copy your modified event_list_display.php file to your active theme’s folder and it will load from there.

Option #2 is what I’d recommend because you will not need to maintain the changes in the event_list.php template the next time you update.


mpalmer

April 17, 2013 at 2:59 pm

HURRAH!  I used #2 – and it works perfectly.  I can’t tell you how much I appreciate your help and sticking through this troubleshooting process. THANK YOU! Yay!

Viewing 30 reply threads

The support post ‘Shortcode for EventList description display?’ 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