Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • EsqJ 11 posts 54 karma points
    Feb 04, 2015 @ 17:36
    EsqJ
    0

    Best way to manage FAQ content?

    Hi Guys,

    In my template i have a section for FAQ's - my goal is for the content editor to be able to add/edit/delete FAQs in this section, as this is not 'static' as such, each faq requires its own structured html, what is the best way to do this?

    The html is structured like this...

    <div class="accordion accordion-border clearfix nobottommargin">

                <div class="acctitle acctitlec"><i class="acc-closed icon-plus-sign orange"></i><i class="acc-open icon-minus-sign orange"></i>This is an open question</div>
                <div style="display: block;" class="acc_content clearfix">Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus. Aenean lacinia bibendum nulla sed consectetur.</div>


                <div class="acctitle"><i class="acc-closed icon-plus-sign orange"></i><i class="acc-open icon-minus-sign orange"></i>This is a closed question</div>
                <div style="display: none;" class="acc_content clearfix">Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus. Aenean lacinia bibendum nulla sed consectetur.</div>


                <div class="acctitle"><i class="acc-closed icon-plus-sign orange"></i><i class="acc-open icon-minus-sign orange"></i>This is another closed question</div>
                <div style="display: none;" class="acc_content clearfix">Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus. Aenean lacinia bibendum nulla sed consectetur.</div>
             
              </div>

    I want the user to be just inputting the question and the answer and to not have to worry about the html around it, what would be the best way to achieve this?

     

     

    Thanks!

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 04, 2015 @ 18:00
    Jan Skovgaard
    0

    Hi EsgJ

    You should probably consider making content elements for the FAQ, so for instance in the content tree you can have elements, which does not have any templates associated with them but just appear as selectable/reusable content elements.

    So in the root of your "Content" section you can have a structure like this

    • Faq entries
      • Faq entry
      • Faq entry
      • Faq entry
      • Etc.

    To be able to set this up you need to go to the "Settings" section and create two document types. You will need to create the container document type called "FAQ entries" and one called "FAQ entry".

    The "FAQ entries" document type should be allowed to be created as a root node and it should allow the "FAQ entry" to be created below it. The "FAQ entry" document type can consist of a rich text editor or whatever you like for the "Question" and "Answer" fields.

    Now you can add a content picker to your default "page document" type, where you can point to the FAQ section and make your XSLT/Razor macro render the FAQ entries in your template so you can control the markup in, which it's wrapped.

    I hope the above approach makes sense to you.

    /Jan

  • EsqJ 11 posts 54 karma points
    Feb 12, 2015 @ 17:00
    EsqJ
    0

    Hi Jan,

    Thanks for the reply, i am going to use your method but im just a little stuck on the razor macro to display the contet.

    So far i have done the following....

    I have created two document types called FAQ Entries and FAQ Entry, FAQ entry has two fields, 'Question' and 'Answer'

    Then in my content tree i have 'GeneralFAQ' and the children of that are the questions answers, so my Content Tree currently looks like this...

    Home Page
    GeneralFAQ
       Question 1
       Question 2
       Question 3
       etc etc

    My home page document type has a property called 'faqContent' i have set this as a content picker.

    In my home page content, i am pointing faqContent to GeneralFAQ via the content picker. 

    I have then created my partial view called FAQBuilder but at the moment its blank as i have no idea what razor script to put into it??? I played around with this...

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    var faqcontentId = (int)CurrentPage.faqContent;
    }

    @if (faqcontentId > 0)
    {
        var faqContentblock = Umbraco.TypedMedia(faqcontentId);
        var entries = faqContentblock.Children(x => x.DocumentTypeAlias == "entry").ToList();
        <div class="accordion accordion-border clearfix nobottommargin">
       
       
            @foreach (var entry in entries)
            {   
          <div class="acctitle acctitlec">@(entry.GetPropertyValue<string>("question"))<i class="acc-closed faqicon"><img src="media/plus-icon.png"></i><i class="acc-open faqicon"><img src="media/minus-icon.png"></i></div>
          <div style="display: block;" class="acc_content clearfix">@(entry.GetPropertyValue<string>("answer"))</div>
              } 

        </div>
    }

    But that does not work, just gives the error '

    Object reference not set to an instance of an object.'

     

    Any help as to what im doing wrong / or a working partial view script would be really really helpful!

     

     

    Thanks

     

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 14, 2015 @ 13:10
    Jan Skovgaard
    0

    Hi EsgJ

    Hmm, perhaps it's a good idea to install the Inspect package https://our.umbraco.org/projects/developer-tools/inspect to see how the content is structured, which can make it easier to figure out where things can go wrong.

    But if you uncomment all of the code except from the faqcontentId variable and then just write @faqcontentId.Count() does that then return anything?

    Hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft