Can I Add a Widget to an Advertisement in XenForo?

  • Thread starter WendyMay
  • Start date
WendyMay

WendyMay

New Member
Joined
May 11, 2021
Messages
11
Reaction score
0
Points
1
  • #1
I have a third party search bar widget that I bought from a XenForo add-ons developer. I would like to add it to a part of my forum that there are no predetermined widget locations for. Basically, I want to add it across the top of the website, above the breadcrumbs. There may not be any widget locations for this add-on, but there are advertisement (under Setup) locations for it. I was wondering if I'm able to contain widgets inside of advertisements inside of XenForo. Has anyone ever done this?
 
Newman

Newman

New Member
Joined
May 11, 2021
Messages
11
Reaction score
0
Points
1
  • #2
Yes, you may "call" a widget from an advertisement slot. I'm not sure if you can call all widgets from advertisements, but I do know you most probably can call a third-party search bar widget from one. Here's how you do it.

1. Start off by installing your add-on and making sure it's configured the way you want. I'm assuming this is a widget add-on.

2. Navigate to the Appearance > Widgets page and click the Add Widget button up top.

3. When the Choose a Widget Definition pop-up appears, click the drop-down and choose your widget. Then click the Add Widget button.

4. At this point, you'll be on the Edit Widget page, where you'll need to fill in the Widget Key and the Title fields. Don't check any of the Display in Positions boxes. You'll want to keep them empty. All you'll want is to create the widget and have it live.

5. Below the check box selections, notice a line of text that says:

Widgets with no position will not appear anywhere, but you can call the configured widget instance directly in templates using the <xf:widget key="widget_key" /> syntax.

Basically, you're going to follow these instructions. You're not going to choose a widget location for this widget, but you are going to choose a location by using another method. Also, you won't be hard coding this widget into a template. You'll be using the Advertising feature to slip it into a template.

6. Next, navigate to Setup > Advertising and click the Add Advertisement button.

7. Fill in the Title field and then choose a location from the Position drop-down.

8. In the HTML box, add the widget code syntax that was located on the widget page you filled in earlier. This is what it looks like:

<xf:widget key="widget_key" />.

All you need to do is replace the widget_key with your own widget key. The one you typed in earlier. So in your case, your syntax might look something like this:

<xf:widget key="SearchBar" />.

9. Press the Save button and you should be all set.
 
Can I Add a Widget to an Advertisement in XenForo? was posted on 05-18-2021 by WendyMay in the XenForo forum.

Forum statistics

Threads
88
Messages
156
Members
17
Latest member
mandy cromarty
Looking for an all-around awesome forum? Check out IndyFor!
Top