Home › Forums › Calendar Products › Community Events › modifying additional fields location.
- This topic has 7 replies, 2 voices, and was last updated 7 years ago by Aaron.
-
AuthorPosts
-
April 5, 2017 at 8:23 am #1265031AaronParticipant
Hi.
We’re using community events and have added some additional fields.
When using the form on the front end of the site the additional fields come up at the bottom, is there any way to move the order of the fields so the appear above the event time and date?
Also, is it possible to use the additional fields to do if/else statements?
I’ve got two different radio options, home / away – I’d like to modify the template so that if = home, do something, else if = away, do something else.
I was using ACF to achieve this, but found out I can’t display the ACF custom fields for events on the front end form.
Thanks
April 5, 2017 at 8:29 am #1265034AaronParticipantIgnore the first question, I found another thread on how to modify the template in your child theme, got it working.
Would be good to know if I can do the if else statement using the additional fields.
Thanks
April 7, 2017 at 7:50 pm #1266904VictorKeymasterHi Aaron!
Great to hear you managed to change the order of the fields! This means you already know how to do a template override.
Now you could apply that same method to modify the additional fields with if/else statements with the custom.php template file located in /wp-content/plugins/the-events-calendar-community-events/src/views/community/modules/custom.php
You should copy that file and paste it in [your-theme]/tribe-events/community/modules/custom.php and then your are good to go.
Let me know how that goes and if you have any questions.
Best!
Victor
April 18, 2017 at 10:09 am #1271231AaronParticipantThanks for your info above Victor, and sorry for not replying sooner.
This was the code I was originally using for ACF on events, but as I can’t show them on the community form, I’m trying to swap them over to use Events additional fields.
<?php if( get_field('home_or_away_match') == 'home' ): ?> <h1>home game<br>vs <?php the_field('opponent'); ?></h1> <?php endif; ?>
I’ve recreated these custom fields in Events additional fields, event_type is a radio field type, and opponent is a text field…
So am looking for a way to check if the home or away field is “home”, and how to display one of the additional fields on it’s own.
I hope that all makes sense and you can help.
Thanks.April 18, 2017 at 8:23 pm #1271440VictorKeymasterHey Aaron!
Don’t worry about the delay.
First off, I do want to note that we are fairly limited in how much we can support custom development questions like this.
That said, I’d be happy to at least point you in the right direction as best I can.
If I understand correctly, you want to show the additional info for an event in different ways depending on the content of those additional fields. To do that, you would have to override the additional-fields.php template file located in /wp-content/plugins/events-calendar-pro/src/views/pro/modules/meta/
In there, I would suggest checking out the $fields variable by using print_r or var_dump like this:
<?php print_r($fields); ?>
Then you can modify the template to suit your needs. I hope it helps.
Let me know how that goes.
Cheers!
VictorApril 19, 2017 at 11:12 am #1271795AaronParticipantSorted, amazing, thank you!!
I used a slightly different bit of code to display all custom fields, then used the if statement to do something if it had the right content (from a radio custom field).
Learnt something new today that’s opened up a lot of options, so thanks for pointing me in the right direction!!
Very very happy.
April 19, 2017 at 12:13 pm #1271830VictorKeymasterHey Aaron!
That’s great! I’m so glad to hear you sorted all out. I appreciate you following up to let us know. Definitely keep us posted if any other questions come up and we’d be happy to help.
Good luck with your project!
Victor -
AuthorPosts
- The topic ‘modifying additional fields location.’ is closed to new replies.