[Customization – Event Calendar PRO] Multiple Templates for List Events Widget

Home Forums Calendar Products Events Calendar PRO [Customization – Event Calendar PRO] Multiple Templates for List Events Widget

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #833002
    kauffmaninc
    Participant

    Hi there,

    I’ve customized the default list-events widget per the online guides, and they’re working great (thanks for building in a method to do that, by the way).

    The issue I’m running into now is that I’d like to use the same widget on a different page, but I want the tweaks to *that* instance of the widget to be a bit different than the one I already have. So if I tweak the template/theme to work on the new page, I mess up the old page. Does that make sense?

    Is there a way to choose which template/theme the widgets use on a per-instance basis? Or is there perhaps a way to register a new widget that is identical in function, but which uses a different template file?

    Thanks in advance!

    #833580
    Barry
    Member

    Hi kauffmaninc,

    There is indeed a means of doing this.

    One is to set up a filter on the widget_display_callback hook provided by WordPress: this provides access to three parameters – the instance array, the widget object itself and the arguments array.

    Through one or more of those you can identify a specific instance of a widget and – by recording this in your code somewhere – conditionally load an alternative template (or conditionally include/exclude blocks of code in an existing template).

    Does that help at all?

    #833667
    kauffmaninc
    Participant

    I hope so! I’ll give it a try at work next week and report back.

    Thanks!

    #840884
    Barry
    Member

    Happy to help – and good luck!

    #847038
    kauffmaninc
    Participant

    Hi Barry,

    The widget_display_callback hook did, indeed, give me the answer I needed. For the sake of anyone else looking for a similar solution, I additionally used information on this page: http://wordpress.stackexchange.com/questions/57546/determining-a-widget-instance-and-sidebar-location

    With that, I was able to determine which piece of information was going to be the most useful to me. I ended up using the $args[‘id’] value, and was able to include additional HTML in my list-widget template file based on that.

    I did not need to keep the hook installed in my functions.php file in order for the IF statement in the template to keep working; I only needed it to find out what was in the various arrays.

    Thanks again!

    #847052
    Barry
    Member

    Awesome – glad that worked and thanks for referencing the WP Stack Exchange post – definitely could be useful for others out there 🙂

    Since it sounds like you’re all good I will go ahead and close this thread, but please don’t hesitate to create new threads if we can help with anything else.

    Also, if you have a moment to spare, we’d love to hear your thoughts on The Events Calendar over on our plugin review page – thanks again!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘[Customization – Event Calendar PRO] Multiple Templates for List Events Widget’ is closed to new replies.