1. REGISTRATION REQUIREMENTS:

    Register with your xenforo.com Username then start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Creating widgets for default showcase sidebar blocks?

Discussion in 'Showcase Support' started by Joe Link, Feb 16, 2016.

  1. Joe Link

    Joe Link New Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    Morning @Bob :)

    We use Widget Framework quite extensively. With most add-ons we build widgets to replicate the default sidebar blocks to position them how and where we want them.

    I started doing this with the categories block, which is fine on nflj_showcase_index but won't show categories when you're in an actual category. Any tips here? Might we run into the same thing with the other blocks?
     
  2. Bob

    Bob Developer Staff Member

    In order to create a categories block via [bd] WF, you are going to have to create a renderer as there is a bunch of PHP involved as well as a special "view" file that will be needed.
     
  3. Joe Link

    Joe Link New Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    I've played around with this a bit, including trying out new static category menu's and whatnot. The functionality of the built in menu is far better than anything I've tried. If you find time to create a category widget I'd gladly make a donation to your beer fund :)

    Another question on the subject. Say for now I want to retain the category widget at the top, so I don't 'clear' the sidebar via WF. I can add a widget above the category with position -1, and I can add one below the other sidebar blocks, but is there a way to position WF widgets between default sidebar blocks? I'm fine editing the templates if that's what I need to do.
     
  4. Bob

    Bob Developer Staff Member

    Yes, its called using CUSTOM HOOKS. Its a built in feature of the [bd] Widget Framework that is extremely powerful, yet possibly the most unknown about feature of the BWF.

    Step one: Edit the template that you want to put a widget in and add a CUSTOM HOOK at the location that you want it to display.

    Custom Hook Syntax: <xen:hook name="my_custom_hook_name" />

    Step two: Edit (or create) a Widget and set the position to the custom hook.

    Position: hook:my_custom_hook_name

    You've just added a widget to an exact location in 2 easy steps ;)
     
    Joe Link likes this.
  5. Bob

    Bob Developer Staff Member

    Here is an example... I want to add an "Article" widget to the top of the Notable Authors page, so I edit the Notable Authors template and add a custom hook right below the Navigation Bar. A custom hook is nothing more than standard XenForo xen syntax and a hook name. The hook name must be unique so as it won't clash with existing hookname in Core XenForo (or other addons). In the example below, its highly doubtful that anyone besides alfa1 would use a hook with his name in it.

    Selection_297.png


    Next, create or edit a widget and set the position of that widget to your custom hook name that you just added to the notable authors template. You need to add it the same shown: hook:hookname (not the xen syntax).
    Selection_296.png

    Save and go to the Notable Authors page and you will see that your Widget now displays in the location you added the hook to the template. Its THAT easy. btw, you can use the SAME HOOK in multiple templates, so in the case you want the same widget in several locations, just edit all of those templates and use the same hook name instead of creating a single widget for each one.

    Selection_299.png
     
    Joe Link likes this.
  6. Joe Link

    Joe Link New Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    Wow, thank you! I can't believe I didn't know about that before :eek:
     
  7. Bob

    Bob Developer Staff Member

    I hear ya. Its extremely powerful, yet hardly anyone knows about it (and its SO EASY to use).
     
    Joe Link likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.