• I created a custom Location placeholder of #_LATT{VenueURL} that I’ve added to one of my locations.

    I’m using a child theme so I can modify the site’s theme without manually editing the source theme’s files. As such, I added the following to my child theme’s functions.php file to be able to use a custom conditional placeholder of {has_VenueURL}:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Without the {has_VenueURL} conditional, the #_LATT{VenueURL} outputs to the page as expected. What did I miss or otherwise code incorrectly?

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 11 replies - 1 through 11 (of 11 total)
  • can you paste your code snippet again using pastebin?

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    Oops, didn’t realize the forum limited the number of lines of code in a post.

    Here’s the pastebin:
    https://pastebin.com/Aaknn6PH

    change this line:
    From

    if( is_object($EM_Event) && preg_match('/^has_VenueURL_(.+)$/',$condition, $matches) && is_array( $EM_Event->VenueURL ) ){

    To

    if( is_object($EM_Event) && preg_match('/^has_VenueURL$/',$condition, $matches) && is_array( $EM_Event->VenueURL ) ){

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    I made that code change, but that {has_VenueURL} conditional still won’t show on the page.

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    agelonwl, anything else I should try? I made that change but the custom conditional still doesn’t work.

    Hi,

    can I know where you will use {has_VenueURL} e.g. location page or events page ?

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    On an events page.

    I’ve also created an Events Attribute of #_ATT{EventURL} as well as the Locations Attribute #_LATT{VenueURL} with custom conditionals for both, and put both onto an event page but neither work.

    To ensure the custom attributes themselves work, in Events Manager Settings > Events format > Single Page Event I included both attributes, once inside a conditional and one outside, each use tagged to show if inside a conditional or not. The resultant event page shows only the non-conditional includes.

    Single Page Event code snip:
    https://pastebin.com/N8mveJ1g

    An example event page:
    https://djspacemonkey.com/performances/milkbar-mod-nwc35/

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    Any further insight on this issue, @agelonwl ?

    you can try this one:

    paste this to your theme functions.php

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

    then add an event attribute to your settings > general > general options > Event Attributes

    #_ATT{venue_url}

    then you can use this on settings > formats/layouts > events format > Default single event format

    {has_venueurl}
     <a href="#_ATT{venue_url}">Venue URL</a>
    {/has_venueurl}

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    Yes, that works. However, that changes from VenueURL as a #_LATT location attribute to a #_ATT event attribute.

    Is there no way to create a conditional placeholder function for a location attribute?

    Also, how do I reuse that for multiple conditionals? Frex, I have two other event attributes, #_ATT{EventURL} and #_ATT{EventAges} and would like to create conditionals for both of those as well as the #_LATT{VenueURL}

    Thread Starter dj.spacemonkey

    (@djspacemonkey)

    Actually, I figured out the second aspect — the my_em_has_attribute_event_output_condition is the unique name for the function, so I just use a different unique name for each custom conditional.

    I’m still stuck on trying to get this to work with #LATT location placeholders, as it makes much more sense to attach the URL for a venue’s website to the location entry, and not enter it for each event held at that location.

    BTW, thanks for all the assistance you’ve already provided. I’m sorry that this is dragging on.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Events Manager] Custom conditional placeholder not working’ is closed to new replies.