• Resolved willemb2

    (@willemb2)


    Newby here. We want to publish a calendar with public events in a specific sector. Most of them have their own website with all the latest details so I want link to them. I have seen this in other calendar plugins. But I cannot find a default field or a place holder for that in EM.

    #_EVENTURL links to the event on our site. #_CONTACTURL seems related to WP user, but we want to allow anonymous front-end submissions

    I would probably get this done with a custom attribute. But these days each yearly neighborhood summer potluck has its own internet domain and website. So I would expect this to be a standard feature.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Change the pulldown for the Location to be URL and then fill in the URL for the event. Then when you view the event you’ll see the link to the event in the WHERE section. You can use the #_EVENTURL or #_EVENTLINK placeholders as well.

    Here’s the documention for placeholders you’ll see a section for Links/URLs

    Thread Starter willemb2

    (@willemb2)

    Thanks, @joneiseman for your rapid response.

    Change the pulldown for the Location to be URL and then fill in the URL for the event. Then when you view the event you’ll see the link to the event in the WHERE section.

    I did not have that pulldown. Probably because I did not enable URLs at Location Types under setting > general. We do normally not publish online events. When I do enable URLs and switch to URL and then back Physical there is indeed a field URL in the WHERE section and I tried adding an URL and saved. But it doesn’t seem to be saved. When I re-edit the location or the event the URL field is empty and it doesn’t appear on the single event page. Example.

    I also added #_EVENTLINK as a attribute for events and in the Single event page format, but that just links to Single event page itself.

    • This reply was modified 5 months, 3 weeks ago by willemb2.

    That’s interesting. When I enter a URL value for the event location it is saved when I save the event. Not sure why it’s not working for you. By default both Physical Location and URL location types are enabled.

    Try going to Event > Settings and then in the General tab in the Advanced section try clicking on the Reset button and then click on the Save Changes button to see if that resolves the problem.

    Did you add any custom code to implement the #_EVENTURL placeholder?

    Another way to do this is to implement your own placeholders for #_EVENTURL and #_EVENTLINK:

    add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3);
    function my_em_styles_placeholders($replace, $EM_Event, $result){
    if( preg_match( '/#_EVENTIMAGE.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'EVENTURL', true);
    if ( empty( $url ) ) {
    $url = esc_url($EM_Event->get_permalink());
    $replace = '<a href="' . $url . '">' . $replace . '</a>';
    }
    else {
    $replace = '<a href="' . $url . '" target="_blank">' . $replace . '</a>';
    }
    }
    else if( preg_match( '/#_EVENTLINK.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'EVENTURL', true);
    if ( !empty( $url ) ) {
    $replace = preg_replace('/(<a href=")[^"]*">([^<]*)<\/a>/', '${1}' . $url . '">' . '$2' . '</a>', $replace);
    }
    }
    else if( preg_match( '/#_EVENTURL.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'EVENTURL', true);
    if ( !empty( $url ) ) {
    $replace = $url;
    }
    }
    return $replace;
    }

    Then in Event > Settings in the general tab in Event Settings within the General Options section enable Event Attributes and enable Event Custom Fields. Then add the following in the Event Attributes box:

    #_EVENTURL

    Then save the settings. There will then be an EVENTURL field when creating or editing an event. The above code snippet will make it so that when someone clicks on the event it will go directly to the external URL.

    You can use the Code Snippets plugin to add this code snippet.

    Thread Starter willemb2

    (@willemb2)

    I did a reset, but that did not change the issue with #_LOCATIONURL

    An URL field only appears below Country in ‘Add new event’. Not in Add new location, Edit location or Edit event. When I add #_LOCATIONURL to Single location page format it show just the URL of that Single location page.

    Did you add any custom code to implement the #_EVENTURL placeholder?

    No, I did not. I have needed some other tweaks though that I found on this forum:

    I added your code snippet to our child-theme’s functions.php (without understanding it, I don’t speak a word PHP) and added #_EVENTURL to Event attributes. Cleared cache. But it does not appear in Add new event. Where should it appear? Under Attributes I only see this line:

    In order to use attributes, you must define some in your templates, otherwise they'll never show. Go to Events > Settings > General to add attribute placeholders.

    that has always been there.

    I added #_EVENTURL to the Single event page format under #_EVENTNOTES and this the result. It writes the Single event page URL in plain text.

    I am sorry I was unable to help.

    Thread Starter willemb2

    (@willemb2)

    @joneiseman Well, thanks a lot for all the effort you put into this!

    • This reply was modified 5 months, 3 weeks ago by willemb2.
    Thread Starter willemb2

    (@willemb2)

    I got it working now with a custom attribute. In Settings > General > Event Attributes I added:

    #_ATT\{Evenement-website}

    Under Settings > Formatting > Events > Single event page format I added:

    {has_att_Evenement-website}
    <a href="#_ATT{Evenement-website}" target="_blank" rel="noopener">click here for the #_EVENTNAME website</a>
    {/has_att_Evenement-website}

    This makes the link to the external website appear as intended.

    Conclusion: for some reason I cannot add the plugins default extra placeholders like _EVENTURL or #_EVENTLINK to General > Event Attributes to make them editable. I installed EM on another site with a totally different theme and other plugins, but it’s the same there. I’ll dig into that later, for the moment I got what I need.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.