Custom field as the event link

Home Forums Calendar Products Events Calendar PRO Custom field as the event link

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30260
    Javier
    Participant

    Hi. I am trying to create a single multi-day (non-consecutive days) event. It would be perfect if the plugin could exclude some dates from the pattern but, at least for now, can’t be done with recurring dates…

    But because it is quite urgent to me to get it done, I am trying to get the same result taking a different approach.

    Here is my scenario. It’s a five day training course with non-consecutive days. A single event from 2013-01-14 to 2013-01-23, but training days are only the 14th, 16th, 18th, 21st and 23rd. So I want it to show in my calendar just these five days instead of all ten days. As I said, recurring dates doesn’t do the job, because it treats each day as a different event and that’s not what I want, so here is my idea and what it would work for me:

    I set manually every single day as a separate single event, all 5 with the same title and descriptions.

    The first day (the 14th) is used as a reference because it will contain the register form for the training course. So in the calendar views I will need the rest of the days to point to this first day.

    My approach would be creating a Custom Field called i.e. ‘Reference Link’ and filling it up with the first day’s permalink.

    Then go for example to table-mini.php template and make an IF statement such as:

    “If custom field ‘Reference Link’ exists and is not empty, use it as the event link. ELSE use the tribe_get_event_link() function”

    I hope that makes sense… I am not a PHP expert so I am having a hard time trying to figure it out :/

    I would appreciate very much your help. thanks.

    #30272
    Jonah
    Participant

    Hey Javier,

    Sorry for the limitations on recurring events. We hope to improve the flexibility of this in the future. Your solution is a good one though. Let me see if I can help you. What I would do is use this plugin for your custom fields: http://www.advancedcustomfields.com/ – it’s way easier and more powerful than using WP custom fields. You can create the custom reference link field and have it only show for the tribe_events post type too! So what I did was just that, and then in the template, for instance I’m going to modify /wp-content/plugins/the-events-calendar/views/table.php for the big calendar, on line 133 you would change that to: http://snippi.com/s/9jzsbru – make sure to make a copy of /wp-content/plugins/the-events-calendar/views/table.php and place in an ‘events’ folder in your theme first too! Then if any event has a link input, the template will use that link instead of the event link. You could event possibly improve this by using a relationship or post object field to be able to select your reference post directly instead of copy/pasting the URL. You’re on your own with that one though 🙂

    Does this help?

    – Jonah

    #30286
    Javier
    Participant

    Thanks for the help Jonah!
    The trick works beautifully!! Although I am afraid it works only on the table.php file. Can’t get it to work on table-mini.php

    On line 137 I replaced the code with this one (http://snippi.com/s/kl1dnx2) without any luck, it doesn’t find the custom reference_link field…

    I read the ACF documentation about the get_field() function but can’t figure it out.

    Many thanks for your help.

    #30308
    Jonah
    Participant

    Hey Javier,

    You’ve got the right line number but try this code instead: http://snippi.com/s/kngfnfe

    I hope that helps!
    – Jonah

    #30319
    Javier
    Participant

    Thanks very much for the hint Jonah! Although your code didn’t work at first. There was missing the $post->ID parameter in the IF statement. Now it works perfectly (http://snippi.com/s/8x6xya9).

    Now I have full control over recurring dates for my training courses! thanks and keep up the good work!!

    Javier.

    #30323
    Jonah
    Participant

    Ooops, I forgot to add that. Glad you figured it out! Let us know if you need anything else.

    – Jonah

    #978375
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Custom field as the event link’ is closed to new replies.