can you paste your code snippet again using pastebin?
Oops, didn’t realize the forum limited the number of lines of code in a post.
Here’s the pastebin:
http://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 ) ){
I made that code change, but that {has_VenueURL}
conditional still won’t show on the page.
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 ?
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:
http://pastebin.com/N8mveJ1g
An example event page:
http://djspacemonkey.com/performances/milkbar-mod-nwc35/
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}
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}
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.