Forum

Thread tagged as: Question, Addons, Events

Remove cr/lf from eventDescRaw

Hi.

I'd like to improve how well my event pages work with Facebook by introducing some "proper" Open Graph tags:

<meta property="og:site_name" content="Grappenhall &amp; Thelwall Royal British Legion" />
<meta property="og:title" content="<perch:events id="eventTitle" />" />
<meta property="og:description" content="<perch:events id="eventDescRaw" />" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.gtrbl.org.uk/events-event.php?event=<perch:events id="eventSlug" />" />

Is there any way to remove cr/lf from eventDescRaw?

Thanks in advance.

Mike Knowles

Mike Knowles 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm good question! I can't think of a way to do that with a template tag at the moment.

The fall back would be to add a new custom field for a short description. However, the people running the pages generally only add a short description anyway, so it would be preferable to adapt the existing field.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ideally we'd have some sort of pluggable filters for this so you can use PHP functions.

The fallback would be to use skip-template to get a PHP array and then use str_replace() or similar.

Do you happen to have an example of that knocking about? I do use an array to get the event data:

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

I'm reading the documentation but struggling to see how it all hangs together.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

We don't have an example other than the documentation. Where are you stuck?

To be honest my Perch is a bit rusty; I've not done anything with it for some time.

I need to understand how the arrays work in templates so I'll read that bit and then post some details. Just writing a specification for a new project naturally powered with Perch so it will be tomorrow when I try it again.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to use perch_events_custom(), so something like:

$event = perch_events_custom(array(
        'filter'=>'eventSlug',
        'match'=>'eq',
        'value'=>perch_get('event'),
        'skip-template'=>true
    ));

OK.

I'll have a play and post back if/when I get stuck.

Thanks for the replies folks. :-)