Add Accordions programmatically

 

If you want to create a accordion programmatically you can use the following code snippet:

Core::make("accordion")->outputAccordion(
    array(
        "templatePreset" => "Accordion minimal",
        "animationDuration" => 300,
        "semanticTag" => "h2"
    ), 

    array(
        array(
            "isOpen" => true,
            "title" => "Title 1",
            "paragraph" => "Hello World 1"
        ),

        array(
            "isOpen" => false,
            "title" => "Title 2",
            "paragraph" => "Hello World 2"
        ),

        array(
            "isOpen" => false,
            "title" => "Title 3",
            "paragraph" => "Hello World 3"
        )
    )
); 

The first parameter is an array which contains the options like the template preset, the animation duration and the semantic tag setting. The second parameter is a multi dimensional array which contains the items.