Support

Home Forums Event Espresso Premium Modularising Event Components

Modularising Event Components

Posted: May 31, 2023 at 6:50 pm

Viewing 8 reply threads


Digital Services Lab

May 31, 2023 at 6:50 pm

Hello, I guess this is both a suggestion and a question.

I use page builders such as Divi for a lot of my clients projects. In doing so I’m often faced with issues when trying to integrate Event Espresso into the themes Template Builder.
The issue is two fold:

  1. As far as I can see, none of the available shortcodes execute for ‘the current’ post so it’s not possible to simply put for example [ESPRESSO_TICKET_SELECTOR] inside a single event template as it requires the event_id attribute
  2. There are no shortcodes for the other components: Description, Venue, notifications, etc.

Here’s my question – I’ve done the following to create my own module shortcodes but is there a better/more appropriate/more EE way to do this?

Tickets – this one was easy

I’m just fetching the current post id and then verifying that we are on a single event and then calling the EE shorcode with either the current post id or an input post id.

// Tickets
// [dsl_ee_single_tickets]
add_shortcode( 'dsl_ee_single_tickets', 'dsl_ee_single_tickets_cb' );
function dsl_ee_single_tickets_cb($attributes = array())
{
    //get current post ID
    $event_id = get_the_ID();

    // clean atts 
    $a = shortcode_atts( array(
        'event_id' => $event_id,
    ), $atts );

    $tickets_html = null;

    // check if EE is running and this is a single event page 
    if (  class_exists( 'EE_Addon' ) && is_single() && 'espresso_events' == get_post_type() ) {

        //call EE shortcode processor using current post ID  or passed in post ID
        $tickets_html = do_shortcode("[ESPRESSO_TICKET_SELECTOR event_id={$event_id}]" );

        
    }

    return $tickets_html;

}

Date-times, venue, header, thumbnail
I don’t like this but it works. I’m sure there is a better way.
For these, they all follow the same patter. I’m just checking we are on a single event and then fetching the relevant template part.. exactly as EE does…kinda.

// Date Times
// [dsl_ee_single_datetimes]
add_shortcode( 'dsl_ee_single_datetimes', 'dsl_ee_single_datetimes_cb' );
function dsl_ee_single_datetimes_cb( $atts ){

    // clean atts 
    $a = shortcode_atts( array(), $atts );

    $ee_datetimes = null;
    // check if EE is running and this is a single event page 
    if (  class_exists( 'EE_Addon' ) && is_single() && 'espresso_events' == get_post_type() ) {
        $ee_datetimes = EEH_Template::get_template_part( 'content', 'espresso_events-datetimes', array(), true );
    }
    
    return $ee_datetimes;
}

Description
Again, I don’t like this but it works.
Because EE filters the_content and adds all the custom fields into the_content you cant just output the_content() or use the EE template as the above example because it’s not modular – you end up with everything in there. So I’m just fetching get_the_content()..

// Details
// [dsl_ee_single_details]
add_shortcode( 'dsl_ee_single_details', 'dsl_ee_single_details_cb' );
function dsl_ee_single_details_cb( $atts ) {
    // add_filter( 'FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );
    // clean atts 
    $a = shortcode_atts( array(), $atts );

    $content = wpautop( get_the_content() );
    

	return $content;
}

So is there a better way to do this?

Here’s my suggestion – probably guessed already…
Can you please create modular shortcodes for each event component that, when used without ad ID parameter, will fetch the current events details.
This would make EE integration with Theme Builders so much better.

Incidentally, as per a previous post from yesterday, there are issues with the shortcodes running inside Theme Builders anyway. Other plugins don’t have this problem. I’ve had to add some PHP to enqueue css and js on Theme Builder pages because EE doesn’t automatically do so for shortcodes called on those pages.


Garth

  • Support Staff

June 2, 2023 at 1:14 pm

Hi there,

WordPress is moving away from shortcodes, so this doesn’t seem like a wise approach. We will likely continue further integration with Gutenberg Blocks.


Digital Services Lab

June 3, 2023 at 10:32 pm

…right. except that most of your add-ons do use shortcodes…
Your response is really unhelpful. Whether you do it using shortcodes or blocks is beside the point.
The point is that you currently have no means, other than customising a php template (which, speaking of wisdom, is a decade old approach..), to change the layout of the event pages. There is no way to integrate EE with page builders/theme builders or WP core template editor for that matter as all the event components are stuck together.

Modularising them into separate elements would enable users to create event page templates using modern techniques (ie. not having to manually modify a php template).

You don’t have modular event element blocks or shortcodes.
You don’t have blocks or shortcodes that work on template pages because none of them are designed to work on the current post – they all require post id attributes.


Garth

  • Support Staff

June 5, 2023 at 8:39 pm

True, but what we have now is not much of an influence of how we move forward.


Digital Services Lab

June 5, 2023 at 8:52 pm

Ok, so your response to a request/suggestion to improve your product is to say that what you have now isn’t how you’ll move forward. Solid. Cheers.


Garth

  • Support Staff

June 5, 2023 at 9:01 pm

Right. We will use more modern techniques.


Digital Services Lab

June 5, 2023 at 9:09 pm

You know, I’m paying thousands for this product across several sites and you seem more interested in being belligerent than helpful.

You haven’t addressed the content of this ticket at all.


Garth

  • Support Staff

June 6, 2023 at 9:26 am

I’m sorry if you feel that way. Given what you are asking for is not something addressable in the short-term, how can I help you?


Digital Services Lab

June 6, 2023 at 5:02 pm

I’m sorry if you feel that way.

..are you though. I mean, your attitude is entirely intentional so it doesnt seem like you are.

how can I help you?

Hmm, this is a tricky one so I can understand why you may be baffled by this.
Perhaps by;

  • Acknowledging you understand the limitation currently, as it has been outlined
  • Addressing the actual suggestion in the context of the limitation
  • Talking about any plans that may be in place to address it if they already exist
  • Taking on board the limitation and suggested solution and planning to address it if plans are not already in place
  • Discussing any timelines that could be expected

Also by;

  • Addressing the question I also raised which you haven’t touched on at all
  • Putting some more effort in that the one line responses you’ve provided so far

That seems like a fairly obvious list of “how to helps”..

Given what you are asking for is not something addressable in the short-term

Well that’s up to you isn’t it. I mean, I put a working though not ideal solution together in about an hour which is outlined in my opening post.
You say you’re moving away from shortcodes so can’t use them but the truth is, it will be years before you move away from shortcodes so there really isn’t any valid reason why it could not be addressed in the short term.
All the functions to output the relevant data is there already, it just needs to be wrapped up. It could very easily be done in the short term before moving over to blocks that replace them at whatever point that happens.

Viewing 8 reply threads

The support post ‘Modularising Event Components’ 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