Support

Home Forums Event Espresso Premium Conditional Widget based on Venue

Conditional Widget based on Venue

Posted: January 15, 2013 at 9:27 pm


nickelmedia

January 15, 2013 at 9:27 pm

I’d like to display a widget based on the venue I choose for an event. For example, if the venue is North Florida, I’d like to automatically display a text widget with hotel information for that venue.

I tried using the widget logic plugin, but I believe it only works with default WP conditional tags. Most of these conditional widget plugins can only target specific pages and not content within them. Does anyone know of any alternatives that will work?

Is there some way to control this via Meta? Could I put a hidden tag in the venue description to call a widget?

Any help or push in the right direction would be greatly appreciated!


Dean

January 16, 2013 at 1:03 am

Hi Jeff,

Using the meta data is actually a very good way of doing this. Simply add a meta tag to the event with a value.

You would need to be able to use PHP in a text widget (there are code snippets/plugins that can enable this) and in a text widget add something like

<?php
$my_variable_name = $event_meta['my_meta_key']; //replace this with the actual meta key

if ($my_variable_name = "my meta value") { // replace with the actual meta value
//some code goes here
} else {
//an error message or you can remove this else statement or, even have a default response for when the event/page doesnt have that meta key
}

?>

You would probably be wise to expand on this and tie in the event id or something as I think this might be too broad to use as is, it would need testing.


nickelmedia

January 25, 2013 at 10:33 am

So in theory, rather than having to use meta, could I use the venue to define the IF statement?

If so, what would the call be to replace $event_meta?

Thanks!


Dean

January 28, 2013 at 4:09 am

Hey,

Yep that sounds right too,

<?php 
if($venue_title = 'Florida') { //Florida equals the venue NAME
echo "yay";
} else {
echo "boo";
}
?>

The support post ‘Conditional Widget based on Venue’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso