Home › Forums › Calendar Products › Events Calendar PRO › Add custom fields to tooltip in month view
- This topic has 9 replies, 3 voices, and was last updated 10 years ago by Barry.
-
AuthorPosts
-
April 7, 2014 at 11:58 am #129073KenParticipant
How would one go about adding the info from a custom field to the tooltip.php file for the month view?
April 7, 2014 at 4:05 pm #129250BarryMemberHi – great question.
As of 3.5 we’ve taken a new approach with regards to tooltips – largely to provide more flexibility with responsive layouts – and beyond recommending you check out the Themer’s Guide it’s probably well worth reading the fairly extensive documentation contained within the month/single-event.php template itself (and cross reference it with the new month/tooltip.php template).
Does that help?
April 7, 2014 at 4:17 pm #129265KenParticipantNot Really.
I have already looked at both of those php files before posting here. I do not see how to go about updating them for the custom fields. I have already placed them in my corresponding theme folder.April 8, 2014 at 9:51 am #129548KenParticipantHi Barry,
After looking at it fresh this morning, I think I was overthinking things yesterday.
The field I wanted to add is called “Time Zone” in the ECP settings. So I was trying to figure out how to add in this string with the[[ myString ]]
samples that were in the single-event.php file. By doing something like this:$additional_data = array(); $zone = tribe_get_custom_field('Time Zone'); $additional_data['zone'] = $zone; echo tribe_events_template_data( $post, $additional_data );
Then I realized I could just add in the php I needed to the tooltip.php file where I wanted the data to appear.
So I added this in:<?php $zone = tribe_get_custom_field('Time Zone'); if(!empty($zone)) { echo ' (' . $zone . ')' ; ?>
So I have it working now. But I am still not clear on the bracket code and how to get that to work instead. Am I doing it correctly? Just because it works doesn’t mean I am doing it correctly.
April 8, 2014 at 11:49 am #129618BarryMemberWell, tooltip.php is a PHP template but it is ultimately used to generate a Javascript template.
So, you only get one chance to modify it server-side and if you echo out a piece of text (in your case, the time zone custom field) that means it will be used in every tooltip (ie, the same timezone will appear in all tooltips). Conversely, if you use a template variable like [[=title]] this can be populated appropriately within the browser environment – that’s why this approach is used.
Does that make more sense?
April 8, 2014 at 12:02 pm #129630KenParticipantAh ok…I didn’t check that against other zones, I thought it was just too easy.
So back to the drawing board for me :0)So I’m back to the question how do I create that template variable?
Where does the code go so that[[=zone]]
will work when I place it in tooltip.php?
I’m just not getting it.April 8, 2014 at 2:51 pm #129815ShaunParticipantI am looking to do something similar too. The documentation online and in the single-event.php are great at explaining how it works, but not how to do it.
How can we add additional data to be generated in json? I assume tribe_events_template_data() comes into play…but where can we add new strings? In functions.php?
April 8, 2014 at 4:28 pm #129838KenParticipantJesse, I got it worked out.
These changes go inside the month/single-event.php I put mine at lines 23-25$additional_data = array(); $somestringname = tribe_get_custom_field('Your Custom Field'); $additional_data['bracketname'] = $somestringname;
Then at line 194 change the “data-tribejson” part to include additional_data like this:
data-tribejson='<?php echo tribe_events_template_data( $post, $additional_data );
Then in the month/tooltip.php add your brackets and the name you chose
[[=bracketname]]
I hope that helps and makes sense.April 11, 2014 at 9:27 am #131202ShaunParticipantThanks!!
April 17, 2014 at 7:21 am #135107BarryMemberWell done all 🙂
-
AuthorPosts
- The topic ‘Add custom fields to tooltip in month view’ is closed to new replies.