• Hi,

    thank you for this great plugin.

    I did implement three minor chnages to ics-calendar.php to have multiple templates supported. Beside the month view i did need a list view used in sidebars.

    Line 162 changed: include(dirname(__FILE__) . ‘/templates/’.$args[‘template’]);

    Line 182 inserted: ‘template’ => ‘calendar-month.php’,

    Line 190 inserted: ‘template’ => $template,

    With these little changes the plugin now supports multiple templates which can be defined with the new shortcode parameter “template”, which defaults to ‘calendar-month.php’ when left out.

    It would be great if you would think about integrating this changes into your plugin.

    Thank you

    Dieter

    PS: If you are interested, i can send you my calendar-list.php template file.

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

    (@room34)

    Thanks for this suggestion! I’m making some updates to the plugin and will be including some configurable options including different view templates in a future version.

    There’s a new version out today that includes some bug fixes and enhancements. You’ll want to be sure to copy in your enhancements when you update.

    Thanks!

    I had the same challenge, and was forced to modify ics-calendar.php to achieve it. Here what I came up with:

    // Render template
    $template_dir = $args['template_dir']??(dirname(__FILE__).'/templates/';
    switch (@$args['view']) {
         case 'list':
              include($template_dir  . 'calendar-list.php');
              break;
         case 'month':         
              include($template_dir  . 'calendar-month.php');
              break;
         default:
              $try_file = $template_dir  . 'calendar-'.$args['view'].'.php';
              if(!empty($args['view']) && file_exists($try_file)){
                   include($try_file);
              }else{
                   include($template_dir  . 'calendar-month.php');
              }
              break;
    }

    (Note that this version also allows for template directories to exist outside of the plugin’s directory so that the contents of the plugin’s directory can remain unmodified.)

    Plugin Author room34

    (@room34)

    That’s a good idea. What type of view were you using this to add? (I’m trying to gauge interest in adding more views besides Month and List.)

    I created a few variations of a free/busy calendar, where the colors of the days change depending on the all-day events (used for displaying availability of a vacation rental). One view is tiny and contains no text (just color codes) suitable for placing in a sidebar, two views show each month in a single row (one tiny and one larger and contains text), and one “normal” calendar. On each, additional rows are added to each week for each distinct event location. This allows me to cleanly display information from one or more rental properties on the same calendar.

    Incidentally, I also tweaked the js so that a configurable number of months can be displayed at a time and they update correctly when a new month is selected from the dropdown.

    • This reply was modified 5 years, 11 months ago by cragmonkey.
    Plugin Author room34

    (@room34)

    Thanks… those are great examples! I’m finding this plugin is being used for things I never would have imagined when I created it.

    I don’t have a ton of time at the moment to do much new development on this since it’s not bringing in any money (though I’m considering creating a paid “Pro” version so I can devote more time to it), but I’ll look at incorporating better support for creating customized templates like what you’re doing here.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding multiple template support’ is closed to new replies.