hendra
hendra

Reputation: 2661

Show filter-form in Silverstripe's ModelAdmin by default

I added a ModelAdmin to my silverstripe site. This includes a filter form, which slides down when the user clicks the loupe icon in the frontend. How can I make the form visible by default (without user interaction)?

Up to now I tried to call the showHide() of LeftAndMain.js with entwine, but as Silvertripe relies heavily on Ajax this only shows the form on the initial page load.

(function($) {
    $('#filters-button').entwine({
        onadd: function(){
            this._super();
            this.entwine('ss').showHide();
        }
    });
})(jQuery);

Upvotes: 4

Views: 141

Answers (1)

jjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjj

Reputation: 3118

You can show the filters by default by using CSS (replace .MyAdmin with the classname of your ModelAdmin):

/* file: mysite/css/admin-extensions.css */
.MyAdmin .cms-content-filters {
    display: block;
}

Then add the css file to your requirements:

LeftAndMain:
  extra_requirements_css:
    - 'mysite/cms/css/admin-extensions.css'

Run ?flush to make SilverStripe aware of the changes.

Upvotes: 3

Related Questions