How to customize the calendar template or create your own?

I'd like to rearrange, remove, and add elements to the Calendar template file. I was also wondering how I could make a custom template as well, I attempted to make a new template in the default-templates folder in the same spot, but it doesn't get picked up.

Thanks

  • Div Truth

    Try the WordPress way, just simply name the file type in the theme directory page-slug-of-page.php

    Also I've manually told pages which template to use before using a snippet like this:

    add_filter( 'page_template', 'custom_page_template' ); //make sure function name is the same
    
       function custom_page_template( $page_template ){
           if ( is_page( 'page-slug' )) {
               $page_template = page-custom-calendar.php';
           }
           return $page_template;
       };

    Once in there you can make any loops you need to make your calendar. I've just goggled php calendars before and then modified the code snippet from there to work with my custom template.

    Hope that helps!

  • mtpultz

    Hi Vaughan,

    That didn't work for me, which probably means i didn't explain what I was trying to do very well.

    I found the code in class_eab_template.php within get_single_content($post, $content=false). I've been linking to this page from the events listing widget.

    function rearrange_single_event_page() {
    	// copy code within $new_content, add and rearrange its layout
    }
    add_filter('eab-events-after_single_event', 'rearrange_single_event_page');

    Cheers

  • mtpultz

    Hi Vaughan,

    I've played around with this, but I can't figure out how to directly change the way content is laid out using a different function invocation or template file. I've only been able to do it by basically overwriting the function myself with regards to the markup. Is there a simpler way of doing this so the plugin can be updated with newer versions?

    I'm trying to change the way the content is displayed in get_single_content() in class_eab_template.php.

    Thanks

  • Vaughan

    Hi @mtpultz,

    Extremely sorry for the delay on this. I'm not fully sure how to do this myself. Did you manage to figure this out? I have flagged the developer for some feedback on this, hopefully he should be able to point you in the right direction.

    Incidentally though, in your function above, did you try setting a higher priority?

    add_filter('eab-events-after_single_event', 'rearrange_single_event_page', 99);

    Thanks

  • Vladislav

    Hello,

    As for the custom template, you may want to copy over a set of template files from one of the directories under plugin's defaut-templates directory, to your theme's root directory. Basically, you will want to have a file named archive-incsub_event.php for "archive"-type view (e.g. a calendar view, or an events list view) and/or one named single-incsub_event.php for single event view (i.e. "this particular event"-type of view). If you implement these templates, you don't even have to use the Eab_Template:: get_single_content(...) calls, as you can use any other template function to rearrange the view how you want it - also, you can also use a number of low-level methods from Eab_EventModel-type objects if you're unhappy with the way the default templating class works. As for the filter we mentioned here ("eab-events-after_single_event"), it's worth noting that it's used to add content *after* most of the main output from Eab_Template:: get_single_content call - it's empty by default, but add-ons may use it to add some additional things. Because of that, you can't really use it to rearrange the events output, but custom templating can hopefully help with that instead.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.