Forum

Thread tagged as: Question, Addons, Events

Grabbing variables from perch_events_custom

Hi.

I'm using an array of options:

<?php
    $opts_content = array(
        'filter'=>'eventSlug',
        'match'=>'eq',
        'value'=>perch_get('event'),
        'template'=>'events/event-detail.html'
    );
?>

...to set-up perch_events_custom():

<!--MAIN CONTENT AREA-->
<div class="wrap">
    <div class="container">
        <?php perch_events_custom($opts_content); ?>
    </div>
</div>
<!--//MAIN CONTENT AREA-->

This works fine. I would very much like to use the event title in the <meta /> within perch_layout():

<?php
    perch_layout('global.header.courses', array(
        'page_title'=>$title,
        'page_description'=>'Something.',
        'page_keywords'=>'Something',
        'class'=>'courses',
    ));
?>

$title is the variable I'm trying to get from perch_events_custom().

Is this possible?

Thanks in advance.

Mike Knowles

Mike Knowles 0 points

  • 6 years ago

Ah! Sorted:

<?php
    $opts_meta = array(
        'filter'=>'eventSlug',
        'match'=>'eq',
        'value'=>perch_get('event'),
        'template'=>'events/event-detail.html',
        'skip-template'=>'true'
    );

    $data_meta = perch_events_custom($opts_meta);

    $title = $data_meta[0]['eventTitle'];
?>
<?php
    perch_layout('global.header.courses', array(
        'page_title'=>$title,
        'page_description'=>'Something.',
        'page_keywords'=>'Something',
        'class'=>'courses',
    ));
?>

I bloody love Perch!