• akiraprise

    (@akiraprise)


    Hi,

    I was wandering if it’s possible to add PHP to the events list template so that I can check if the attribute Affiliate is filled in, so that I can add a “buy tickets” link on each event. For example:

    http://ibiza2012.net/ibiza-closing-parties-2012/ << I’d like to put Buy Tickets buttons on all of the parties that have tickets available.

    I’ve done it on the event-single.php page, but can’t find a template file to do it for the way the event list is displayed, is there a template or if not how can I make it work?

    ta
    Russell

    http://wordpress.org/extend/plugins/events-manager/

Viewing 8 replies - 1 through 8 (of 8 total)
  • agelonwl

    (@angelonwl)

    have you tried events-list.php ?

    Thread Starter akiraprise

    (@akiraprise)

    Is that the template for each individual “box” like on the link I sent, or the entire page – I thought that was the whole page template?

    Thanks
    Russell

    agelonwl

    (@angelonwl)

    yes, however abit confuse now; is that link is a events or category listing?

    For Events List: events-list.php
    For Category List: categories-list.php
    For Location List: locations-list.php

    Thread Starter akiraprise

    (@akiraprise)

    That link is a normal page which is displaying events on it using:

    [events_list limit=6 town=pacha]

    I’ve looked at the events-list.php file and I’m confused on how I can change the output of each event, it looks as though it’s just controlling the event search and pagination rather than each individual event listing,

    ta

    agelonwl

    (@angelonwl)

    Thread Starter akiraprise

    (@akiraprise)

    Thanks for your help Agelonwl,

    Can you advise how to merge these two bits of code please? Been trying all morning but failing miserably 🙁 I’d really appreciate it!

    <?php echo EM_Events::output(array('format'=>
    '<a href="#_EVENTURL" border=0>Test</a>
    <B>#_EVENTLINK</B><br/>#_EVENTDATES #_EVENTTIMES<BR/><i>#_LOCATIONNAME, #_LOCATIONADDRESS, #_LOCATIONTOWN </i><br/>
    <strong>!!!!!!!!EVENT LINK SHOWS HERE IF ITS SET!!!!!!!!</strong><HR>',
     'limit'=>20, 'pagination'=>1)); ?>

    and

    <?php if(isset($attr['affiliate']) && !empty($attr['affiliate'])){
            echo '<a href="'.$attr['affiliate'].'"><strong>Buy a ticket</strong></a>';
    }?>
    agelonwl

    (@angelonwl)

    You can do something like these:

    event-list.php

    echo EM_Events::output(array('format'=>
    '#_EVENTLINK</B><br/>#_EVENTDATES #_EVENTTIMES<BR/><i>#_LOCATIONNAME, #_LOCATIONADDRESS, #_LOCATIONTOWN </i><br/>
    {has_attribute}<a href="#_ATT{affiliate}"><strong>Buy a ticket</strong></a>{/has_attribute}<HR>',
     'limit'=>20, 'pagination'=>1));

    in your theme functions.php

    add_action('em_event_output_condition', 'my_em_has_attribute_event_output_condition', 1, 4);
    function my_em_has_attribute_event_output_condition($replacement, $condition, $match, $EM_Event){
        if( is_object($EM_Event) && preg_match('/^has_attribute$/',$condition, $matches) ){
        	if( !in_array($args['affiliate'],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes['affiliate']) ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        return $replacement;
    }

    note: modify as needed

    Thread Starter akiraprise

    (@akiraprise)

    Excellent 🙂 thank you so much for your help – that’s brilliant 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘[Plugin: Events Manager] Adding PHP to the Events List Template’ is closed to new replies.