Skip Navigation

[Resolved] "Legacy Output" for Categories (checkbox) not working?

This support ticket is created 5 years 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.

Our next available supporter will start replying to tickets in about 0.19 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 14 replies, has 2 voices.

Last updated by maxfieldB 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1379541

Tell us what you are trying to do?
Hello, we needed to customize the appearance of our checkboxes, so we changed the output of these to "legacy" in our view. This worked well for all of our filters on the homepage. However, the "categories" checkboxes seem to not work when we apply the shortcode- you can see that they appear differently on the homepage (battstaging2.com) despite having similar code. Can you help us debug?

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
battstaging2.com

#1379699

Hello,

I assume we are talking about the shortcode [wpv-control-post-taxonomy], attribute "output":
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-post-taxonomy

The Legacy Output will output the checkboxes as a HTML order list, for example:

<ul class="categorychecklist form-no-clear">
...
<li id="post_category-33" class="popular-category"><label for="in-category-33" class="selectit"><input type="checkbox" id="in-category-33" class="js-wpv-filter-trigger" name="wpv-category[]" value="career-skills"> Career Skills (26)</label></li>
...
</ul>

It does not work as the custom checkboxes post field.

In your case, I suggest you try to create some JS codes to apply those CSS class to taxonomy field, for example:
Edit your post view(ID 312), in section "Search and Pagination", click "JS Editor", add below JS codes:

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	jQuery('ul.categorychecklist li').addClass('form-item form-item-checkbox wpcf-form-item wpcf-form-item-checkbox');
});
jQuery('ul.categorychecklist li').addClass('form-item form-item-checkbox wpcf-form-item wpcf-form-item-checkbox');

More help:
hidden link

#1381453
Screen Shot 2019-11-12 at 2.50.10 PM.png

Hi there,

I think you are referring to a different question. Legacy output did not output an ordered list for us; it stopped the output from creating inputs that were nested inside the labels.

So instead of:
<label><input></label>

Legacy output creates:
<input><label></label>

Which can then be correctly styled with CSS. However this does not appear to be working on the checkboxes, so we're getting unsettled checkboxes. We have also tried custom jQuery radiocheckbox (link below), which is also failing on these categories checkboxes.
hidden link

Can you help us resolve this?

#1381593

There isn't such kind of feature within Legacy output, and it can be fixed by the JS codes I mentioned above.

If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you. thanks

#1381635

Thanks Luo - I am not sure your solution will work, because it still leaves the <input> nested *inside* the <label>, which traditionally makes checkboxes impossible to style with CSS - however I look forward to seeing if you have a solution.

I believe we already created a copy of our site for you, but I have just created another [duplicator package] and shared it with the email I have on file. Thank you for your help, and I look forward to seeing the solution!

Max

#1381685
cat-css.JPG

It should be able to work, see screenshot cat-css.JPG

And I have provided the detail steps to setup the JS codes:
https://toolset.com/forums/topic/legacy-output-for-categories-checkbox-not-working/#post-1381453
You just need to copy/paste the JS codes.

There isn't the same problem in the duplicator package you provided in previous thread:
https://toolset.com/forums/topic/custom-post-archives-have-disappeared/#post-1374461

#1381697

I see! Thank you so much for this help. I did not actually previously enter the JS in the correct place - your guidance here has helped resolve this issue, you're right, it totally works!

I appreciate the help.

Max

#1381751

It looks like I spoke slightly too soon. While the new code does change the form of the checkbox to a box, no checkmark actually happens once the box is checked. I am unable to resolve on my end - can you help me resolve this?

#1381755

I am downloading the new duplicator package files, will update here if there is anything found.

#1381821

Here are what I found in your duplicator package, those checkboxes do checked after click it, but you are using custom CSS codes to hide it, for example, you can try these:

It is your custom CSS codes do not work for the taxonomy checkboxes field.
Those custom CSS codes are from your theme file \wp-content\themes\h-code-child\style.css, line 714~771,

.form-item-checkbox {
    position: relative;
    margin: 16px 0;
    overflow: auto;
    width: 100%;
    margin-bottom: 0px !important;
    margin-top: 7px !important;
}

.form-item-checkbox label {
    cursor: pointer;
    margin-left: 28px !important;
    user-select: none;
    width: unset !important;
    font-family: 'Open Sans', sans-serif;
    text-transform: none !important;
    color: #00000087 !important;
    letter-spacing: .1px !important;
    margin-top: -3px;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-rendering: optimizeLegibility !important;
}

.form-item-checkbox label:before, .form-item-checkbox label:after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
}
.form-item-checkbox label:before {
    width: 20px;
    height: 20px;
    background: #fff;
	border: 2px solid #d8d9da99;
    border-radius: 2px;
    cursor: pointer;
    transition: background .3s;
}
.form-item-checkbox input[type="checkbox"] {
  outline: 0;
  margin-right: 10px;
	display:none;
}
.form-item-checkbox input[type="checkbox"]:checked + label:before {
  background: var(--technycblue) !important;
  border: none;
}
.form-item-checkbox input[type="checkbox"]:checked + label:after {
  transform: rotate(-45deg);
  top: 5px;
  left: 4px;
  width: 12px;
  height: 6px;
  border: 2px solid #fff;
  border-top-style: none;
  border-right-style: none;
}

For example, you can remove above CSS codes, delete cache, and test again, you should be able see all native HTML checkboxes work fine, but according to our support policy we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

And you are right, in order to make the taxonomy checkboxes field work with your custom CSS codes, it needs to output the HTML codes as you mentioned above:

<input><label></label>

The current

But there isn't such a built-in feature within Toolset Views plugin, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Our developers will evaluate it.

#1381851

Hi Luo,

The first line that I wrote in this thread says, "we needed to customize the appearance of our checkboxes," -

I am a bit frustrated that we had this miscommunication - it would have been much easier if you could have mentioned that at the beginning.

#1381865

Yes, I do understand you need to customize the checkboxes style, but the Views shortcode [wpv-control-post-taxonomy] can only output the taxonomy checkboxes field as below:

<label><input></label>

This is a limitation of Views shortcode [wpv-control-post-taxonomy], and does not satisfy your custom CSS codes requirement, please let me know if you need other CSS/JS workaround.

#1381879

Can you help with this?

Originally, our approach was to use Jquery checkboxradio(), which *does* allow customization of the input in the form:

<label><input></label>

However, for some reason it was not working with toolset, even though they had an identical example on their website:

hidden link

It is just very important for us to customize the appearance of the checkboxes.

#1382773
cat-cks.JPG

Please try below JS codes:

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
    cat_style();
});
function cat_style(){
    jQuery('ul.categorychecklist li').addClass('form-item form-item-checkbox wpcf-form-item wpcf-form-item-checkbox');
    jQuery('ul.categorychecklist li input[type="checkbox"]').each(function(index){
    	$(this).closest('li').prepend($(this)); // move checkbox before label tag
    });
}
cat_style();

I have tested it in my localhost with your duplicator package, it works fine, see screenshot: cat-cks.JPG

More help:
hidden link

#1383799

Wow - this really worked. Thank you very much for your help - I know that was a lot of work for you, but I really appreciate it because this lets us move forward and the custom checkboxes are very important to us.

THANK YOU!