• Resolved julinho.sf

    (@julinhosf)


    Hi,

    I’ve been searching in this forum and I didn’t find the solution.

    My problem is that I have an attribute called “Age” and I don’t want to show anything if this attribute is empty, so I need a way to know if this attribute is empty or not. In other words: I need to create something like {has location}{/has location}, but with this attribute.

    I can use html and php, so it is not a problem.

    I appreciate your answers.

    Thanks a lot,
    Julio

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Hi Julio,

    Something I want to add soon, but atm you’d need to make a custom conditional placeholder for it – http://wp-events-plugin.com/tutorials/create-a-custom-placeholder-for-event-formatting/

    if you search these forums, I remember someone having done this before.

    Thread Starter julinho.sf

    (@julinhosf)

    Thanks a lot,

    I’ve managed to do it using this code:

    function my_em_has_attribute_event_output_condition($replacement, $condition, $match, $EM_Event){

    // Attribute_1
    if( is_object($EM_Event) && preg_match(‘/^has_Attribute_1$/’,$condition, $matches) ){
    if( !in_array($args[‘Attribute_1’],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes[‘Attribute_1’]) ){
    $replacement = preg_replace(“/\{\/?$condition\}/”, ”, $match);
    }else{
    $replacement = ”;
    }
    }

    // Attribute_2
    if( is_object($EM_Event) && preg_match(‘/^has_Attribute_2/’,$condition, $matches) ){
    if( !in_array($args[‘Attribute_2’],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes[‘Attribute_2’]) ){
    $replacement = preg_replace(“/\{\/?$condition\}/”, ”, $match);
    }else{
    $replacement = ”;
    }
    }

    return $replacement;
    }
    add_action(’em_event_output_condition’, ‘my_em_has_attribute_event_output_condition’, 1, 4);

    Thanks for your support!

    I’m using event manager 5.4.4 and i need to use conditional event attribute. I think your solution could fit to my needs… Where you put this code? “Attribute_1” is a general name for an attribute? I mean, in your case you used “Age” instead of “Attribute_1” in your code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create conditional placeholders for attributes’ is closed to new replies.