WordPress.org

Forums

Bootstrap Shortcodes for WordPress
[resolved] Collapse / Accordion "start collapsed" issue (18 posts)

  1. mattboden
    Member
    Posted 1 year ago #

    Hi there,

    I'm using your plugin for a theme based on Bootstrap 3.

    All seems to be working fine except for the Accordion shortcode.

    I'm unable to set it so that only the first tab is "active". It doesn't matter whether i set them to true, false, or leave blank they are open on page load.

    http://newsite.opalbroadcastingnetwork.tv/downloads/test-download-1/

    Any thoughts would be great.

    Thanks for your help.
    Matt

    https://wordpress.org/plugins/bootstrap-3-shortcodes/

  2. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    Hey mattboden,
    Sorry for the delay in replying, I was away for the holiday weekend.

    Thanks to your report I've tracked down a bug in the current version of this plugin. Setting the "active" parameter to any value, "true", "false", "dishwasher", etc. will cause the collapse to display as "active". To work around this issue just leave that parameter off the collapses you want to display collapsed.

    So while this will show all collapses open:

    [collapsibles]
    [collapse title="Collapse 1" active="true"]
    …
    [/collapse]
    [collapse title="Collapse 2" active="false"]
    …
    [/collapse]
    [collapse title="Collapse 3" active="dishwasher"]
    …
    [/collapse]
    [/collapsibles]

    This should work as you expect and only show the second one as open:

    [collapsibles]
    [collapse title="Collapse 1"]
    …
    [/collapse]
    [collapse title="Collapse 2" active="true"]
    …
    [/collapse]
    [collapse title="Collapse 3"]
    …
    [/collapse]
    [/collapsibles]

    We will fix this bug in an upcoming version. Thank you for your report and please don't hesitate to write back if this doesn't resolve your issue!

  3. mattboden
    Member
    Posted 12 months ago #

    Hi there,

    Thanks for getting back to me.

    Glad i helped to establish a bug, but mine is coming from elsewhere unfortunately (and i suspect related to my theme). With shortcode, no panels will collapse regardless of what i include, or don't include. I also tested the full code for an accordion and whilst it works, it is running in reverse so "collapse in" keep a panel open, and "collapse" keeps a panel closed, which is opposite to what it should be doing. Very odd! Hopefully i can find the solution as it's a shame such a handy feature for presenting content doesn't work for me.

    Matt

  4. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    That's an odd situation. Does the bug still present itself if you switch to one of WordPress's default themes like 2014?

    I'm happy to keep working on this with you. If it turns out I can adjust the plugin for better compatibility with themes like yours I'll do what I can!

  5. mattboden
    Member
    Posted 12 months ago #

    Thanks for offering support. I think if the longhand code correctly i'd say there might be something that could be done. I assume bootstrap is not core to 2014 and i'll need to add it to check whether it works - i've not checked that as yet, but i'll need to help isolate where the root of the problem might be.

  6. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    What theme are you using? Maybe I can test in a similar environment.

  7. mattboden
    Member
    Posted 12 months ago #

    Hi there,

    The theme used is http://themeforest.net/item/tendershop-responsive-easy-digital-downloads-theme/6758249 picked due to it being built using the bootstrap platform. I tested the 'collapse' with all plugins deactivated, but didn't make a change, so not sure it's the plugins. Leads me to believe it's the theme. I'll try and add bootstrap to 2014 to see if it works okay with that one.

    Thanks a million for your help.

  8. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    Matt,
    Give "Shoestrap" a try. It's a very light-weight theme that has Bootstrap included. I've tested it successfully with this plugin.

    http://shoestrap.org/

    If that works OK for you, then I think we can narrow the problem down to the theme. I'll have to figure out how we can work around it once we've done that.

  9. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    Hold that thought. I found the problem. The issue is definitely with your theme, specifically in this file:
    http://newsite.opalbroadcastingnetwork.tv/wp-content/themes/tendershop/js/script.js

    On line 1275 your theme does this:

    jQuery('.collapse').collapse()

    Which seems to be conflicting with this plugin's preference for using data-attributes for collapse (see here for the difference).

    Commenting out line 1275 in /tendershop/js/script.js should fix the issue for now. I'll see if I can figure out a way to work around the problem and correct for when a theme wants to fire the collapse() function this way.

  10. mattboden
    Member
    Posted 12 months ago #

    Hi

    Thanks again for taking the time to check out the issue.

    Is that the right file? That one doesn't seem to go beyond 150 lines.

  11. mattboden
    Member
    Posted 12 months ago #

    I found the line and commented it out. It's had the effect of stopping the longhand code from collapsing, and hasn't made a change to the shortcode. They're all still open.

  12. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    Ugh. The theme developer is reversing the way collapse is supposed to work.

    In /wp-content/themes/tendershop/style.css

    Comment out line 95 which should read as follows:

    .collapse { display: block }

    Then everything should work as expected.

  13. mattboden
    Member
    Posted 12 months ago #

    Thanks so much! The shortcode for collapse is working perfectly now too.

    Not sure why it was reversed, but i can't see any adverse effects elsewhere on the site.

    Really appreciated!

  14. Michael W.
    Member
    Plugin Author

    Posted 12 months ago #

    Glad it's working now. I'll investigate working around this kind of thing in the future and correcting for weird theme development.

    Thanks for reporting and I'm glad you like the plugin!

  15. Artem P.
    Member
    Posted 7 months ago #

    If it's possible please add class "collapsed" to accordion-toggle by default (if toggle isn't active). Bootstrap does it automatically (try to open - close toggle).

    CURRENT:
    <a class="accordion-toggle" data-toggle="collapse" data-parent="#%3$s" href="#%4$s">%5$s</a>

    NEW:

    <a class="accordion-toggle' . ($active == 'true' ? '' : ' collapsed') . '" data-toggle="collapse" data-parent="#%3$s" href="#%4$s">%5$s</a>

  16. Michael W.
    Member
    Plugin Author

    Posted 7 months ago #

    Thank you for reporting this. I see that the example at Bootstrap's website does indeed include the "collapsed" class for non-active collapses. That must be new?

    I'll add this to the list of things to add in the next release.

  17. Artem P.
    Member
    Posted 7 months ago #

    It's important if you have different header/title design for collapsed and expanded toggle.

  18. Michael W.
    Member
    Plugin Author

    Posted 7 months ago #

    I had some other bugs to fix, so I just pushed an update which fixes this also. Let me know if you have any problems with this, and apologies to everyone everywhere for pushing so many damn updates today :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic