Home › Forums › Calendar Products › Events Calendar PRO › Changing the Single Event Page Layout
- This topic has 13 replies, 2 voices, and was last updated 9 years, 11 months ago by
Cliff.
-
AuthorPosts
-
May 20, 2016 at 5:02 pm #1117259
Joelle
ParticipantHello, my client chose to go with your calendar over the All-in-One Events calendar from Time.ly she’s been using for years. However, we’re struggling with the layout of the events page.
Is there any way to rearrange the page without dismantling the original plugin’s templates?
One of the key reasons for purchase was the “custom field” option, but now that content is buried way at hte bottom of the page with a big long ugly link instead of a nice tidy button or similar (she’d like it at the top)
And it would be great to otherwise hide/rearrange some of the data.
Is there information on doing this somewhere? 🙂 Thank you!
May 20, 2016 at 5:50 pm #1117270Joelle
ParticipantDerp, I found this, naturally. The obvious source of information. 🙂 I’m hoping this is what I need.
May 20, 2016 at 6:32 pm #1117278Joelle
ParticipantHello again. 🙂
I’m hoping someone can assist me in pulling out individual additional fields. I have two separate ones and I’d like to display them in separate places on the page. I know which files to edit, with the Themers Guide, but I’m unclear how to determine the extra fields I need based on this from the /srcs/views/pro/modules/meta/additional-fields.php file.
`<div class=”tribe-events-meta-group tribe-events-meta-group-other”>
<?php esc_html_e( ‘Other’, ‘tribe-events-calendar-pro’ ) ?>
<dl>
<?php foreach ( $fields as $name => $value ): ?>
<dt> <?php echo esc_html( $name ); ?> </dt>
<dd class=”tribe-meta-value”>
<?php
// This can hold HTML. The values are cleansed upstream
echo $value;
?>
</dd>
<?php endforeach ?>
</dl>
</div>I really appreciate your assistance here. Thank you!
May 20, 2016 at 8:11 pm #1117300Joelle
ParticipantWell, I guess a “nevermind” is in order because it looks like you don’t offer assistance with this per this thread. 🙁
I don’t understand why it tribe_get_custom_field was deprecated, it does *exactly* what I need it to do, but with your other method, it seems a lot more complicated to pull out one simple field.
So there’s no straightforward tip for how to get it to display just ONE field instead of the whole array despite it being available before?
Thanks. 🙂
May 20, 2016 at 8:24 pm #1117302Cliff
MemberHi Joelle. Thanks for your thoroughness. We hope you’ll get comfy with our calendar suite. 🙂
Yes, our Themer’s Guide (that you linked to) is our main help for these customizations.
Although I’m not exactly clear what you’re wanting, I can point you to the tribe_get_custom_fields() method (the deprecated method ends in ‘field’, not ‘fields’)
I also found get_custom_field_by_label() in /wp-content/plugins/events-calendar-pro/src/Tribe/Custom_Meta.php, which is actually the method used by the deprecated tribe_get_custom_field()
Please let me know if any of that helped and if I can be of further assistance.
May 20, 2016 at 10:25 pm #1117327Joelle
ParticipantHi Cliff!
I want to show just one of my additional fields, not the full array, which is what happens with tribe_get_custom_fields.
The deprecated snippet actually does what I want. I’m not understood on why they deprecated it without offering a comparable solution to displaying a single custom field.
I hope that makes it clearer. 🙂 thank you for responding!
May 21, 2016 at 8:17 pm #1117487Cliff
MemberJoelle,
I believe get_custom_field_by_label(), mentioned previously, is exactly what you want.
Did you try using it yet?
May 21, 2016 at 8:26 pm #1117489Joelle
ParticipantI did, it gives me a fatal error:
Fatal error: Call to undefined function get_custom_field_by_label() in /home/knitagog/public_html/stage/wp-content/themes/fibrespacesixteen/tribe-events/single-event.php on line 51
May 21, 2016 at 8:34 pm #1117492Cliff
MemberPlease share your full code snippet for review.
May 21, 2016 at 8:41 pm #1117493Joelle
ParticipantSure thing. I’m not a php wizard, I’m really just doing my best. 🙂
<?php if ( custom_field_by_label('Instructor') ) : ?> <div class="tribe-events-instructor"><strong>Instructor:</strong> <?php echo custom_field_by_label('Instructor'); ?></div> <?php endif; ?>May 21, 2016 at 10:24 pm #1117512Cliff
MemberThanks for that. There were several issues, most importantly: custom_field_by_label isn’t the name of the function (it was missing starting with get_) and it’s technically a method because it’s a function in a PHP class.
Long story short, try this out 😉
https://gist.github.com/cliffordp/4912b6e0e5ffc67e312264336f1218b8
Let me know if it works for you.
May 22, 2016 at 8:08 am #1117564Joelle
ParticipantThanks, Cliff. We’ll give that a try. It seems kind of silly to have so many lines of code to do one simple thing that was working and still works. I’m not a super programmer or anything, so Im assuming there was a good reason for it, but it seems like less is more.
Anyway, I’ll give it ago. Thank you! I appreciate your help. 🙂
-
This reply was modified 9 years, 11 months ago by
Joelle.
May 22, 2016 at 11:57 am #1117599Joelle
ParticipantThe solution, which was sussed out with a friend of mine, is this:
At the top, this:
$events_label_singular = tribe_get_event_label_singular(); $events_label_plural = tribe_get_event_label_plural(); $event_id = get_the_ID(); $eventFields = tribe_get_custom_fields();Then, where I require the instance of a singular custom field:
<a href="<?php echo $eventFields['Register Now']; ?>" class="register_now">Register Now</a>This works just great.
-
This reply was modified 9 years, 11 months ago by
Joelle.
May 23, 2016 at 6:36 am #1117727Cliff
MemberI’m glad you got a solution you’re happy with.
$eventFields = tribe_get_custom_fields(); echo $eventFields['Register Now'];is the same as
echo Tribe__Events__Pro__Custom_Meta::get_custom_field_by_label( 'Register Now', $event_id );If you’re going to be pulling more than one Additional Field in your implementation, the way your friend did it is more performant because of not having to run Tribe__Events__Pro__Custom_Meta::get_custom_field_by_label() multiple times.
However, the additional code I included is probably desirable and should be considered in your final implementation. For example, you probably don’t want to output a blank value or get a PHP error because the value is an array and not a string.
Anyway, I’ll close this ticket. Feel free to open a new one if you have another situation come up.
Have a great day!
-
This reply was modified 9 years, 11 months ago by
-
AuthorPosts
- The topic ‘Changing the Single Event Page Layout’ is closed to new replies.
