Building with XenForo 2 is back

Over the next few weeks, we'll be adding to the Building with XenForo 2 video series, starting today with a look at how to make your custom add-on content taggable!

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

IMG_0200].png
 
Last edited:

XenForo

Company info
Staff member
Today, part 17 looks into building a section within the admin control panel using routes, admin navigation, admin controllers and all the rest...

And then, we build a list of content and implement Filterer to allow the content to be extensively searchable, with tokenised search parameters for users to manipulate.

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

1656494460242.png
 

asprin

Active member
Wait...is the filterer still not supported for public controllers as mentioned at the end of the video?

But I've seen addons have it on public lists as well :confused:
 

Kier

XenForo developer
Staff member
Wait...is the filterer still not supported for public controllers as mentioned at the end of the video?

But I've seen addons have it on public lists as well :confused:
The filterer can be used for public controllers, but it's very easy to abuse it and cause performance issues for your forum. Consequently, we don't make it readily available on the public side, requiring add-on authors to jump through a few more hoops to make it work.
 

asprin

Active member
Consequently, we don't make it readily available on the public side, requiring add-on authors to jump through a few more hoops to make it work.
Yep, understandable and fair. But since I intend to expose it as part of an addon I'm working on, I'll make an attempt to get it working. I'm hoping I'm able to understand these "hoops" that I need to go through. Don't have any reference per se but keeping my fingers crossed.
 

Kier

XenForo developer
Staff member
Yep, understandable and fair. But since I intend to expose it as part of an addon I'm working on, I'll make an attempt to get it working. I'm hoping I'm able to understand these "hoops" that I need to go through. Don't have any reference per se but keeping my fingers crossed.
All you really need to do is pull the contents of filter_macros::filter_bar through to a public template (or reference it directly), but I'd just caution its use outside of the ACP again - inside the control panel you have a very limited number of users with access to the system, and it's rare that you'd have more than one or two admins using the tool at the same time. On the other hand, letting an potentially large number of visitors access the filterer concurrently could lead to serious performance issues unless you're very careful in selecting how the results can be filtered. If you must do it, make sure that each of the Finder->where() clauses you employ hit an appropriate index in the database or are optimised in some other way.
 

asprin

Active member
Am I right in assuming that the concept of Filterer is not available in XF v2.1?

I didn't want to upgrade yet but I guess if I have to use list filters then I might well have to do it then....
 

Kier

XenForo developer
Staff member
Am I right in assuming that the concept of Filterer is not available in XF v2.1?

I didn't want to upgrade yet but I guess if I have to use list filters then I might well have to do it then....
Correct, Filterer became available in 2.2.something
 

briansol

Well-known member
This?
To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
Sorry i missed this months ago.

Thanks for the video. It's not exactly what i had in mind. understandably, the JS is simple enough.


Consider the option is the name of another 'product'. The product has a full suite of meta and details that need to be added.

So, the idea would be to pop the other modal, fill out product 2 form, save, close, and return the new element to the original modal.


So, to take your example, I want to add more than just Kiwi to my select list. Rather, I want to DEFINE Kiwi.

Name: Kiwi
color: Green
cat: citrus
size: small
etc etc etc

And all of that would exist on a "Fruit" table.


So, if i were looking at Farmer's Fruit Market page

Add New would pop a modal to add a new Vendor.

We begin to input Farmer Joe into the vendor table and one of the options is what fruit do they sell?

Oh No! Kiwi is not an option, yet!

So, similar to your example above i would like to add Kiwi to the option list. But as above, i have a page similar to the Vendor Add which allows to create new fruit in the database. So, i would like to pop that modal up to add Kiwi and all its data, save it to the db, and onsuccess, return the rowid (unique) and name for the original modal to be added back to the JS as per your video example.

In theory, this could be infinite, as for example, perhaps Green isn't in the 'colors' table yet and needs to be added.
and maybe green has attributes hue, saturation, etc etc
and citrus isn't in the category table yet

i think you get the idea.

modals calling modals and returning the stack back to the opener.
 

Karelke

Well-known member
Today, part 17 looks into building a section within the admin control panel using routes, admin navigation, admin controllers and all the rest...

And then, we build a list of content and implement Filterer to allow the content to be extensively searchable, with tokenised search parameters for users to manipulate.

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

View attachment 270271

Great video!

Note that is_numeric() will return true if the value is something like '92.15' or '1337e0'. In my opinion, ctype_digit() is a better method to validate user id's.
 
Top