PLEASE NOTE:
THIS IS NOW OBSOLETE. THERE IS NO JQUERY UI ACCORDION IN THE CONCRETE5 CORE
Step 1 - Create a page attribute for accordion section.
- Go to dashboard/pages/attributes and add a new select attribute type
- Handle "accordion_sections"
- Name "Accordion Sections"
- Not searchable
- Allow Multiple options to be chosen
- Allow users to add to this list
- Option Order display order
- No need to enter options now, they will not show up on the end page anyway
Step 2 - Create a page type template in your theme
- Copy /yourtheme/default.php to /yourtheme/accordion.php
- Go to /dashboard/pages/themes
- Inspect your theme to see the new file and activate it
Edit the newly created file, add this where you would like the accordion to appear:
<div id='accordion'>
<?php
$sections = $c->getCollectionAttributeValue('accordion_sections');
if (count($sections)>0){
foreach ($sections as $opt) {?>
<h3><?= $opt->value; ?></h3>
<div>
<?php
$a = new Area($opt->value);
$a->setBlockLimit(1);
$a->display($c);
?>
</div>
<? }
} ?>
</div>
Step 3 - Make a controller for your page type
- Create /site_root/controllers/page_types/accordion.php
Put this in the file
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); class AccordionPageTypeController extends Controller { public function on_start() { $html = Loader::helper("html"); $this->addHeaderItem($html->css("jquery.ui.css")); $this->addHeaderItem($html->css("ccm.dialog.css")); $this->addHeaderItem($html->javascript("jquery.ui.js")); $this->addHeaderItem($html->javascript("ccm.dialog.js")); $js_string = "\n"; $js_string .= "<script type='text/javascript'>\n"; $js_string .= " $(function() {\n"; $js_string .= " $( '#accordion' ).accordion({\n"; $js_string .=" collapsible: true\n"; $js_string .= " });\n"; $js_string .= " });\n"; $js_string .= "</script>\n"; $this->addHeaderItem($js_string); }
}
Step 4 - Associate your page type with the accordion_sections attribute.
- Go to /dashboard/pages/types
- Click "Edit" on accordion
- Click the checkbox next to accordion sections
- Click "Update Page Type"
Step 5 - Add an accordion page
- Go to dashboard / sitemap
- Click the page you want your test page to show up under and choose 'add page'
- Accordion for page type
- Add as many accordion sections as you would like to have on the page
- Click "Add Page"
- Click New Page
- Choose "Visit"
- Edit Page
- You should see an accordion pane with the names of your sections, and an area in each pane to add content to
Loading Conversation