Skip Navigation

[Resolved] Display search filters in bootstrap columns

This thread is resolved. Here is a description of the problem and solution.

Problem: My filter controls are arranged in several Bootstrap columns, but the select element overflows the bounds of the column and appears on the same line as the label. I would like it to be on its own line and only as wide as the column without overflowing.

Solution: Ensure the HTML syntax surrounding your control elements is valid, with the proper opening and closing tags. Next, add CSS classes as needed to your select control using this format:

[wpv-control taxonomy="subject" url_param="wpvsubject" type="select" default_label="Subject" hide_empty="true" class="my-class-name"]

Finally, apply a 100% width to the select control using CSS:

.my-class-name {
  width: 100%;
}
This support ticket is created 7 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by michaelM-28 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#524905

I am trying to style the filter items for a custom search in a wordpress Archive: Subject. I tried adding the filter controls into three equal-width columns using Bootstrap grid classes. I have the following code in my Filter Editor:

[wpv-filter-start hide="false"][wpv-filter-controls]
<h2>Find your lesson</h2>
<div class="container">
  <div class="row">
    <div class="col-sm-4">
  		<h3 class="label">[wpml-string context="wpv-views"]Grade:[/wpml-string]</h3>
  		[wpv-control taxonomy="grade" url_param="wpv-grade" type="select" taxonomy_orderby="slug" hide_empty="true"]
    </div>
    <div class="col-sm-4">
  		<h3 class="label">[wpml-string context="wpv-views"]Scope & Sequence:[/wpml-string]</div>
  		[wpv-control taxonomy="scope-sequence" url_param="wpv-scope-sequence" type="select" hide_empty="true"]
    </div>
    <div class="col-sm-4">
  		<h3 class="label">[wpml-string context="wpv-views"]Subject:[/wpml-string]</div>
  		[wpv-control taxonomy="subject" url_param="wpvsubject" type="select" default_label="Subject" hide_empty="true"]
    </div>
  </div>
  <div class="row">
  [wpv-filter-spinner container="div" position="after" spinner="<em><u>hidden link</u></em>"][/wpv-filter-spinner]
  </div>
</div>
[/wpv-filter-controls]
[wpv-filter-end]

When I go to view the page, I expected to see the three dropdown select boxes evenly divided among the 3 columns, instead I am seeing that the 3rd column is wrapping below and there is also a lot of extra space below the filters now. See hidden link.

I am thinking that the reason the columns are wrapping is because the values inside one of the dropdowns is too long and it overflows by default. I would also like to apply the Bootstrap styles to the select dropdowns in order to fine tune their appearance (like provided here hidden link) -- but I don't see where I can attach any classes to a filter shortcode.

#524927

Hi, can you check your HTML syntax? It looks like your tags are mismatched in several places like so:

<h3 class="label">[wpml-string context="wpv-views"]Scope & Sequence:[/wpml-string]</div>

You're closing a div tag when instead you should close an h3 tag. This is the main reason your bootstrap columns aren't working as expected. Please fix these mismatched tags, then we can continue debugging. Thanks!

#524928

Woops!!! Got those fixed, now you can see that the middle dropdown is extending into the next column. I would like to style those dropdowns with Bootstrap class "selectpicker" instead.

#524931

Okay, now add classes like so:

[wpv-control taxonomy="subject" url_param="wpvsubject" type="select" default_label="Subject" hide_empty="true" class="my-class-name"]

You can make the selects behave by adding the following additional CSS:

.my-class-name {
  width: 100%;
}

This will bump each one down to its own line, and force it to expand to fill the width of the column without overflowing.

#527160

Got it to work, thank you!