Posted: November 20, 2019 at 12:06 pm
I am in the process of setting up my events in Event Espresso. I have no problem creating an event and adding the necessary data to it (date/time, tickets, etc.). Where I am having a problem is styling the event display, as you say in your own documentation it is rather generic looking. I have looked at a number of support responses as well as the documentation, but I am still not seeing any examples of how to approach this. I am using Divi and Divi Builder, but I am not sure integration there makes sense. Ultimately I would really like to have an “event” template that gets used to display the information for an event. |
|
Hi, The Divi theme uses generic styles for its posts, so this isn’t a surprise. May I ask what kind of styling are we talking about? For example are you looking to change the layout, change colors, text sizes/spacing? |
|
Hi Josh, Thanks for your rapid response! I would like to style all of the items that you mention…layout order, visual layout, colors, text sizes/spacing. I understand, based on some coding work that I did with the EE Event Grid Add-On that there are even values that I might interrogate and utilize. Ideally I would like to select a page template from the “Page Template” drop down oin the Add Event screen. From a programming point of view I believe I am capable of doing that…just need to understand the structure need to put that together…maybe an example of the necessary files and base code would help… Thank you! |
|
Hi Tim, The layout order of the event page can be controlled with the settings in the Template Settings page. You go to Event Espresso > Events > Templates, then set “Use Custom Display Order?” to Yes. Then you can drag/drop the items to the preferred order. If you prefer not to use the above options, and do a custom page template instead, you can follow this guide that explains how to get started: https://eventespresso.com/wiki/ee4-custom-post-types/#single_event_template After you have your starter template in place, you can copy/paste the desired elements from the stock template parts used by Event Espresso. Those are located in the EE plugin’s /public/Espresso_Arabica_2014 folder. For example, to display the ticket selector in your custom template, you’ll copy the code from the content-espresso_events-tickets.php file. With regards to changing the visual layout, colors, text sizes/spacing, that’s normally something that you would do by adding some CSS to a custom stylesheet, so you would not need to do a custom PHP template to make those changes. |
|
Hi Josh, Thank you for your response. I have created a single-espresso_events.php file in my child theme directory and have added the add_filter statement to my functions.php file in my child theme as well. I have made some changes in the single-espresso_events.php and I am seeing the desired changes in the event pages now. So that is working great, thank you! I have one additional step I would like to be able to complete, and I don’t know if I can do this as an add-on to the above approach, but it would be great if I could. In the Add Event screen, I would like to be able to add these changes as an additional “Page Template” If I were able to do this then I could format specific events in specifc ways. Thanks, |
|
The single-espresso_events.php will be the default and you can copy that file and give it a new name. You can make more than one copy and modify each one so it has its unique specific format. Then, in each template copy, you’ll add a PHP comment at the top of the file as outlined here: e.g.
then a second layout template could have:
|
|
Hi Josh, I am currently struggling with one issue though. For an event, I am retrieving an $event object (EEH_Event_View::get_event($post->ID)), from there I would like to retrieve the Datetime(s) for that event (I ony have one per event) and then the tickets available for that Datetime. The goal being the iterate through the tickets available and pull out the price for each. I am struggling with this and I seem to be getting back an empty array when I instantiate the $tickets object… $event = EEH_Event_View::get_event( $post->ID ); I am wondering, am I doing this the right way and/or is event status (upcoming, etc.) affecting this return? Thanks, |
|
Hi Tim, The event status won’t affect the above, or at least, an event status of upcoming wouldn’t, however, what you have described that you want to do differs from the method you are using.
You have an EE_Event object, but then you skip most of the above and just go for an array of tickets using a helper method, ultimately the end result would be that you have an array of available tickets and that’s likely exactly what you need, however the code above references a DateTime:
Which unless you’ve set up outside of the above code (which wouldn’t really make sense) will not work. Using the helper method is fine if that’s what you want to use, it’s just a little different from your post. You’ve mentioned:
Have you confirmed that you are in fact getting an empty array back from the above call? Personally I recommend using Kint as its much nicer to view the objects within it, I personally use: https://en-gb.wordpress.org/plugins/kint-debugger/ Then you’d wrap
Then that code runs you’ll get a much nicer debug output than print_r/var_dump etc. If you are getting an empty array we can work through some more troubleshooting steps. The other option is to use the methods directly available on the |
|
Hi Josh, Thank you for the additional information. Some of that makes sense, and some does not, due to my inexperience with the product. Would it be possible for you to give me a rough example of how you would put that together? I will attempt to pseudo-code what I am looking to do… $event = EE_Event(post->ID) Not sure if that makes sense, but seemed like the most efficient way to convey what I am looking to do. I understand coding, but not PHP of the Event Espresso structure. I can muddle my way through the PHP if you can help me with a starting point. Thanks, |
|
What you have is most of the way there, except that you’re using So you want an array of ticket prices by the time you’ve finished? E.g That’s what you’ve asked for about but that seems a little strange so I’m not sure if that is what you need? I’ll happily give you an example:
Pulls the event object for the current post. The above helper method (This |
|
Hi Josh, It occurred to me, maybe I should clarify exactly what I am hoping to do…in plain English! lol For any single event, I will have one date/time for that event, I will have two tickets for that event(date/time), potentially more. One ticket would be based upon single occupancy lodging, and one ticket would be based upon double occupancy lodging. I want to be able to look through all the tickts that are available for an event, so I can grab the price for each of the tickets and display it elsewhere in a single event listing. Thanks, |
|
Hi John, Just got your post as I was typing my clarification…I think what you sent is exactly what I am after. I will check it out and let you know! Thanks, |
|
Hi Josh, I added your code to my page and it is working… $event = EEH_Event_View::get_event( $post->ID ); foreach( $tickets as $ticket ) { d($ticket_prices); } I added in Kint as you suggested and it is showing me that… d($tickets); is an empty array… d($event); is showing me the correct event though… Confused about that? Thanks, |
|
Can you link me to the event in question on your site, please? |
|
Hi Tony, Here is the event on my site… https://softliteworkshops.com/events/ws-2020010901/ New code is not there, it is on internal dev site…I can push it there if you want… Thanks, |
|
Hi Tony, I went ahead and put Kint on the production site and push the new code out there as well. Figured that would make it easier for you to inspect the objects in question… Thanks, |
|
Hi Tony, I have inspected multiple events, as they are all sharing this code (coming from single-espresso_events.php in a child theme) and all are returning an empty array… Thanks, |
|
For this event: https://softliteworkshops.com/events/ws-2020010901/ Your tickets are not active, they show as upcoming… meaning they are not ‘available’ for purchase and the above method will not return those. The above method is only going to return ticket with a TKT_start_date <= now AND the TKT_end_date >= now, meaning your tickets are available for sale. Do you want the tickets available on an event regardless of their status or are you displaying the price when they become available for purchase? |
|
Ironically I asked that question at the top of this post…was upcoming an issue? So I guess now we know it is… I would like to get the ticket prices either before they are on sale, or while they are on sale… Thanks, |
|
What you actually asked, is if the event status would affect anything, which is not the problem here, the ticket status is. The event and ticket status are completely separate and your code specifcially checked for an event status (sold out), nothing was mentioned about upcoming tickets 🙂
Then you’ll need to use EE_Event model directly, something like:
Will pull all tickets saved within an event. |
|
Hi Tony, I thought that’s what I was asking…I guess my lack of understanding of the core internals is really hampering what I am trying to do here! lol My apologies for the miscommunication… Long story short, I updated to code to include the new constructor you just provided an I indeed now see my tickets! Thank you all for your excellent support today!!!!! |
|
No problem, I’m glad that worked for you. I highly recommend you read over the docs on the model system: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System The models can get all of the information you need and if there isn’t a method already available to pull what you need it’s simple enough to pass where conditions to something like |
|
The support post ‘Styling the Event Page’ 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.