Copied to clipboard

Flag this post as spam?

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


  • suzyb 476 posts 934 karma points
    May 08, 2011 @ 18:40
    suzyb
    0

    Tabs in content

    I have a site where some of the pages have content that needs to appear in tabs.  I am using jquery for the tabs but am not sure the best way to add the content in the backend.

    I want to make it easy for users to add the content so don't want them to have to enter the div structure required for the tabs.  But as there can be a variable number of tabs I'm not sure how to make the tab content properties of the doc type so they can be edited.

    Can anyone advise?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 12x admin c-trib
    May 08, 2011 @ 18:54
    Jan Skovgaard
    0

    Hi Suzyb

    How will the tabs on the website be generated? Are'nt they going to mirror the content structure from the backoffice so content from tab a in the backoffice goes into tab a in the website and so on?

    Or is the tabs on the frontpage made dynamically somehow that does not take the backoffice structure into account?

    /Jan

  • suzyb 476 posts 934 karma points
    May 08, 2011 @ 21:32
    suzyb
    0

    That's what I'm not sure of.  The pages are about university courses which can last 2 or 3 years.  Each page has an overview about the course and a brief summary of what is covered in each of the years.  To keep things nice the designer only wants 1 year's summary shown at a time so I am using jquery "tabs" to do this, basically hiding or showing a div when a link is clicked.

    This is the code shows I am ultimatly trying to produce in the front end, title and content is what I want to be editable.  If the course has 2 years then 2 tabs are shown, if it has 3 then 3 tabs are shown but I'd like this to be dynamic if possible.  So if the client wants to add a course with 10 years, they can.

    <ul class="tabs">
        <li><a href="#tab1"><!--title--></a></li>
        <li><a href="#tab2"><!--title--></a></li>
    </ul>
    
    <div class="tab_container">
        <div id="tab1" class="tab_content">
            <!--Content-->
        </div>
        <div id="tab2" class="tab_content">
           <!--Content-->
        </div>
    </div>

    For the time being I have added 6 fields to my doc type,  tab 1 title, tab 1 content, tab 2 title, tab 2 content etc and have an xslt macro that adds an li or tab_content div if the field isn't empty.  But that is no use if the client wants to add a course with 4 years or 5 years.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 12x admin c-trib
    May 08, 2011 @ 21:48
    Jan Skovgaard
    0

    Hi Suzy

    Ok...Then I think the most flexible thing you can do in the backoffice is to add a content repository to the root of the content section so it's at the same level as your site.

    So it will look something like this

    Website
       - Textpage
       - Textpage
         - Textpage
       - Etc.
    Courses repository
        Folder for course X
           Course
           Course
           Course
        Folder for course Y
           Course
           Course
           Course
           Course
           Course
           Course
    Etc.

    Then you have a repository where you can structure the courses in folder, so it is ordered and makes sense.

    Then on your document type, representing the page where the courses should be shown you can place a Multiple node picker (From the uComponents package or just use the or the lusini picker (Can't remember the package name, but the guy who made it is named lusini). In the developer section go to the datatypes and make sure the picker you have chosen to use has the start node set to the id of the "Courses repository".

    When you go to your document type, representing the page with courses you can now select all the courses you want to get information from and display them in meaningful tabs.

    Does this approach make sense to you? :-)

    /Jan

  • suzyb 476 posts 934 karma points
    May 08, 2011 @ 22:31
    suzyb
    0

    Yes it does.

    Thanks a lot Jan.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 12x admin c-trib
    May 08, 2011 @ 22:59
    Jan Skovgaard
    0

    I'm glad to hear that - please don't hesitate to ask further questions if you're in doubt about anything :-)

    /Jan

  • phonsie 3 posts 21 karma points
    Feb 01, 2012 @ 09:34
    phonsie
    0

    Hi,

    There's an explanation of how to use an accordion layout at http://blog.pbdesk.com/2011/02/re-usable-jquery-accordion-for-umbraco.html

    Below is a modifed version of the XSLT file which can be used for tabs in the same way as the accordion. You can just add more tabs with the Repeater then as mentioned in the article above.

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="propertyAlias" select="string('Tabs')" />
    <xsl:template match="/">
    <xsl:if test="$currentPage/tabs/items/item">
    <div id="tabs">
    <ul>
    <xsl:for-each select="$currentPage/tabs/items/item">
    <li><a href="#{position()}"><xsl:value-of select="./data [@alias = 'TabHeader']" disable-output-escaping="yes" /></a></li>        
    </xsl:for-each>
    </ul>
    <xsl:for-each select="$currentPage/tabs/items/item">
    <div id="{position()}">
    <xsl:value-of select="./data [@alias = 'TabContent']" disable-output-escaping="yes" />
    </div>
    </xsl:for-each>

    </div> <!-- end of tabs div-->
    <script type="text/javascript">
    <![CDATA[
    $(function() {
    $("#tabs").tabs(); 
    });
    ]]> 
    </script>
    </xsl:if>
    </xsl:template>

    Just another way of doing it :)


    Phonsie.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies