• Resolved heyvern

    (@heyvern)


    Have not been successful adding my own custom template to the widget for the overview so was wondering how I might add this alternative template? Yes, even if it means changing the core files or possibly adding in hooks or other gizmos to the plugin.

    Currently there are only table and list (description list) templates. I understand description lists are suited to this content but I would still prefer the option to create my own templates.

    For example, I have a nice styled layout done in CSS with a compact horizontal display, background colors and CSS “border” arrows on day headings that looks awesome and works great.

    Initially I styled this using the existing classes for the list dl, dd, dt tags. However, one drawback is the way the description lists are structured. Without a “wrapper” around each “day” block I can’t keep them together as the screen changes size.

    I simply modified the current “list” template (overview-list.php) to change everything from dl, dd and dt to <div> tags. I could then add another div wrapper around each day to keep them together.

    Of course… once I update the plugin I will have to copy those changes back in… it’s a pain but just one file in my situation.

    My thought is how difficult to create my own “template” that I can select in the widgets? I fiddled with the files and tried to do this on my own without success yet.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author janizde

    (@janizde)

    Hi @heyvern,
    I have already thought about some kind of Template API to make it possible to add own templates besides table and list.

    What you could do to add a third one (e.g. Overview):

    1. Add a template file ‘overview-{your-slug}.php’ in the views/shortcode directory.
    2. Add your new option to the $validAttributeValues in the Shortcode class.
    3. Add an entry for your template in the $templateMap (in the method Shortcode\Overview::shortcode).
    4. For use with Widgets, add another option in the Widget\Overview module.

    These changes will also be lost after update.

    I will add ways to add your custom templates without them being deleted on update.

    Thanks for the feedback.

    Plugin Author janizde

    (@janizde)

    Plugin Author janizde

    (@janizde)

    Btw: you can also use the op_shortcode_template filter (https://github.com/janizde/WP-Opening-Hours/blob/master/doc/filters.md#op_shortcode_template) but this doesn’t add the option to the Widget, just always replaces the template path.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Opening Hours – add custom template’ is closed to new replies.