Announcement

Collapse
No announcement yet.

displaying sub-sections for given section

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    displaying sub-sections for given section

    hi community

    firstly, apologies for long windedness of this post, any help/pointers greatly appreciated.

    i'm trying to create a sub-navigation that displays only the sub-sections for the currently chosen section. i have hacked together some code from other examples found but i'm unsure how to access the current section?

    i've created a 'parentsection' variable that allows me to associate a sub-section to it's parent but am unsure how to 'say'

    if parentsection == currentlychosensection then
    display this sub-section

    also my parentsection var makes use of 'use parent' within the sub-section pages and i don't know how to access a variable value when it's set to this?

    current code is this

    <ul class="list-subnav">

    <!-- entire section list -->
    <!--
    whats going on
    if current section level is > previous section level and current section level == 2
    create a new ul of subnav-sub-category

    if current section level is > previous section level and current section level == 3
    create a new ul of subnav-sub-sub-category


    if current section level < previous section level
    close the ul

    if current section level < previous section level and current section level == 1
    (we're closing a level 3 down to the base level)
    so close the li / ul / li

    if current section level is == previous section level OR current section level is < previous section level
    close the li

    always start an li

    save the current section level

    -->

    <actinic:block type="EntireSectionList" >

    <actinic:block php="true" >
    if (("<actinic:variable name="SectionLevel" />" > $previousSectionLevel) && ("<actinic:variable name="SectionLevel" />" == 2))
    echo "<ul class='list-subnav-sub-category'>";
    </actinic:block>

    <actinic:block php="true" >
    if (("<actinic:variable name="SectionLevel" />" > $previousSectionLevel) && ("<actinic:variable name="SectionLevel" />" == 3))
    echo "<ul class='list-subnav-sub-sub-category'>";
    </actinic:block>

    <actinic:block php="true" >
    if ("<actinic:variable name="SectionLevel" />" < $previousSectionLevel)
    echo "</ul>";
    </actinic:block>

    <actinic:block php="true" >
    if ("<actinic:variable name="SectionLevel" />" < $previousSectionLevel && "<actinic:variable name="SectionLevel" />" == 1)
    echo "</li></ul></li>";
    </actinic:block>


    <actinic:block php="true" >
    if (("<actinic:variable name="SectionLevel" />" == $previousSectionLevel || "<actinic:variable name="SectionLevel" />" < $previousSectionLevel))
    echo "</li>";
    </actinic:block>

    <li><a href="<actinic:variable name="SectionPageName"/>" <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionID%22%20%2f%3e%20%3d%3d%20%3cactinic%3avariable%20name%3d%22MainSection%3a%3aSectionID%22%20%2f%3e" >class="selected"</actinic:block>><actinic:variable name='SectionName'/></a>

    <actinic:block php="true" >
    $previousSectionLevel = "<actinic:variable name="SectionLevel" />";
    </actinic:block>

    </actinic:block>


    </ul>

    #2
    Have a look on drillpine.biz at the accordion menu, you won't go bald that way and it will only cost you £40 and will be installed in 5 minutes flat.

    Comment


      #3
      Originally posted by jcroughton View Post
      hi community

      firstly, apologies for long windedness of this post, any help/pointers greatly appreciated.

      i'm trying to create a sub-navigation that displays only the sub-sections for the currently chosen section. i have hacked together some code from other examples found but i'm unsure how to access the current section?
      Do a search in the forum for ' freebie: popout section aware nav. ', and look at the code given and the description. This can do exactly what you want by changing the parameters passed to the code. I found is a great tool for creating custom navigation when combined with javascript and or css.

      Malcolm

      SellerDeck Accredited Partner,
      SellerDeck 2016 Extensions, and
      Custom Packages

      Comment


        #4
        hi leehack and malbro, thanks for your comments.

        leehack - i'd seen drillpine.biz accordian menu but i don't think it did what i wanted (i.e. only display the sub-sections within the current section and not all the sections and their subsections)

        malbro, i'll do a search but i'm trying to create a menu without javascript so it'll be non-javascript compliant (otherwise users with javascript disabled won't be able to nav the store)

        i did manage to sort it in the end using some custom variables and php blocks/ifs, my (cleaned up) code is below, thanks all

        <ul class="list-subnav">

        <!-- entire section list -->
        <!--
        whats going on
        initialise the php vars

        save the current parent section for comparison with the saved parent section (i.e. the parent section we are in)

        if the current parent section == saved parent section then start the sub nav

        if current section level is > previous section level and current section level == 2
        create a new ul of subnav-sub-category

        if current section level is > previous section level and current section level == 3
        create a new ul of subnav-sub-sub-category

        if current section level is > previous section level and current section level == 4
        create a new ul of subnav-products

        if current section level < previous section level
        close the ul

        if current section level < previous section level and current section level == 1
        (we're closing a level 3 down to the base level)
        so close the li / ul / li

        if current section level is == previous section level OR current section level is < previous section level
        close the li

        always start an li

        save the current section level

        -->
        <actinic:block php="true" >
        $previousSectionLevel = 0;
        $savedParentSection = "<actinic:variable name="ParentSectionAlias" selectable="false" />";
        </actinic:block>

        <actinic:block type="EntireSectionList" >

        <actinic:block php="true" >

        $currentParentSection = "<actinic:variable name="ParentSectionAlias" selectable="false" />";

        if ($currentParentSection == $savedParentSection) {

        if (("<actinic:variable name="SectionLevel" selectable="false" />" > $previousSectionLevel) && ("<actinic:variable name="SectionLevel" selectable="false" />" == 2))
        echo '<ul class="list-subnav-sub-category">';

        if (("<actinic:variable name="SectionLevel" selectable="false" />" > $previousSectionLevel) && ("<actinic:variable name="SectionLevel" selectable="false" />" == 3))
        echo '<ul class="list-subnav-sub-sub-category">';

        if (("<actinic:variable name="SectionLevel" selectable="false" />" > $previousSectionLevel) && ("<actinic:variable name="SectionLevel" selectable="false" />" == 4))
        echo '<ul class="list-subnav-products">';

        if ("<actinic:variable name="SectionLevel" selectable="false" />" < $previousSectionLevel)
        echo '</ul>';

        if ("<actinic:variable name="SectionLevel" selectable="false" />" < $previousSectionLevel && "<actinic:variable name="SectionLevel" selectable="false" />" == 1)
        echo '</li></ul></li>';

        if (("<actinic:variable name="SectionLevel" selectable="false" />" == $previousSectionLevel || "<actinic:variable name="SectionLevel" selectable="false" />" < $previousSectionLevel))
        echo '</li>';


        echo '<li><a href="<actinic:variable name="SectionPageName" selectable="false" />" <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionID%22%20%2f%3e%20%3d%3d%20%3cactinic%3avariable%20name%3d%22MainSection%3a%3aSectionID%22%20%2f%3e" >class="selected"</actinic:block>><actinic:variable encoding="actinic" name="SectionName" selectable="false" /></a>';

        $previousSectionLevel = "<actinic:variable name="SectionLevel" selectable="false" />";
        }
        </actinic:block>

        </actinic:block>


        </ul>

        Comment


          #5
          Surely you don't want them all on show at the same time? It would be like the longest and hardest to use menu there is if you have more than say 100 products or so. People having to scroll to see parts of your menu is not a good idea IMO. Do you have an example site loaded so we can get a feel for what you are working with?

          Comment


            #6
            Originally posted by jcroughton View Post
            malbro, i'll do a search but i'm trying to create a menu without javascript so it'll be non-javascript compliant (otherwise users with javascript disabled won't be able to nav the store)
            Javascript is not necessary to use the code which is all in php, the javascripts allowed the code to be active on any given page rather than static. Gabes code produces a different menu on each page, depending on the conditions you set. Changing pages makes the menu appear to change, javascript additions make the menu more interactive, which is how I use it. I found the code very useful in learning how Actinic navigation works and IMO it also produces a better menu system than using the code available within Actinic especially for large sites.

            As previously mentioned Drillpine produce some good menu systems which install easily and work very well, I have used the collapso menu on one project but having now learnt a lot more I prefer to mix my own.

            Incidentally many javascripts will degrade gracefully when javascript is disabled so you can still navigate the store, you just lose the interactive effects. Dynamicdrive.com has a large number of useful scripts including an accordion one, and also css tricks for use with menus.

            It all depends on how much you like writing code rather than designing web sites

            Malcolm

            SellerDeck Accredited Partner,
            SellerDeck 2016 Extensions, and
            Custom Packages

            Comment


              #7
              leehack, no i wouldn't do that, as you say having a massive scroll would be horrible. i'm going to use css to hide the products at the final level so the list doesn't get too long. no site loaded yet, need to work that out

              malbro, thanks again, i'll take a look

              Comment

              Working...
              X