cafejoya Posted August 19, 2016 Share Posted August 19, 2016 I would like to create a link(FAQ) located at the top horizontal menu on the home page. Clicking FAQ would send visitors to a new page where I would like to display text in several different paragraphs. I would like to use collapsible content panels for those panels. Similar to this. https://jqueryui.com/accordion/ Can this be accomplished in Prestashop? Thank you. Peter Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 extend rich text editor (necessary step!) create a cms page FAQ use source tool and paste these contents: <br><dl><dt><a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordionTitle js-accordionTrigger">First Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion1" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur <a href="http://www.google.com">Test</a>adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion2" aria-expanded="false" aria-controls="accordion2" class="accordion-title accordionTitle js-accordionTrigger"> Second Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion2" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion3" aria-expanded="false" aria-controls="accordion3" class="accordion-title accordionTitle js-accordionTrigger"> Third Accordion heading </a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion3" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd></dl> <script>// <![CDATA[ //uses classList, setAttribute, and querySelectorAll //if you want this to work in IE8/9 youll need to polyfill these (function(){ var d = document, accordionToggles = d.querySelectorAll('.js-accordionTrigger'), setAria, setAccordionAria, switchAccordion, touchSupported = ('ontouchstart' in window), pointerSupported = ('pointerdown' in window); skipClickDelay = function(e){ e.preventDefault(); e.target.click(); } setAriaAttr = function(el, ariaType, newProperty){ el.setAttribute(ariaType, newProperty); }; setAccordionAria = function(el1, el2, expanded){ switch(expanded) { case "true": setAriaAttr(el1, 'aria-expanded', 'true'); setAriaAttr(el2, 'aria-hidden', 'false'); break; case "false": setAriaAttr(el1, 'aria-expanded', 'false'); setAriaAttr(el2, 'aria-hidden', 'true'); break; default: break; } }; //function switchAccordion = function(e) { console.log("triggered"); e.preventDefault(); var thisAnswer = e.target.parentNode.nextElementSibling; var thisQuestion = e.target; if(thisAnswer.classList.contains('is-collapsed')) { setAccordionAria(thisQuestion, thisAnswer, 'true'); } else { setAccordionAria(thisQuestion, thisAnswer, 'false'); } thisQuestion.classList.toggle('is-collapsed'); thisQuestion.classList.toggle('is-expanded'); thisAnswer.classList.toggle('is-collapsed'); thisAnswer.classList.toggle('is-expanded'); thisAnswer.classList.toggle('animateIn'); }; for (var i=0,len=accordionToggles.length; i<len; i++) { if(touchSupported) { accordionToggles[i].addEventListener('touchstart', skipClickDelay, false); } if(pointerSupported){ accordionToggles[i].addEventListener('pointerdown', skipClickDelay, false); } accordionToggles[i].addEventListener('click', switchAccordion, false); } })(); // ]]></script> <style><!-- //updated ver * { box-sizing:border-box; } @import url(http://fonts.googleapis.com/css?family=Lato:400,700); body { font-family:'Lato'; } .heading-primary { font-size:2em; padding:2em; text-align:center; } .accordion dl, .accordion-list { border:1px solid #ddd; &:after { content: ""; display:block; height:1em; width:100%; background-color:darken(#38cc70, 10%); } } .accordion dd, .accordion__panel { background-color:#eee; font-size:1em; line-height:1.5em; } .accordion p { padding:1em 2em 1em 2em; } .accordion { position:relative; background-color:#eee; } .container { max-width:960px; margin:0 auto; padding:2em 0 2em 0; } .accordionTitle, .accordion__Heading { background-color:#38cc70; text-align:center; font-weight:700; padding:2em; display:block; text-decoration:none; color:#fff; transition:background-color 0.5s ease-in-out; border-bottom:1px solid darken(#38cc70, 5%); &:before { content: "+"; font-size:1.5em; line-height:0.5em; float:left; transition: transform 0.3s ease-in-out; } &:hover { background-color:darken(#38cc70, 10%); } } .accordionTitleActive, .accordionTitle.is-expanded { background-color:darken(#38cc70, 10%); &:before { transform:rotate(-225deg); } } .accordionItem { height:auto; overflow:hidden; //SHAME: magic number to allow the accordion to animate max-height:50em; transition:max-height 1s; @media screen and (min-width:48em) { max-height:15em; transition:max-height 0.5s } } .accordionItem.is-collapsed { max-height:0; } .no-js .accordionItem.is-collapsed { max-height: auto; } .animateIn { animation: accordionIn 0.45s normal ease-in-out both 1; } .animateOut { animation: accordionOut 0.45s alternate ease-in-out both 1; } @keyframes accordionIn { 0% { opacity: 0; transform:scale(0.9) rotateX(-60deg); transform-origin: 50% 0; } 100% { opacity:1; transform:scale(1); } } @keyframes accordionOut { 0% { opacity: 1; transform:scale(1); } 100% { opacity:0; transform:scale(0.9) rotateX(-60deg); } } --></style> you can alter contents of accordion in source tool editor, of course you can alter styles colors etc. effect: http://i.imgur.com/g9lQ0t9.gifv 1 Link to comment Share on other sites More sharing options...
cafejoya Posted August 19, 2016 Author Share Posted August 19, 2016 extend rich text editor (necessary step!) create a cms page FAQ use source tool and paste these contents: <br><dl><dt><a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordionTitle js-accordionTrigger">First Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion1" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur <a href="http://www.google.com">Test</a>adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion2" aria-expanded="false" aria-controls="accordion2" class="accordion-title accordionTitle js-accordionTrigger"> Second Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion2" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion3" aria-expanded="false" aria-controls="accordion3" class="accordion-title accordionTitle js-accordionTrigger"> Third Accordion heading </a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion3" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd></dl> <script>// <![CDATA[ //uses classList, setAttribute, and querySelectorAll //if you want this to work in IE8/9 youll need to polyfill these (function(){ var d = document, accordionToggles = d.querySelectorAll('.js-accordionTrigger'), setAria, setAccordionAria, switchAccordion, touchSupported = ('ontouchstart' in window), pointerSupported = ('pointerdown' in window); skipClickDelay = function(e){ e.preventDefault(); e.target.click(); } setAriaAttr = function(el, ariaType, newProperty){ el.setAttribute(ariaType, newProperty); }; setAccordionAria = function(el1, el2, expanded){ switch(expanded) { case "true": setAriaAttr(el1, 'aria-expanded', 'true'); setAriaAttr(el2, 'aria-hidden', 'false'); break; case "false": setAriaAttr(el1, 'aria-expanded', 'false'); setAriaAttr(el2, 'aria-hidden', 'true'); break; default: break; } }; //function switchAccordion = function(e) { console.log("triggered"); e.preventDefault(); var thisAnswer = e.target.parentNode.nextElementSibling; var thisQuestion = e.target; if(thisAnswer.classList.contains('is-collapsed')) { setAccordionAria(thisQuestion, thisAnswer, 'true'); } else { setAccordionAria(thisQuestion, thisAnswer, 'false'); } thisQuestion.classList.toggle('is-collapsed'); thisQuestion.classList.toggle('is-expanded'); thisAnswer.classList.toggle('is-collapsed'); thisAnswer.classList.toggle('is-expanded'); thisAnswer.classList.toggle('animateIn'); }; for (var i=0,len=accordionToggles.length; i<len; i++) { if(touchSupported) { accordionToggles[i].addEventListener('touchstart', skipClickDelay, false); } if(pointerSupported){ accordionToggles[i].addEventListener('pointerdown', skipClickDelay, false); } accordionToggles[i].addEventListener('click', switchAccordion, false); } })(); // ]]></script> <style><!-- //updated ver * { box-sizing:border-box; } @import url(http://fonts.googleapis.com/css?family=Lato:400,700); body { font-family:'Lato'; } .heading-primary { font-size:2em; padding:2em; text-align:center; } .accordion dl, .accordion-list { border:1px solid #ddd; &:after { content: ""; display:block; height:1em; width:100%; background-color:darken(#38cc70, 10%); } } .accordion dd, .accordion__panel { background-color:#eee; font-size:1em; line-height:1.5em; } .accordion p { padding:1em 2em 1em 2em; } .accordion { position:relative; background-color:#eee; } .container { max-width:960px; margin:0 auto; padding:2em 0 2em 0; } .accordionTitle, .accordion__Heading { background-color:#38cc70; text-align:center; font-weight:700; padding:2em; display:block; text-decoration:none; color:#fff; transition:background-color 0.5s ease-in-out; border-bottom:1px solid darken(#38cc70, 5%); &:before { content: "+"; font-size:1.5em; line-height:0.5em; float:left; transition: transform 0.3s ease-in-out; } &:hover { background-color:darken(#38cc70, 10%); } } .accordionTitleActive, .accordionTitle.is-expanded { background-color:darken(#38cc70, 10%); &:before { transform:rotate(-225deg); } } .accordionItem { height:auto; overflow:hidden; //SHAME: magic number to allow the accordion to animate max-height:50em; transition:max-height 1s; @media screen and (min-width:48em) { max-height:15em; transition:max-height 0.5s } } .accordionItem.is-collapsed { max-height:0; } .no-js .accordionItem.is-collapsed { max-height: auto; } .animateIn { animation: accordionIn 0.45s normal ease-in-out both 1; } .animateOut { animation: accordionOut 0.45s alternate ease-in-out both 1; } @keyframes accordionIn { 0% { opacity: 0; transform:scale(0.9) rotateX(-60deg); transform-origin: 50% 0; } 100% { opacity:1; transform:scale(1); } } @keyframes accordionOut { 0% { opacity: 1; transform:scale(1); } 100% { opacity:0; transform:scale(0.9) rotateX(-60deg); } } --></style> you can alter contents of accordion in source tool editor, of course you can alter styles colors etc. effect: http://i.imgur.com/g9lQ0t9.gifv Thank you immensely vekia. I followed your instructions to the letter. First, extending the rich text editor. Followed by the creation of a new CMS page. However, when I paste the code that you provided, I receive a "The content field is invalid." message. I can see the results of the code in the editor pane but I cannot save the file because of this error. I cannot find the problem though Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 you extended the validation class too ? :-) Link to comment Share on other sites More sharing options...
cafejoya Posted August 19, 2016 Author Share Posted August 19, 2016 (edited) you extended the validation class too ? :-) At the risk of sounding like a complete fool, I'm not sure what validation class that I should be extending. You will have to excuse me. Edited August 19, 2016 by cafejoya (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 the tutorial describes the way of how to extend tinymce editor. there is a section with validation class change: http://i.imgur.com/alCgPae.png - you applied this change to validation file? Link to comment Share on other sites More sharing options...
cafejoya Posted August 19, 2016 Author Share Posted August 19, 2016 (edited) you extended the validation class too ? :-) Seems fine in the editor window Until I try saving the changes Works well when I preview it in the editor as well, nut cannot save Edited August 19, 2016 by cafejoya (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 Until I try saving the changes this appears when validation class is not enhanced with guidelines, so im asking again, what about validation class? Link to comment Share on other sites More sharing options...
cafejoya Posted August 19, 2016 Author Share Posted August 19, 2016 this appears when validation class is not enhanced with guidelines, so im asking again, what about validation class? I really don't know what what a validation class is? Sorry Link to comment Share on other sites More sharing options...
cafejoya Posted August 19, 2016 Author Share Posted August 19, 2016 I put this code into a file called Validate.php. I then copied it to the directory /override/classes/ May have done the trick. Will do more testing though <?php class Validate extends ValidateCore { public static function isCleanHtml($html, $allow_iframe = false) { return true; } } ?> Link to comment Share on other sites More sharing options...
cafejoya Posted August 20, 2016 Author Share Posted August 20, 2016 Seems to be functioning well. Now, I would like to get each panel to close when another heading is clicked. Back to the drawing board. Link to comment Share on other sites More sharing options...
vekia Posted August 20, 2016 Share Posted August 20, 2016 hello Great :-) this was exactly what you had to do - validate class change. how it works at the moment and what you want to do now? can i see it somewhere online? Link to comment Share on other sites More sharing options...
cafejoya Posted August 21, 2016 Author Share Posted August 21, 2016 Here you are vekia. Of course, this is still "A work in Progress" I am trying my best to launch the site sometime this week if all goes as planned As for the accordion effect, I would really like to get it to look like the example at https://jqueryui.com/accordion/ I will have to spend a little time learning CSS I guess. Thank you for all your help and input. I really appreciate Link to comment Share on other sites More sharing options...
vekia Posted August 21, 2016 Share Posted August 21, 2016 the design depends on styles that you will use. paste css styles: accordionTitle::before{ content:'\f078'; font-family:fontawesome; margin-right:5px; } .is-collapsed::before{ content:'\f077'; font-family:fontawesome; margin-right:5px; } dd.accordion-content { padding:10px; border-left:1px solid #f4f4f4; border-right:1px solid #f4f4f4; } dd.is-collapsed { padding:0px!important; } .accordionTitle, .accordion__Heading { background-color: #f4f4f4; text-align: left; font-weight: 700; padding: 10px; display: block; text-decoration: none; color: ##4B2E1E; transition: background-color 0.5s ease-in-out; border-bottom: 1px solid darken(#ffffff, 5%); } it will be almost the same then (it is not possible to recreate the same design because some part of your theme overrides these styles). effect: http://i.imgur.com/4y8NMOm.gifv 1 Link to comment Share on other sites More sharing options...
cafejoya Posted August 22, 2016 Author Share Posted August 22, 2016 Thank you again vekia. I'm not quite sure what section of CSS code I should replacing or appending to. I will keep trying though Link to comment Share on other sites More sharing options...
vekia Posted August 22, 2016 Share Posted August 22, 2016 append these styles to editor (there where you pasted code) full code with new styles <br><dl><dt><a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordionTitle js-accordionTrigger">First Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion1" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur <a href="http://www.google.com">Test</a>adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion2" aria-expanded="false" aria-controls="accordion2" class="accordion-title accordionTitle js-accordionTrigger"> Second Accordion heading</a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion2" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd><dt><a href="#accordion3" aria-expanded="false" aria-controls="accordion3" class="accordion-title accordionTitle js-accordionTrigger"> Third Accordion heading </a></dt><dd class="accordion-content accordionItem is-collapsed" id="accordion3" aria-hidden="true"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p> <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p> </dd></dl> <script>// <![CDATA[ //uses classList, setAttribute, and querySelectorAll //if you want this to work in IE8/9 youll need to polyfill these (function(){ var d = document, accordionToggles = d.querySelectorAll('.js-accordionTrigger'), setAria, setAccordionAria, switchAccordion, touchSupported = ('ontouchstart' in window), pointerSupported = ('pointerdown' in window); skipClickDelay = function(e){ e.preventDefault(); e.target.click(); } setAriaAttr = function(el, ariaType, newProperty){ el.setAttribute(ariaType, newProperty); }; setAccordionAria = function(el1, el2, expanded){ switch(expanded) { case "true": setAriaAttr(el1, 'aria-expanded', 'true'); setAriaAttr(el2, 'aria-hidden', 'false'); break; case "false": setAriaAttr(el1, 'aria-expanded', 'false'); setAriaAttr(el2, 'aria-hidden', 'true'); break; default: break; } }; //function switchAccordion = function(e) { console.log("triggered"); e.preventDefault(); var thisAnswer = e.target.parentNode.nextElementSibling; var thisQuestion = e.target; if(thisAnswer.classList.contains('is-collapsed')) { setAccordionAria(thisQuestion, thisAnswer, 'true'); } else { setAccordionAria(thisQuestion, thisAnswer, 'false'); } thisQuestion.classList.toggle('is-collapsed'); thisQuestion.classList.toggle('is-expanded'); thisAnswer.classList.toggle('is-collapsed'); thisAnswer.classList.toggle('is-expanded'); thisAnswer.classList.toggle('animateIn'); }; for (var i=0,len=accordionToggles.length; i<len; i++) { if(touchSupported) { accordionToggles[i].addEventListener('touchstart', skipClickDelay, false); } if(pointerSupported){ accordionToggles[i].addEventListener('pointerdown', skipClickDelay, false); } accordionToggles[i].addEventListener('click', switchAccordion, false); } })(); // ]]></script> <style><!-- //updated ver * { box-sizing:border-box; } @import url(http://fonts.googleapis.com/css?family=Lato:400,700); body { font-family:'Lato'; } .heading-primary { font-size:2em; padding:2em; text-align:center; } .accordion dl, .accordion-list { border:1px solid #ddd; &:after { content: ""; display:block; height:1em; width:100%; background-color:darken(#38cc70, 10%); } } .accordion dd, .accordion__panel { background-color:#eee; font-size:1em; line-height:1.5em; } .accordion p { padding:1em 2em 1em 2em; } .accordion { position:relative; background-color:#eee; } .container { max-width:960px; margin:0 auto; padding:2em 0 2em 0; } .accordionTitle, .accordion__Heading { background-color:#38cc70; text-align:center; font-weight:700; padding:2em; display:block; text-decoration:none; color:#fff; transition:background-color 0.5s ease-in-out; border-bottom:1px solid darken(#38cc70, 5%); &:before { content: "+"; font-size:1.5em; line-height:0.5em; float:left; transition: transform 0.3s ease-in-out; } &:hover { background-color:darken(#38cc70, 10%); } } .accordionTitleActive, .accordionTitle.is-expanded { background-color:darken(#38cc70, 10%); &:before { transform:rotate(-225deg); } } .accordionItem { height:auto; overflow:hidden; //SHAME: magic number to allow the accordion to animate max-height:50em; transition:max-height 1s; @media screen and (min-width:48em) { max-height:15em; transition:max-height 0.5s } } .accordionItem.is-collapsed { max-height:0; } .no-js .accordionItem.is-collapsed { max-height: auto; } .animateIn { animation: accordionIn 0.45s normal ease-in-out both 1; } .animateOut { animation: accordionOut 0.45s alternate ease-in-out both 1; } @keyframes accordionIn { 0% { opacity: 0; transform:scale(0.9) rotateX(-60deg); transform-origin: 50% 0; } 100% { opacity:1; transform:scale(1); } } @keyframes accordionOut { 0% { opacity: 1; transform:scale(1); } 100% { opacity:0; transform:scale(0.9) rotateX(-60deg); } } accordionTitle::before{ content:'\f078'; font-family:fontawesome; margin-right:5px; } .is-collapsed::before{ content:'\f077'; font-family:fontawesome; margin-right:5px; } dd.accordion-content { padding:10px; border-left:1px solid #f4f4f4; border-right:1px solid #f4f4f4; } dd.is-collapsed { padding:0px!important; } .accordionTitle, .accordion__Heading { background-color: #f4f4f4; text-align: left; font-weight: 700; padding: 10px; display: block; text-decoration: none; color: #4B2E1E; transition: background-color 0.5s ease-in-out; border-bottom: 1px solid darken(#ffffff, 5%); } </style> today i will release step by step guide related to this type of accordion, with proper way to apply css styles. Link to comment Share on other sites More sharing options...
cafejoya Posted August 22, 2016 Author Share Posted August 22, 2016 Hello vekia. I think that beneath that mild-mannered appearance, you must be wearing a tight body suit with a BIG "S" plastered on the front of it. Because you are faster than a speeding bullet. By the way, here are the results when i use the modified code that you provided earlier. i am not getting the same results as you. Link to comment Share on other sites More sharing options...
vekia Posted August 22, 2016 Share Posted August 22, 2016 here it is:faq on cms page in PrestaShop 1 Link to comment Share on other sites More sharing options...
cafejoya Posted August 23, 2016 Author Share Posted August 23, 2016 We make a great team vekia. You the expert, me the noob ! Thanks for all the help that you have given me. I really could use all the help that I can get right now. I appreciate it very much. I will check out your accordion guide to see if I can get it to work on my dev site. Link to comment Share on other sites More sharing options...
cafejoya Posted August 23, 2016 Author Share Posted August 23, 2016 here it is: faq on cms page in PrestaShop Hello vekia, I followed the instructions on your site. If i click the heading of one of the panels then proceed to click on the heading of the second panel both remain fully expanded. I was under the impression that the first would close as soon as I clicked on the second. Thank you Link to comment Share on other sites More sharing options...
benzachar Posted September 4, 2016 Share Posted September 4, 2016 Hi cafejoya, vekia, Thank you for this solution. I was working on the same thing and I chose to use the solution 2 in this article: http://www.majory-cubizolles.fr/blog/ajouter-un-accordeon-dans-une-page-cms-astuce-prestashop/ (sorry in French, but easy to understand with the English code) I edited global.js, my css and then the CMS page. I thought it was easier. I wonder if it's as good as your solution, and if it will stay after an update from Prestashop? Link to comment Share on other sites More sharing options...
Major Bob Posted November 28, 2016 Share Posted November 28, 2016 This is a great solution that I used for Prestashop 1.6. Unfortunately, after upgrading to 1.7, the code doesn't appear to work anymore. I hope that there will be a solution for the future that works with 1.7 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now