Support » Plugin: Accordion Shortcode » [Plugin: Accordion Shortcode] Collapse all

Viewing 10 replies - 1 through 10 (of 10 total)
  • Great plugin – but I’m really trying to do the same – anyone have luck with this?

    Using [accordions active=0] just doesn’t do anything.

    Thanks for any ideas!

    I am needing the same thing!

    For this plugin to show all of the accordion items as collapsed when the page first renders you need to make a couple changes to the plugin code. I had the same issue as you guys for about an hour today. Open your plugins directory and then open the accordion-shortcode directory, and then finally open accordion-shortcode.php.

    Look for this line, its line 53 in my editor:
    $attr['active'] = (int)$attr['active'];

    Change it to:
    $attr['active'] = (bool)$attr['active'];

    Then look for this line, its line 61 in my editor:
    'active' => 0,

    Change it to:
    'active' => false,

    Then on your accordion, make sure you set the shortcode to:
    [accordions collapsible=true]

    This just worked for me, hope it helps.

    awarren – Thanks for posting this. Worked like a charm!!!

    Found an easier workaround: Use a very large value for active:

    [accordions active=100 collapsible=true]

    vijilov

    (@vijilov)

    hey i tried -1. its working!
    try this,

    [accordions active=-1]

    For me, -1 expands the last accordion.

    The only thing that works for me is:

    [accordions active=100 collapsible=true]

    (assuming you have fewer than 100 accordions)

    I am also trying to have all collapsed when the page is loaded, but the script must have been edited, because I can’t find

    $attr['active'] = (int)$attr['active'];

    on line 53, which now is showing:

    'class' => null,

    akhayyat’s workaround did NOT work for me.

    Can anybody help, please?

    In version Version: 1.2.1 I can find this on line 101-130:

    public static function accordions_shortcode( $atts, $content ) {
    
    		self::$add_script = true;
    		if( is_string($atts) )
    			$atts = array();
    
    		$attr['autoHeight'] = self::eval_bool( $atts['autoheight'] );
    		$attr['disabled']  	= self::eval_bool( $atts['disabled'] );
    		$attr['active']  	= (int)$atts['active'];
    		$attr['clearStyle'] = self::eval_bool( $atts['clearstyle']);
    		$attr['collapsible']= self::eval_bool( $atts['collapsible']);
    		$attr['fillSpace'] 	= self::eval_bool( $atts['fillspace']);
    
    		$query_atts = shortcode_atts( array(
    				'autoHeight'  => false,
    				'disabled'   => false,
    				'active'  => 0,
    				'animated'   => 'slide',
    				'clearStyle'  => false,
    				'collapsible'  => false,
    				'event'   => 'click',
    				'fillSpace'  => false
    			), $attr);
    		$id = "random-accordion-id-".rand(0,1000);
    
    		$content = str_replace( "]<br />","]", ( substr( $content, 0 , 6 ) == "<br />" ? substr( $content, 6 ): $content ) );
    
    		self::$shortcode_js_data[$id] = $query_atts;
    
    		return str_replace("\r\n", '', '<div id="'.$id.'" class="accordions-shortcode">'.do_shortcode( $content ).'</div>');

    Maybe it’s somewhere around here I need to change the script to laod collapsed?

    @peterkopi

    Change your line 109 to $attr['active'] = (bool)$attr['active'];

    Then change your line 117 to 'active' => false,

    And Finally, display your accordion with [accordions collapsible=true] as the opening shortcode. Let me know if this works, I haven’t used this plugin for quite some time.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Accordion Shortcode] Collapse all’ is closed to new replies.