• Resolved dionadk

    (@dionadk)


    I added a conditional placeholder to custom attributes. So that if a field is left blank it wont be visible in the single events page. This works fine. But I have a drop down custom attribute with #_ATT{key name}{select|option1|option2}.
    According to the conditional placeholder I added it shows -select- value.I want this in such a way that if drop down options are not selected don’t display else display the option selected. Any help appreciated. Thank you in advance

    case 'has_speaker':
    if (is_array($EM_Event->event_attributes) && !empty($EM_Event>event_attributes['Request a Speaker:']))
    $replacement = preg_replace('/\{\/?has_speaker\}/', '', $match);
    else									$replacement = '';
    break;
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry for the confusion but can you give us further details about this?

    Thread Starter dionadk

    (@dionadk)

    Thanks for replying.

    I added a custom attribute “Speaker” with option “Select|Yes| No”
    #_ATT{speaker}{select|yes|no}

    Lets say if the user left this fields blank it shows “select” (default top value) on the Single Events Page. I need to hide that attribute on the Single Events page if user has not selected the dropdown value yes or no.
    This is the code:

    function filterEventOutputCondition($replacement, $condition, $match,$EM_Event){
      if (is_object($EM_Event)) {
        switch ($condition) 
          case 'has_att_speaker':
            if (is_array($EM_Event->event_attributes)
     && !empty($EM_Event->event_attributes['speaker']))
              $replacement = preg_replace('/\{\/?has_att_speaker\}/', '', $match);
             else
               $replacement = '';
           break;
            }
        }
        return $replacement;
    }
    add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);

    Right now this shows select if user didnt select yes or no:

    Hope this clarifies the situation. Sorry for the confusion.

    • This reply was modified 6 years, 10 months ago by dionadk.
    Plugin Support angelo_nwl

    (@angelo_nwl)

    I see what you mean now, Im going to test this out and update you here.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try something like this

    
    function filterEventOutputCondition($replacement, $condition, $match,$EM_Event){
      if (is_object($EM_Event)) {
        switch ($condition) 
          case 'has_att_speaker':
            if (is_array($EM_Event->event_attributes)
     && !empty($EM_Event->event_attributes['speaker']))
              $replacement = $EM_Event->event_attributes['speaker'];
             else
               $replacement = '';
           break;
            }
        }
        return $replacement;
    }
    add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional place holder for custom attribute’ is closed to new replies.