Support

Home Forums Event Espresso Premium Possible bug in the child template?

Possible bug in the child template?

Posted: July 1, 2014 at 9:06 am

Viewing 5 reply threads


Simon Belcher

July 1, 2014 at 9:06 am

Hi guys,

Trying to use the venues archive page to just output the thumbnail, then the title, then the upcoming dates that events are held at that venue.

I am stuck at the first hurdle and I think it may be a bug:

http://ee.stagebe.co.uk/venues/

Notice: Undefined variable: wrap_class in /var/www/eerieevenings/htdocs/wp-content/themes/eerieevenings-child/content-espresso_venues-thumbnail.php on line 9

Is this an easy fix?

Also then need to output the dates of the events at that venue which is where I could really do with the help?

Many thanks!


Dean

July 2, 2014 at 2:11 am

Hi,

An undefined variable isn’t a bug as such, it’s merely a notifying that the variable being requested has not been set. It will not stop the plugin from functioning.

Also please note that wp_debug should not be used on a live site for security reasons (http://codex.wordpress.org/Debugging_in_WordPress#WP_DEBUG just above the PHP Errors, Warnings and Notices sdection)

Regarding the events, this might not be the best way to do it, but I would add the following to the content-espresso_venues.php

	<?php 
    	global $wpdb, $post;

	 	$sql = "SELECT EVT_ID ";
        $sql .= "FROM {$wpdb->prefix}esp_event_venue ";
        $sql .= "WHERE {$wpdb->prefix}esp_event_venue.VNU_ID = $post->ID";

        $the_events = $wpdb->get_results( $wpdb->prepare( $sql, $post->ID ));

        //var_dump($the_events);

        foreach($the_events as $event) {
        	$x = get_post($event->EVT_ID, ARRAY_A);
        	//var_dump($x);
        	echo '<a href="' . $x['guid'] . '"><h2>' . $x['post_title'] . '</h2></a>';
        }

        ?>

It does an SQL search for each venue to find the events associated with it, then a get post on each event and spits out the title with link.


Simon Belcher

July 2, 2014 at 2:40 am

Ahh that certainly looks like its along the right path, could I be really cheeky and pick your brains further?

The guid on all my events is blank, and also that shows all events not just upcoming events.

Is there a way to output a linked title along with the relevant date?

Many thanks.


Simon Belcher

July 2, 2014 at 2:42 am

p.s. Could I also make a feature request for this to be included? If you’re searching for something by Venue then it means you are looking for a venue local to you, once you’ve found it it would be natural to want to see the dates that events are being held there?

p.p.s And one step further on this, it would be great if the venues could be arranged by County, or even ordered from a postcode search 😉


Simon Belcher

July 2, 2014 at 5:42 am

Hi Dean,

We took your lead and ended up with this, it generates a working list of permalinked titles which include the date and time of the relavant event.

Maybe of use to others…

<?php
    global $wpdb, $post;

    // Pull details of the events associated with this venue from the db
    $sql = "SELECT * FROM {$wpdb->prefix}esp_event_venue ";
    $sql .= "LEFT JOIN {$wpdb->prefix}esp_datetime ON {$wpdb->prefix}esp_datetime.EVT_ID = {$wpdb->prefix}esp_event_venue.EVT_ID ";
    $sql .= "WHERE {$wpdb->prefix}esp_event_venue.VNU_ID = $post->ID ";
    $sql .= "AND {$wpdb->prefix}esp_datetime.DTT_EVT_start > '" . date('Y-m-d H:i:s') . "'";

    $the_events = $wpdb->get_results( $wpdb->prepare( $sql, $post->ID ));
 
    echo '<ul class="venue-events">';

    foreach($the_events as $event) {
        $x = get_post($event->EVT_ID, ARRAY_A);

        // Reformat the mysql date string
        $datetime = strtotime( $event->DTT_EVT_start );
        $formatteddatetime = date("d/m/y @ g:i A", $datetime);

        echo '<a href="/events/' . $x['post_name'] . '">' . $x['post_title'] . ' - ' . $formatteddatetime . '</a>';    
    }

    echo '';

?>
  • This reply was modified 10 years, 5 months ago by Tony. Reason: cleaned up the php forum formatting


Dean

July 2, 2014 at 6:19 am

Hi Simon,

Sorry for the slow response, but I’m glad you figured it out. And thank you for sharing it with the rest of the community!

I’ll certainly add your thoughts regarding the venues to our feature request list.

Viewing 5 reply threads

The support post ‘Possible bug in the child 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