• Resolved djbo5a5

    (@djbo5a5)


    Hello,

    I have tried to update and copy template files to the directory “ics-calendar” in my theme directory, but it doesn’t work. Is it possible to localize templates?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author room34

    (@room34)

    The plugin does not currently support localizing templates in this way.

    Can you describe the types of changes you’re hoping to make? I might be able to suggest an alternative approach.

    As it is currently written, I don’t think it would be a good idea to try to localize the templates. Plugins that support this (e.g. WooCommerce) are built with a lot more hooks and also with their functionality more compartmentalized outside of the templates. As it’s presently written, there’s a bit more functional code included in these templates than there should be to support easily localizing the templates.

    In other words: there’s a fairly high risk of breaking functionality if you edit the templates, and also there’s a very high probability that you’d need to substantially rework your customized templates with upcoming plugin updates.

    This may be the impetus I need for refactoring some of this functionality, and pulling more of the code logic out of the templates.

    For now though I would recommend that you avoid editing templates. Most of the types of customizations other users have wanted to do have been achievable using just CSS and occasionally jQuery.

    Thread Starter djbo5a5

    (@djbo5a5)

    Ok, thank you!

    Plugin Author room34

    (@room34)

    I would add this though… with the caveat that you may have to experiment a bit.

    The Pro version includes additional templates, and in order to do that, I made the core plugin support external templates. It won’t automatically swap in localized versions by placing identically named template files in your theme, but with a bit of extra code you can create your own uniquely named templates and put them wherever you want in your theme.

    This hinges mostly on the r34ics_display_calendar_render_template action. It accepts 3 input parameters: $view, $args, and $ics_data. In order these are a string with your view name (must match view from the shortcode), an array of all of the arguments in the shortcode, and an array of the parsed calendar data ready to be manipulated by the view.

    Inside your add_action() function you’ll need use an include() or locate_template() or similar to retrieve your custom template. You’ll also probably want to use one of the existing templates as a starting point.

    Unfortunately this is not the whole story. There are several spots within the R34ICS::display_calendar() method where there you’ll find switch (@$view) { } and each of these has some special view-specific handling for setting certain values. They all have a default case with additional hooks. In many cases, you can use those hooks and just copy the code from one of the cases for the built-in views. But key elements of the logic won’t be set without these, and your view won’t display properly as a result.

    Anyway… maybe this will help you to experiment a bit. Ultimately I do plan to add more structured support for custom templates and localization… it’s just not there yet.

    Thread Starter djbo5a5

    (@djbo5a5)

    Thanks for the clear answer. Actually, I have found the solution without changing templates, the only thing which I didn’t like was navigation arrows, I wanted a bit more modern look and I changed them with jQuery. By the way, I have tested the plugin with Google calendar feed and everything works well. Will it work with boooking.com and Airbnb ICS feed? I can’t test them right now.

    • This reply was modified 4 years, 2 months ago by djbo5a5.
    Plugin Author room34

    (@room34)

    I havne’t specifically tested it with booking.com or Airbnb myself, but I know a lot of people are using it with Airbnb. Not sure about booking.com. But as long as they offer a public (meaning you don’t have to be logged in to access it) ICS feed URL, you should be fine.

    Thread Starter djbo5a5

    (@djbo5a5)

    Awesome, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to override templates’ is closed to new replies.