Jump to content
thirty bees forum

Simple FAQ workaround for those in need.


Recommended Posts

Here's a simple and short guide to make a simple accordion style FAQ section using HMTL5 and few rows of CSS. Not the perfect solution but a workaround for those waiting to find it.

https://www.stechies.com/create-accordion-html-without-javascript/


I combined it with section headers using h2 as title for the sections and it looks pretty fine. It's a simple list, but it's working on all modern browsers and very easy to implement.

Adaptation:

Put the custom CSS in Thirtybees' Custom Code section or your theme's custom CSS code field (Warehouse has one). If you have a theme solution go with it, as it will combine the custom rules with the main css file and not embed them in the html. Adjust to your liking.

details {
    border: 1px solid #d4d4d4;    
    padding: .75em .75em 0;
	margin-top: 10px;
	box-shadow:0 0 20px #d4d4d4;
}

summary {	
    font-weight: bold;
    margin: -.75em -.75em 0;
    padding: .75em;
    background-color: #5f75a4;
    color: #fff;
}

details[open] {
    padding: .75em;
	border-bottom: 1px solid #d4d4d4;
}

details[open] summary {
    border-bottom: 1px solid #d4d4d4;
    margin-bottom: 10px;
}

Open a text editor as Notepad++ and format your html code for your CMS page there. Every Q&A is a separate <details></details> tag.
When you're done with your code go to tinymce's source code editor and paste your code.

image.png.81f63be52f5eb11d48a9196d5efa8163.png

Using the usual WYSIWYG editor does not work (you can edit the text after you imported the source but you can't make the element).

EDIT: HTML purifier might have to be disabled in order to save this correctly in TinyMCE, but if you don't make daily changes in this page this could enabled after the page is complete.
image.png

The only fault is that this workaround is not using .js and when you open new question, the already opened one does not close. But for its simplicity and robustness it's a solid solution for me, no bootstrap shenanigans, etc.

 

	<details>
		<summary>Question 1</summary>
		Answer 1
	</details>
	<details>
		<summary>Question 2</summary>
		Answer 2
	</details>



image.thumb.png.88ae739543006a244826e391e6c2260d.png

  • Thanks 1
Link to comment
Share on other sites

27 minutes ago, the.rampage.rado said:

Here's a simple and short guide to make a simple accordion style FAQ section using HMTL5 and few rows of CSS. Not the perfect solution but a workaround for those waiting to find it.

https://www.stechies.com/create-accordion-html-without-javascript/


I combined it with section headers using h2 as title for the sections and it looks pretty fine. It's a simple list, but it's working on all modern browsers and very easy to implement.

Adaptation:

Put the custom CSS in Thirtybees' Custom Code section or your theme's custom CSS code field (Warehouse has one). If you have a theme solution go with it, as it will combine the custom rules with the main css file and not embed them in the html. Adjust to your liking.

details {
    border: 1px solid #d4d4d4;    
    padding: .75em .75em 0;
	margin-top: 10px;
	box-shadow:0 0 20px #d4d4d4;
}

summary {	
    font-weight: bold;
    margin: -.75em -.75em 0;
    padding: .75em;
    background-color: #5f75a4;
    color: #fff;
}

details[open] {
    padding: .75em;
	border-bottom: 1px solid #d4d4d4;
}

details[open] summary {
    border-bottom: 1px solid #d4d4d4;
    margin-bottom: 10px;
}

Open a text editor as Notepad++ and format your html code for your CMS page there. Every Q&A is a separate <details></details> tag.
When you're done with your code go to tinymce's source code editor and paste your code.

image.png.81f63be52f5eb11d48a9196d5efa8163.png

Using the usual WYSIWYG editor does not work (you can edit the text after you imported the source but you can't make the element).

The only fault is that this workaround is not using .js and when you one new question, the already opened one does not close. But for its simplicity and robustness it's a solid solution for me, no bootstrap shenanigans, etc.

 

	<details>
		<summary>Question 1</summary>
		Answer 1
	</details>
	<details>
		<summary>Question 2</summary>
		Answer 2
	</details>



image.thumb.png.88ae739543006a244826e391e6c2260d.png

In my case is not working, it continue to change the html to

<p></p>
<p>Accordion One Body Content 1 Accordion Two Body Content 2</p>
<p></p>

after I save the cms article

p.s. I think this topic have to be moved to Tips and Tricks forum as in this forum the replies are answers.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...