Chúc mừng Tết Trung Thu 15% off everything Shop the sale
Browse topics
Beginner All add-ons Installing your first add-on · part 4 of 5

Add a widget and choose where it appears

Installing an add-on that brings a widget does not put it on your pages. How to add a widget, pick its position and order it.

Updated 4 min read By the D.C Style team

On this page

Widgets are the blocks around your content: lists of new threads, statistics, members online, stories. An add-on can bring new kinds of widget, but installing it does not put any of them on your pages. You decide where each widget appears by adding it in Appearance > Widgets and choosing its positions. The one D.C Style exception is Story, which places its stories bar above the forum list for you.

Add a widget

  1. In the Admin CP, open Appearance > Widgets and click Add widget.
  2. Choose the widget definition, the kind of widget you want. D.C Style widgets have names such as [D.C Style] Forum Statistics or [D.C Style] New Threads.
  3. Fill in the Widget key. It is required, and it is simply a unique name for this widget, such as forum_stats_home.
  4. Enter a Title if you want one. It is optional: leave it empty and the widget shows a suitable title of its own.
  5. Under Display in positions, tick every place the widget should appear. A number box appears next to each ticked position: that is its display order.
  6. Set the widget's own options further down the page, then click Save.

You can add the same kind of widget more than once, each with its own settings. For example, one New Threads widget in the sidebar and another above the forum list.

Choosing a position

Positions are named after the page and the spot on that page. These are the ones most forums use:

PositionWhere it appears
Forum list: Above nodesFull width, above the list of forums on your home page.
Forum list: Below nodesFull width, below the list of forums.
Forum list: SidebarThe sidebar next to the forum list.
Forum view: SidebarThe sidebar inside a forum's thread list.
Thread view: SidebarThe sidebar while reading a thread.
Public: Sidebar top / Public: Sidebar bottomThe top or bottom of the sidebar on pages that have one.

When several widgets share a position, the display order decides their order: lower numbers come first. Give your widgets numbers with gaps, such as 10, 20 and 30, so you can slot a new one in later without renumbering the rest.

Show a widget to some visitors only

The Display condition field lets you limit who sees a widget. It takes a template-style expression. Two common ones:

  • $xf.visitor.user_id shows the widget to logged-in members only.
  • !$xf.visitor.user_id shows it to guests only.

Permissions still apply on top of this. A widget whose add-on has a view permission, such as Forum Statistics and its Can view forum statistics permission, stays hidden from groups that do not have it. See XenForo permissions explained.

Widget not appearing?

  • No position ticked. A widget with no position appears nowhere. That is allowed, because it can still be placed in a template by its key, but it is usually a mistake.
  • Wrong page. A Forum list position only shows on the forum list. Sidebar positions only show on pages that have a sidebar.
  • Permissions. Check the add-on's permissions for the group you are testing with. Guests belong to Unregistered / Unconfirmed.
  • Nothing to show. Some widgets hide themselves when they have nothing to list. XenForo's own New threads widget does this, and so does Forum Statistics until its statistics have been built for the first time.

Our guides for Forum Statistics and D.C Style Widgets suggest good positions for each widget. If the widget still refuses to appear, work through Installed an add-on but nothing shows up?

Still stuck? Open a support ticket with the widget definition, the positions you ticked and a link to the page where it should appear.

Did this guide help? Thanks! Glad it worked. Sorry about that. What went wrong? Thanks for telling us. We'll use it to improve this guide.

What went wrong?
Need a reply? Open a ticket instead.

Still stuck? Open a ticket