Event Categories show up twice when translated (for month/single-event.php)

Home Forums Calendar Products Events Calendar PRO Event Categories show up twice when translated (for month/single-event.php)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1254429
    Mister
    Participant

    Hi,

    I discovered the following issue: When setting up Events Calendar with WPML (as described in your docs: https://theeventscalendar.com/knowledgebase/setting-up-the-events-calendar-with-wpml/) and when then capturing new events which have an event category, which is also translated, then they show up twice on templates using the month/single.php template.

    Steps in detail:

    1. Set up a fresh WP install
    2. Install Events Calendar, and WPML.
    3. Set up 2 languages in WPML and configure WPML as described in the docs
    4. Create a new Event Category in language 1.
    5. Go to language 2 and create a translation for the Event Category (create a new Event Category in language 2 and select that it is a translation of the previously created category in language 1)
    6. Now create the venue, organizer and event in the two languages. Set the category respectively
    7. Copy the “/wp-content/plugins/the-events-calendar/src/views/month/single-event.php” to “/wp-content/themes/yourtheme/tribe-events/month/single-event.php”
    8. Add the following code to single-event.php (the use case is to show categories in month view (e.g. tooltip etc) – see attached file:
      echo tribe_get_event_categories( $event_id, array(
      		'before'       => '',
      		'sep'          => ' ',
      		'after'        => '',
      		'label'        => 'Categories', // An appropriate plural/singular label will be provided
      		'label_before' => '',
      		'label_after'  => '',
      		'wrap_before'  => '<dd class="my-widget-event-categories">',
      		'wrap_after'   => '</dd>',
      	) );
    9. go to the month view, and you will see it twice

    This does not happen on the single view of the event (i.e. if you click the event, then you see the category only once). Both templates use tribe_get_event_categories which uses at the end get_the_term_list.

    How can this be fixed?

    #1254975
    Andras
    Keymaster

    Hello Mister,

    Thanks for using our plugins and welcome to the forums!

    Wow, thank you for the detailed guide and testing, this is a great starting point!

    I will need some time to investigate this, I ask for a bit of patience. We’ll get back to you soon.

    Thanks,
    Andras

    #1255346
    Geoff B.
    Member

    Good afternoon Mister,

    At my colleague Andras’ request, I will be stepping in this thread as well to help with the customization you are trying to implement.

    Just to make completely sure I am testing this out in a similar environment, could you please provide us with your complete system information in a private reply using the instructions found in the following link?

    https://theeventscalendar.com/knowledgebase/sharing-sys-info/

    Have a great day!

    Geoff B.

     

    #1255361
    Mister
    Participant

    This reply is private.

    #1255364
    Mister
    Participant

    Please note one additional important information:

    This issue appears only when the event category of each language is linked together as translation (step no. 5 in the setup instructions listed in the first post). If you just create the category in each language without marking them as translation, then it doesn’t show up twice.

    However, to properly set up the categories, they should be marked as translations. If this is not done, the language switcher cannot be used on the categories, because WPML doesn’t find a translation for the category.

    #1255792
    Geoff B.
    Member

    Good morning Mister,

    Thank you so much for writing back and for providing additional information.
    However, for some reason, it appears that the the Events Calendar plugins system information (mostly the version number) is missing ?

    In any case, thanks to that I have been able to reproduce the issue of the custom taxonomy (in this case Event Categories) being duplicated.

    A quick research has shown that this is sometimes the case with WPML:

    Just to set expectations, as you might know, the scope of our support is mostly to get our customers started on the right track and to help them in case of issues.

    We unfortunately do not provide complete support for customization.

    With that in mind, I would still like to ask our WPML coding expert to see if there is not some filter that this needs to be run through to work.

    In the meantime, if you get a chance, could you see if any of the WPML threads above help out?

    Have a good weekend,

    Geoff B.

    #1256586
    Mister
    Participant

    Hi Geoff,

    I can see a couple times in that system info the events calendar version number, which is 4.4.4.

    I understand the scope of the support, but I think it is important here to find out whether this is a WPML or an Events Calendar issue, and I hope that your WPML coding expert can figure it out.

    What really makes me nervous is, that what I have written in my first post at the very bottom. While with the customized template, the taxonomy shows up twice, on the single event view it doesn’t. And both templates call the same functions ( tribe_get_event_categories which then calls get_the_term_list ).

    Therefore we cannot say that we have the issue in general that the taxonomy shows up twice (like it may be the case in one of the WPML threads you posted).

    #1257068
    Geoff B.
    Member

    Good evening Mister,

    Thank you for your answer.

    To clarify, I was mostly referring to the fact that it appears you are the proud owner of a the Events Calendar Pro license. I did not see traces of that plugin or its version number in the previous system information you shared.

    I apologize for not making things clearer. This is my bad.

    I understand the scope of the support, but I think it is important here to find out whether this is a WPML or an Events Calendar issue, and I hope that your WPML coding expert can figure it out.

    I absolutely agree with you and hopefully we are able to do just that.

    The bad news is that after following-up, I found out that our residential WPML coder is unfortunately on work leave until April.

    For that reason, I have also reached out to our most senior Dev staff with the hopes that they can provide some form of explanation.

    What really makes me nervous is, that what I have written in my first post at the very bottom. While with the customized template, the taxonomy shows up twice, on the single event view it doesn’t. And both templates call the same functions ( tribe_get_event_categories which then calls get_the_term_list ).

    Here again I am in complete agreement.

    My hunch is that perhaps this has to do with a certain filter not being applied in the way you have integrated it to your custom template.

    Perhaps this is due to the fact that this function is not called directly in any of our default views, but rather it’s called in:

    1. /wp-content/plugins/the-events-calendar/src/functions/template-tags/general.php
    2. /wp-content/plugins/the-events-calendar/src/views/modules/meta/details.php  which is called “indirectly”

    I should be able to provide more details on this topic tomorrow.

    Thank you for your understanding.

    Best regards,

    Geoff B.

    #1257866
    Geoff B.
    Member

    Good evening Mister,

    I ran this by our other coding wizards and was asked to open a specific ticket for this, since there was no obvious reason for that behaviour.

    Unfortunately, I cannot commit to a date at this point. But stay tuned, you will be contacted as soon as the analysis is completed.

    I am also keeping a follow-up on this to run it by our WPML coder when he returns during the first week of April.

    I wish I had a better answer for you, but for now it’s the best one I have.

    Thank you for your understanding.

    Best regards,

    Geoff B.

    #1269516
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    #1313638
    Geoff B.
    Member

    Good evening Mister,

    Thank you for hanging in there.

    It took a while, but I finally heard back from our Dev ninjas.
    For one thing, I do believe that the issue is gone with the latest version of our plugins and of WPML.

    In month view – though not in single event view – by the time tribe_get_event_categories() is called (using the sample template override) the object term cache for the event category contains duplicates.

    One way to work around this would be wiping the cached terms before calling tribe_get_event_categories() – example (note the addition of a call to wp_set_cache()):

    wp_cache_set( $post->ID, false, Tribe__Events__Main::TAXONOMY . '_relationships' );

    echo tribe_get_event_categories( $event_id, array(
    'before' => '',
    'sep' => ' ',
    'after' => '',
    'label' => 'Categories', // An appropriate plural/singular label will be provided
    'label_before' => '',
    'label_after' => '',
    'wrap_before' => '<dd class="my-widget-event-categories">',
    'wrap_after' => '</dd>',
    ) );

    Let me know if that helps.

    Have a great day!

    Geoff B.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Event Categories show up twice when translated (for month/single-event.php)’ is closed to new replies.