Custom Module Category?

Hi,

I read the core code and it seems that adding a new custom category in addition to “Basic” and “Advanced” is not straightforward.

Do you suggest a way to do that? or;
Do you have future plans for adding this feature?

I think this feature is very important for someone extending modules.
In our case, it is very important, and the last thing I want to do is to add a JS code to reorder modules in the browser.

Thanks and Cheers!

Hey Elemento,

I have already assigned this to another member of the team so they can assist you further.

Ben

Hi Elemento,

The category comes from the module’s constructor function as in the example below. You can’t change the category for core modules, but you can add different categories for the custom modules you create. Let me know if you have any questions about that.

/**
 * @class FLAccordionModule
 */
class FLAccordionModule extends FLBuilderModule {

    /**
     * @method __construct
     */
    public function __construct()
    {
        parent::__construct(array(
            'name'          => __('Accordion', 'fl-builder'),
            'description'   => __('Display a collapsible accordion of items.', 'fl-builder'),
            'category'      => __('Advanced Modules', 'fl-builder')
        ));

        $this->add_css('font-awesome');
    }
}

Thanks,
Justin

Hey there,
This seemed like a good thread to continue with my question.

I’ve added a category for my custom modules (Let’s call it Custom Modules).

By default, it shows up underneath the core BB categories. For example:

  • Basic Modules
  • Advanced Modules
  • WordPress Widgets
  • Custom Modules

Is there a way to move it up the food chain / re-order it to appear first in the list?

Thanks,
Carrie

Hey Carrie,

It’s good to see you here! :slight_smile:

That’s not currently possible, but looking at your list, I think we should do something about it.

We’re actually pushing out a minor update later today, so this is perfect timing. It’s a fairly easy change, so here’s what I’ve done…

  • Custom module categories now show up above the widgets category but below ours by default.

  • If you want yours to show up first, you can now define your categories in a filter like so…

function my_builder_module_categories( $categories ) {
    	$categories[] = 'My Module Cat 1';
	    $categories[] = 'My Module Cat 2';
    	return $categories;
}
add_filter( 'fl_builder_module_categories', 'my_builder_module_categories' );

That filter doesn’t exist yet, but it will in the next update.

Let me know if you have any questions!

Justin

Whoa - talk about awesome! Thanks for the quick integration. :slight_smile:

You’re welcome! That should be live now. Let me know if you have any questions.