• Resolved Stefancom

    (@stefancom)


    Dear Forum Users,

    I just started using the Plugin, and I think it is very useful and strong. I would like to take it a step further to what I want to do, but I fail. Maybe someone would know how to get there?

    Is it possible to add a new event and to connect that with a wordpress page? Just like one includes the date, the time, the location, I would like to “include” (select) one (or more) of my pages.

    Those pages could appear for example as links within the event information.

    Is such possible?

    Best regards

    Stefan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Stefancom

    (@stefancom)

    Couple hours later I am smarter than before: I began to figure out the Attribute function. Very nice! I introduced three different values as a start, just to play around.

    Now, could I use a Conditional Placeholder based on my new attribute’s value?

    I would like on one page to only display events which have a specific value in that attribute. Is that possible?

    Stefan

    Hi Stefan,

    Good work on getting smarter 🙂

    Although there’s no conditional placeholder for event attributes by default, you can add one by adding the code below to the functions.php file of your theme.

    https://pastebin.com/4amjiMwi

    You’d need to change attribute_name to match the name of your attribute.

    Thread Starter Stefancom

    (@stefancom)

    Hi Caimin

    Thanks for the help! Very much appreciated.

    I fail to get this to work, yet weirdly it seems the standard programming provides some sort of “conditional” display of information already:

    #_ATT{attribute}{ }
    
    When I write it like this, it shows the attribute, if there is one, but stays invisible, if there is not any. ... That is already kind of effective, yet surprisingly simple. Not bad.
    
    But I have the impression, that I do need the conditional placeholder after all for what I want to do. But I must have misunderstood something concerning your advice ... What seems to be the issue with the following? Would you be able to see the problem?
    
    (1) This is, what I included in my theme's function.php:
    
    <code>function my_em_has_attribute_event_output_condition($replacement, $condition,</code>$match, $EM_Event){
    

    if( is_object($EM_Event) && preg_match(‘/^is_true/’,$condition, $matches) ){
    if( !in_array($args['website'],$EM_Event->event_attributes) &&!empty($EM_Event->event_attributes[‘website’]) ){

                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
    

    }else{

                $replacement = '';
    

    }

        }
    

    return $replacement;

    }
    <code>add_action('em_event_output_condition',</code>'my_em_has_attribute_event_output_condition', 1, 4);
    
    (2) This is the definition of this attribute in the Event Settings:
    
    

    #_ATT{website}

    (3) This is the code as I use it in the Events’ formatting:

    `{has_website}Info …{/has_website}

    So, what I want to do: If there is a website/URL to the event, that can be noted in the newly create “website” attribute field. So, when there is text in that attribute, a link (with the word “Info …” or an image) to that website will be displayed. If there is no text to that attribute, nothing will be displayed, neither the URL nor the word “Info …”. I guess I do need the customised conditional placeholder for that, right?

    Best,

    Stefan

    Thread Starter Stefancom

    (@stefancom)

    Test
    Test
    Thread Starter Stefancom

    (@stefancom)

    Hi Caimin

    Thanks for the help! Very much appreciated.

    I fail to get this to work, yet weirdly it seems the standard programming provides some sort of “conditional” display of information already:

    #_ATT{attribute}{ }

    When I write it like this, it shows the attribute, if there is one, but stays invisible, if there is not any. … That is already kind of effective, yet surprisingly simple. Not bad.

    But I have the impression, that I do need the conditional placeholder after all for what I want to do. But I must have misunderstood something concerning your advice … What seems to be the issue with the following? Would you be able to see the problem?

    (1) This is, what I included in my theme’s function.php:

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

    (2) This is the definition of this attribute in the Event Settings:

    #_ATT{website}

    (3) This is the code as I use it in the Events’ formatting:

    {has_website}Info …{/has_website}

    So, what I want to do: If there is a website/URL to the event, that can be noted in the newly create “website” attribute field. So, when there is text in that attribute, a link (with the word “Info …” or an image) to that website will be displayed. If there is no text to that attribute, nothing will be displayed, neither the URL nor the word “Info …”. I guess I do need the customised conditional placeholder for that, right?

    Best,

    Stefan

    Thread Starter Stefancom

    (@stefancom)

    (I apologise for the chaotic messages. In the first one I misunderstood how to post code. In the second I tested how to do it right. In the third I posted my message right.)

    Thread Starter Stefancom

    (@stefancom)

    Hi everyone

    I fixed it already!

    https://snippets.webaware.com.au/snippets/events-manager-conditional-placeholders-for-custom-attributes/

    This page was very helpful. It pretty much did exactly what I was looking for. Go there if you have a similar question like mine. Caimin, thank you for your help, as well.

    Stefan

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

The topic ‘Include a page in event’ is closed to new replies.