Announcement

Collapse
No announcement yet.

Making a list of products on each page

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

    Making a list of products on each page

    If it possible to make a list of all products appearing on each page? i.e. so I can generate an index, say on the left of the page.

    #2
    Hi,

    It's not something that can be done automatically. However you can create your own javascript file that contains all your products and then tweak the javascript provided in our Advanced User Guide to suit. I did this by:

    - creating a file called Act_product_tree.js in the site1 folder and added the following:

    Code:
    var product_tree = new CreateArray(3);
    product_tree[1].sName = "Select Items From A List";
    product_tree[1].pChild = new CreateArray(3);
    product_tree[1].pChild[1].sName = "Black Ink Cartridge"
    product_tree[1].pChild[2].sName = "Colour Ink Cartridge";
    product_tree[1].pChild[3].sName = "Ink Jet Printer";
    product_tree[2].sName = "Products With A Range of Options";
    product_tree[2].pChild = new CreateArray(1);
    product_tree[2].pChild[1].sName = "Diary";
    product_tree[3].sName = "Basic Products";
    product_tree[3].pChild = new CreateArray(1);
    product_tree[3].pChild[1].sName = "Calculator";
    If you want a full list of products to appear on all pages then add the following between the <HEAD> and </HEAD> tags in your primary template:

    Code:
    <SCRIPT LANGUAGE="JavaScript" SRC="Act_product_tree.js" TYPE="text/javascript"></SCRIPT>
    
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function ProductList(ab)
    {
    var strProdID = '<table border=0>';
    for (var y=1;y<=ab.length;y++)
    {
    if (ab[y].sName !=null)
    {
    if (ab[y].pChild)
    {
    for (var z=1;z<=ab[y].pChild.length;z++)
    {
    if (z <= ab[y].pChild.length)
    {
    strProdID += '<tr><td><span class="actxxsmall">' + ab[y].pChild[z].sName + '</span></td></tr>';
    }
    }
    }
    }
    }
    strProdID += '</table>' 
    return strProdID
    }
    //-->
    </SCRIPT>
    - Then put the following in the body of the template where you want the list to appear:

    Code:
    <script language=Javascript1.1>document.write(ProductList(product_tree))
    </script>
    If you only want the products relating to that page to show then you need to create a primary template for each section and you would change the code between the head tags as follows:

    Code:
    ]<SCRIPT LANGUAGE="JavaScript" SRC="Act_product_tree.js" TYPE="text/javascript"></SCRIPT>
    
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function ProductList(ab)
    {
    var strProdID = '<table border=0>';
    if (ab[1].sName !=null)
    {
    if (ab[1].pChild)
    {
    for (var z=1;z<=ab[1].pChild.length;z++)
    {
    if (z <= ab[1].pChild.length)
    {
    strProdID += '<tr><td><span class="actxxsmall">' + ab[1].pChild[z].sName + '</span></td></tr>';
    }
    }
    }
    }
    strProdID += '</table>' 
    return strProdID
    }
    //-->
    </SCRIPT>
    Note that the [1] in the code depicts which part of the Act_product_tree.js file it pulls out - so [1] is looking at lines that start 'product_tree[1].' In this example that is for 'Select Items From A List', so you would only apply this template to the 'Select Items From a List' section.

    I hope this helps.
    ********************
    Tracey
    SellerDeck

    Comment


      #3
      Thanks Tracey - I'll give that a try.
      Russell

      Comment

      Working...
      X