It is recommended that you use the solution while retaining frequently asked questions in a SharePoint list. It consists of:
- customizable question list template with content type with questions and answers .
- FAQ List View for rendering as Accordion
Figure 1. List of frequently asked questions with an accordion view (SharePoint 2013)
Figure 2. List of frequently asked questions with an accordion view (SharePoint 2010)
Implementation
1 Create your own content type for entries in the FAQ
<ContentType ID="0x0100fb1027dc96a44bf280f6cb823a8da5ae" Name="FAQ" Group="SE" Description="FAQ Content Type" Inherits="TRUE" Version="0"> <FieldRefs> <FieldRef Name="LinkTitle" ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" DisplayName="Question" Sealed="TRUE"/> <FieldRef Name="LinkTitleNoMenu" ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" DisplayName="Question" Sealed="TRUE"/> <FieldRef Name="Title" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" DisplayName="Question" Sealed="TRUE"/> <FieldRef ID="{b0747420-54bc-41b2-a1b3-8432f2dbdc70}" Name="Answer"/> </FieldRefs> </ContentType>
2 Create a client-side visualization in the frequently asked questions list (for SharePoint 2013)
(function () { loadCss('http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css'); function OnAccordionViewPostRender(renderCtx) { jQuery(function() { jQuery( "#accordionFAQ" ).accordion(); }); } function loadCss(url){ var link = document.createElement('link'); link.href = url; link.rel = 'stylesheet'; document.getElementsByTagName('head')[0].appendChild(link); } function OnAccordionViewPreRender(renderCtx) { } function RenderAccordionViewBodyTemplate(renderCtx) { var listData = renderCtx.ListData; if (renderCtx.Templates.Body == '') { return RenderViewTemplate(renderCtx); } var accordionHtml =''; accordionHtml = '<div id="accordionFAQ">'; for (var idx in listData.Row) { var listItem = listData.Row[idx]; accordionHtml += '<h3>'; accordionHtml += listItem.Title; accordionHtml += '</h3>'; accordionHtml += '<div>'; accordionHtml += listItem.Answer; accordionHtml += '</div>'; } accordionHtml += '</div>'; return accordionHtml; } function _registerAccordionViewTemplate() { var accordionViewContext = {};
3 Apply the client-side rendering template to the existing view through JSLink
For more information about creating a list of frequently asked questions, see the following posts:
Vadim gremyachev
source share