Support

Home Forums Event Espresso Premium templates?

templates?

Posted: May 23, 2017 at 5:00 pm

Viewing 15 reply threads


CornellPump

May 23, 2017 at 5:00 pm

Hi, I have EE4 and one thing I can’t seem to find information on is whether I can make a custom single event view template. I want a different template for certain types of events to control what is shown to potential registrants. Is this possible? I see info on this with EE3, but EE4 seems to steer everything to global css.


Tony

  • Support Staff

May 24, 2017 at 6:37 am

Hi there,

Global CSS?

With EE4 events are a custom post types and the output is controlled via your theme. So generally speaking the output for a single event will be done using single.php, EE hooks into the_content and adds the event details there.

You can take over the output specifically for EE events by creating your own single-espresso_events.php template file and then controlling the output from there. We have an example of how you can create your own template files within:

\event-espresso-core-reg\public\Espresso_Arabica_2014\

For info on the templates that load take a look here:

https://gist.github.com/lorenzocaum/0a35fe4997992fdb1dc5


CornellPump

May 24, 2017 at 8:48 am

re: “global CSS” – not an official term; just in reference to what I found about customizing event views for EE4 by using a copy of the espresso_default.css file and making changes that affect all events. (IE when looking for ways to not show the pricing, the suggested option is to do this with CSS).
If I get what you are saying correctly, I can make a post template that then includes whatever CSS I need for that particular event type, and select it as the template for that event – is that correct?


Tony

  • Support Staff

May 24, 2017 at 9:10 am

Is it purely CSS changes your looking to make?

Creating a page template purely for CSS changes is overkill really, it can work, but you can just include the CSS within either a child themes styles.css file or use a custom CSS plugin


CornellPump

May 24, 2017 at 9:22 am

Tony,
Here are the changes I want to make – maybe you have some suggestions on how to do this.
1. For events that are free, to not show the event price column on the ticket selector and change the button text to “RSVP Now”; for all paid events the price is listed and the button keeps the default text.
2. To not show the price and total on the ticket details section that shows on the registration page, for free events only.
3. To change the heading on the registration page for free events only, from “registration checkout” to “RSVP” or “RSVP Information”


CornellPump

June 1, 2017 at 10:51 am

Any ideas/suggestions on this welcome, please.


Josh

  • Support Staff

June 1, 2017 at 12:30 pm

An idea/suggestion you might consider from the documentation:

https://eventespresso.com/wiki/show-ticket-price-zero-free/


CornellPump

June 1, 2017 at 3:42 pm

Hi Josh, There might be a way to apply that idea. Thanks; I had looked all through the documentation and missed that. I would still need a separate template with probably some javascript to change the text I want to change though, right?


Josh

  • Support Staff

June 2, 2017 at 9:17 am

I do not think you need a separate template with some JavaScript to change the text. The text that you want to change can be changed by using a filter hook, similar to the example I shared with you. In fact, in that example you can add additional code within the conditional such as:

add_filter(
 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
 function(){return 'RSVP now';}
);

Note that the above will change the button text whenever there’s a free ticket included within the event, so you may prefer to handle that another way.


CornellPump

June 5, 2017 at 8:51 am

OK- thank you! I think this will be much easier.


CornellPump

June 21, 2017 at 1:14 pm

Hi Josh,

I added the filter that you suggested for the button text change and it is changing the text for all events, not just free ones.
http://www.cornellpump.com/events_archive/pump-school-2018-test-event/


Josh

  • Support Staff

June 21, 2017 at 1:52 pm

Did you wrap the code in a conditional, like I earlier mentioned? You’ll need to wrap the code in a conditional or it will apply to all events.


CornellPump

June 21, 2017 at 3:04 pm

Hi Josh, I did do a conditional but it appears to not be working right. I’m a novice in PHP (esp. wordpress-specific coding). here is the code:
function convert_zero_to_free( $amount, $return_raw ) {
if ( ! $return_raw || ! is_admin() ) {
$amount = $amount == 0 ? __( ‘No Cost’, ‘event_espresso’ ) : $amount;
}
return $amount;
}

function format_reserve_button($amount, $reserve_button){
if ($amount = ‘No Cost’){
$reserve_button=’RSVP now’;
}
else {
$reserve_button=’Register Now’;
}
return $reserve_button;
}

add_filter( ‘FHEE__EEH_Template__format_currency__amount’, ‘convert_zero_to_free’, 10, 2 );

add_filter( ‘FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text’, ‘format_reserve_button’, 10,2);


CornellPump

June 21, 2017 at 3:28 pm

I think I am reading the use of the $amount variable wrong; I’m going to work on this a bit and get back to you.


Josh

  • Support Staff

June 21, 2017 at 4:16 pm

The $amount variable doesn’t actually get passed to the
FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text filter hook.

You can replace the above with something like this instead:

https://gist.github.com/joshfeck/150850af75a79932c533aec061868260


CornellPump

June 21, 2017 at 4:29 pm

That worked perfectly. thank you.

Viewing 15 reply threads

The support post ‘templates?’ 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