Calendar Widget

This topic contains 3 replies, has 3 voices, and was last updated by  Stephen Harris 10 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7267

    Hey Stephen,

    Just bought Pro and am loving everything!

    I’m wondering how to make a few changes to the calendar widget.

    1. Change the tfoot text to say “Next” and “Prev” instead of the month abbreviations
    2. Change the day abbreviations in the thead to “Mon, Tues, Wed…” instead of “M, T, W”

    I tried messing around to make this work, but was wondering if you had done this before and have a solution?

    Thanks.

    pach16
    #7280

    I’m also interested in editing the layout of the widget in a way that can’t be done with CSS I’d like to move the next previous functions into the head of the table and have arrows instead of text. I can see that editing class-eo-calendar-widget.php would allow for this, but that would change with updates. Any other suggestions or plans to make the widget an editable template at all? Thanks

    • This reply was modified 10 years, 7 months ago by  boldfish.
    boldfish
    #7282

    If you want to put the next/previous in the thead with css, just make the calendar widget position: relative;. Then set the tfoot to absolute positioning.

    pach16
    #7285

    Hi pach16, boldfish,

    As noted you can edit the calendar widget class, but changes will be lost with updates. There’s no wary round this currently… except by creating a new widget, which extends EO_Calendar_Widget. In this way you inherit all the methods, but you are able to copy and rewrite generate_output():

    class My_EO_Calendar_Widget extends EO_Calendar_Widget{
    
        function __construct() {
             $this->id_base = 'my_eo_calendar_widget';
             $this->name = 'My Events Calendar';
             $this->option_name = 'widget_' . $this->id_base;
             $this->widget_options = array( 'classname' => 'widget_calendar eo_widget_calendar' );
             $this->control_options = array( 'id_base' => $this->id_base );
        }
    
         static function generate_output( $month, $args = array() ){
               /*  ... copy from original class and adapt as required ... */
        }
    }
    function myplugin_register_my_eo_calendar_widget() {
         register_widget( 'My_EO_Calendar_Widget' );
    }
    add_action( 'widgets_init', 'myplugin_register_my_eo_calendar_widget' );
    

    Care should be taken to ensure this is declared after EO_Calendar_Widget. It should be ok in functions.php, but if its in a plug-in, ensure that it lives in a file which is included on plugins_loaded action.

    While I’ll consider using a template for the calendar for EO 2.4 (2.3 is being released over the weekend), the above method is probably the best.

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.