Conditional Placeholder with Custom Attributes
-
Hi there,
I put the following code in the themes functions.php
/** * add some conditional output conditions for Events Manager * @param string $replacement * @param string $condition * @param string $match * @param object $EM_Event * @return string */ function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){ if (is_object($EM_Event)) { switch ($condition) { // replace LF with HTML line breaks case 'nl2br': $replacement = nl2br(preg_replace('/\{\/?nl2br\}/', '', $match)); break; // #_ATT{Homepage} case 'has_att_homepage': if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Homepage'])) $replacement = preg_replace('/\{\/?has_att_homepage\}/', '', $match); else $replacement = ''; break; } } return $replacement; } add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);
And the following in Formatting > Events > Single Events
{has_att_website} Text {/has_att_website}
I would like to hide the Custom Attribute #_ATT{Website} when it’s empty. But it’s gone anyway even if there is a url in there.
Any thoughts?
Cheers
`
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Conditional Placeholder with Custom Attributes’ is closed to new replies.