• Hi, I posted about this a few weeks ago but didn’t have any luck, so I’m just trying again, I have 3 attributes set up on my new site, one for the line-up, one for a ticket reseller, and another for a different reseller. I’d like these to only display when there’s a value entered into each, and I’d also like them to be wrapped in html, for example:

    {has_lineup}<a href="#_ATT{lineup}">Lineup</a>{/has_lineup}

    I’ve looked at the tutorial over and over again at https://wp-events-plugin.com/tutorials/creating-conditional-placeholders-for-events/ and can’t get my head around how to link the code up correctly with the Attributes fields.

    Can someone help me with the code I can just paste in? I’m not lazy – just genuinely confused by the code. Alternatively – can someone help set it up like an add-on?

    I’m begging – please help me code this and I’ll be very grateful and paypal some beer money, or, Marcus, if you can do this for me I’ll purchase the full module – this is the only stumbling block for me ??

    Cheers!
    Russ

    https://www.ads-software.com/extend/plugins/events-manager/

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

    (@netweblogic)

    sorry custom jobs like that would need a programmer because it’s specific to your attribute, anyone willing to pitch in please do!

    Thread Starter akiraprise

    (@akiraprise)

    It’s just a very simple text attribute that I’ve set up using the included attribute framework built into the plugin, so please, anyone fancy making a very quick and easy buck? ??

    Thread Starter akiraprise

    (@akiraprise)

    Anyone willing to take on the job? Or can recommend someone? I really need to get this fixed on the site to launch it – please? ??

    ta

    I’m working through the same problem. I don’t want to create a whole new addon just to add a quick attribute.

    I don’t think it is unique to akiraprise’s problem (though, of course, Marcus is the one who would know best). The way I see it, the basic issue is: can we create conditional placeholders for Event Attributes, or can we only do it for custom placeholders? If the former, what’s the main difference?

    Thanks.

    ok, I got it to work! The main problem was relating the event_id to the post_id, as the Event Attributes are stored in postmeta, while the hook you need to use relies on $EM_Event. I’m not sure I understand fully why this works, but it seems to. Marcus, might you consider including this in your documentation (and maybe cleaning it up a little)?

    I have used “styles” as the name of the attribute, to stay in line with Marcus’ tutorial.

    I hope this helps, akiraprise.

    add_action('em_event_output_condition', 'my_em_styles_event_output_condition', 1, 4);
    function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
    	global $wpdb;
    	$postid = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_value = '{$EM_Event->event_id}' AND meta_key='_event_id'", 0	);
    	$styles_check = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.post_id = $postid[0] AND meta_key='styles'", 0	);
    	if( is_object($EM_Event) && preg_match('/^is_styles_(.+)$/',$condition, $matches) ){
    		if( in_array($matches[1],$styles_check) ){
    			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
    		}else{
    			$replacement = '';
    		}
    	}
    	return $replacement;
    }
    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    we’ll be reviewing the docs regularly as we’ll be adding many more features over the months!

    i run into the same problem with my facebook link and i had a totally different approch… here is my solution:

    i copied the template folder into my theme folder and started adding stuff to it like you do normal in the admin panel (well documented…)

    then i had a look at the class-functions and class-attributes you could get if you global $EM_event

    marcus pointed out, that there is a stored information in the $EM_event object called ‘attributes’ which will return all the attributes eg. custom fields and custom meta (or at least all meta?! not sure anymore)

    so i just went and wrote like

    $attr = $EM_Event->attributes;
    if(isset($attr[‘your custom attr’]) && strlen($attr[‘your_custom_attr’]) > 0) do something tricky;

    i use this for facebook links.. if there is one, i will print it out if not .. not

    if needed i could copy-past my code somewhere

    Thread Starter akiraprise

    (@akiraprise)

    Hey everyone,

    Thanks for looking into this and giving me 2 different options, I’m not sure which is best for my needs.

    Bucketsaway, I’ve put that code you posted in my functions file, added a #_ATT{styles}, put a text string in it on one event and tried to show the content with {is_styles}Conditional is working{/is_styles}, but it doesn’t seem to work, am I doing something wrong?

    and scharc, this also sounds interesting, could yuo give me an example of your code or how to implement this?

    Sorry guys but I’m a bit of a novice with php, but I really appreciate you both looking into this and giving me advice! Thanks ??

    in this example, the “styles” attribute should be a dropdown list. For instance:

    #_ATT{styles}{red|blue|green|brown}

    The conditional then takes the form

    {is_styles_red}This would be test that would appear if the style was red{/is_styles_red}
    {is_styles_blue}This would be test that would appear if the style was blue{/is_styles_blue}

    with some modification of the code, you could get it to work for a text field instead of a dropdown list, but I haven’t tried that.

    i think my description is selfexplaining and really easy… but you asked for it, so here it goes again:

    1. follow this: https://wp-events-plugin.com/documentation/using-template-files/

    2. add some custom attributes, in my example its “Facebook-Link”. remember, case-sensitive!

    3. you want something done to your single-event view, so copy your modifications from the admin panel to the event-single.php

    mine looks like: https://pastebin.com/c4zaNyJL

    thats it!

    akiraprise, did you get it to work?

    Thread Starter akiraprise

    (@akiraprise)

    Hi again,

    You actually both really helped, I’ve got 2 ticket affiliates, so I’ve managed to use both Bucketsaway code as a dropdown selection and scharc’s as a text input!

    Thanks again
    Akiraprise

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Events Manager] Conditional Placeholder’ is closed to new replies.