Announcement

Collapse
No announcement yet.

JS Section lists in columns

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

    JS Section lists in columns

    Is there a JS guru out there who can change the supplied section list in 2 column (page 38 AUG) into 4 columns.

    rather than have 2 columns of 8 I want to get 4 cols of 4. I've already stripped out the child sections as I only need the top levels



    Code:
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function SectionList(ar)
    {
    var col = 1;
    var strIDs = '<table width="100%"><tr><td valign=top width="50%">';
    for (var i=1;i<=ar.length;i++)
    {
    if (ar[i].sURL !=null)
    {
    strIDs += '<a href="' + ar[i].sURL + '"><span class="actxsmall">' + ar[i].sName + '</span></a><br>';
    {
    
    
    }
    if ( col == 1 )
    {
    strIDs += '</td><td valign=top width="50%">';
    col++;
    }
    else
    {
    strIDs += '</td></tr><tr><td valign=top width="50%">';
    col = 1;
    }
    }
    }
    if ( col == 1 ) strIDs += '</td><td>';
    return strIDs + '</td></tr></table>';
    }
    //-->
    </SCRIPT>

    #2
    Hi Jo

    I don't have the answer for you but I'm currently working on something very similar...

    One question for you - does the list that this generates show the relevant 2 levels of subsections for you?

    The code
    Code:
    <!--@act NETQUOTEVAR:CHILDSECTIONS_RAW -->
    only outputs 1 level of child sections into the array it creates at the head of my pages... this inevitably leaves me missing a level of subsections

    Have you experienced this?

    Jos
    Thanks

    Jos Medinger

    Tel : 01978 843 962
    www.internetology.co.uk
    Actinic / E-Commerce Hosting, Design & SEO
    ______________________________________

    Comment


      #3
      Hi Jos

      I have stripped out the chid/subsections as I don't want them.

      I have 16 top level sections which i want to display 4 x 4 at the top of the page (rather than using a left hand nav bar

      Comment


        #4
        HTML Code:
        <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
        <!--
        function SectionList(ar)
        {
        	var col = 1;
        	
        	var strIDs = '<table width="100%"><tr><td valign=top width="25%">';
        	
        	for (var i=1;i<=ar.length;i++) {
        		if (ar[i].sURL !=null) {
        			strIDs += '<a href="' + ar[i].sURL + '"><span class="actxsmall">' + ar[i].sName + '</span></a><br>';
        		}
        		if ( col != 4 ) {
        			strIDs += '</td><td valign=top width="25%">';
        			col++;
        		} else {
        			strIDs += '</td></tr><tr><td valign=top width="25%">';
        			col = 1;
        		}
        	}
        	
        	return strIDs + '</td></tr></table>';
        }
        //-->
        </SCRIPT>
        That should do the job
        Matt
        Actinic User since v.3

        Custom Actinic Site Specialist:
        <a href="http://www.glowsticksdirect.co.uk/">GlowSticksDirect.co.uk</a>
        <a href="http://www.digishopdirect.co.uk/">DigiShopDirect.co.uk</a>
        <a href="http://www.calibreshopping.co.uk/">CalibreShopping.co.uk</a>

        Comment


          #5
          Thats brilliant, it works too, thanks Matt

          Comment


            #6
            Pfffffft, of course it works

            I had to check it before i posted it

            No probs
            Matt
            Actinic User since v.3

            Custom Actinic Site Specialist:
            <a href="http://www.glowsticksdirect.co.uk/">GlowSticksDirect.co.uk</a>
            <a href="http://www.digishopdirect.co.uk/">DigiShopDirect.co.uk</a>
            <a href="http://www.calibreshopping.co.uk/">CalibreShopping.co.uk</a>

            Comment


              #7
              Do you know if it would be possible to tweak this Javascript so that it DIDN'T display the top level of sections - just the 2 subsequent child ones below the top level?

              ie.

              Top Level Section 1 (not displayed)
              ----Child Section 1 (displayed)
              --------Child Section 1a (displayed)
              ----Child Section 2 (displayed)
              Top Level Section 2 (not displayed)

              Jos
              Thanks

              Jos Medinger

              Tel : 01978 843 962
              www.internetology.co.uk
              Actinic / E-Commerce Hosting, Design & SEO
              ______________________________________

              Comment


                #8
                HTML Code:
                <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
                <!--
                function SectionList(ar)
                {
                var strIDs = '<table border=0 width=95% cols=2>';
                for (var i=1;i<=ar.length;i++)
                  {
                  if (ar[i].sURL !=null)
                    {
                    /* strIDs += '<table><tr><td colspan=2><a href="' + ar[i].sURL + '"><span class="actxxsmall">' + ar[i].sName +  '</span></a></td></tr></table>'; */
                      {
                      if (ar[i].pChild)
                        {
                        for (var j=1;j<=ar[i].pChild.length;j++)
                          {
                strIDs += '<table><tr><td><img src=shim.gif width=5></td><td><a href="' + ar[i].pChild[j].sURL + '"><span class="actxxsmall">' + ar[i].pChild[j].sName + '</span></a></td></tr></table>';          
                 
                            {
                            if (ar[i].pChild[j].pChild)
                              {
                              for (var k=1;k<=ar[i].pChild[j].pChild.length;k++)
                                {
                 
                  strIDs += '<table><tr><td width="20"></td><td><a href="' + ar[i].pChild[j].pChild[k].sURL + '"><span class="actxxsmall">' + ar[i].pChild[j].pChild[k].sName + '</span></a></td></tr></table>';
                 
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                strIDs + '</table>' 
                return strIDs
                }
                //-->
                </SCRIPT>
                That should do what you want...
                Matt
                Actinic User since v.3

                Custom Actinic Site Specialist:
                <a href="http://www.glowsticksdirect.co.uk/">GlowSticksDirect.co.uk</a>
                <a href="http://www.digishopdirect.co.uk/">DigiShopDirect.co.uk</a>
                <a href="http://www.calibreshopping.co.uk/">CalibreShopping.co.uk</a>

                Comment


                  #9
                  Thanks Matt

                  That's worked a treat - must buy myself a "Javascript for Dummies" book one of these days!

                  Cheers

                  Jos
                  Thanks

                  Jos Medinger

                  Tel : 01978 843 962
                  www.internetology.co.uk
                  Actinic / E-Commerce Hosting, Design & SEO
                  ______________________________________

                  Comment


                    #10
                    I want to do something similar to what is discussed here, but only want the links from the current section to be displayed not all the child links in the site.

                    The script works fine with <!--@act NETQUOTEVAR:SECTIONTREE_RAW --> but not with <!--@act NETQUOTEVAR:CHILDSECTIONS_RAW -->. Am i on the right lines?

                    I want to achieve

                    Current section - not displayed
                    --child section 1 - displayed
                    ----child section 2 - displayed
                    Next section - not displayed
                    --child section 1 - not displayed
                    etc

                    thanks in advance

                    caroline

                    Comment


                      #11
                      Hi Caroline,

                      NETQUOTEVAR:CHILDSECTIONS_RAW will just show you the child sections and not the main top level sections. I can't see a way of not displaying the next child section in your examples. All coding on the above just shows the coding for the whole childsection, using the IF statement.

                      Kind Regards
                      Nadeem Rasool
                      SellerDeck Development

                      Comment

                      Working...
                      X