SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help on the best way to do this in ASP

    Hi im adding a new responsive skin to my website, it is long overdue, but the problem is that the old code for the categories, (which loads categories, and subcategories and subsubcategories)
    wont work because of the order that the data is loaded from the database.

    Currently it pulls all the categories from the database and loops through them, as it goes it checks the database for any sub categories and any subsub categories and displays them.

    However because of the layout of the new code, it now needs to know before writing any categories if it needs to set a category as a dropdown or not.
    It needs a different class and div tag for categories that have subcategories and subsubcategories, to those that dont.

    To explain imagine an asp page called areas.asp with a value passed to it in the URL as follows:

    areas.asp?subcatagoryid=21

    The page loads all the top level categories in the database, if one matches then it displays it in bold, and loops through all the next categories.
    If it doesnt match it loads the recordset details and loops through all the categories looking for a match and displaying them on the page as it goes,
    however if the category id is for a subcategory or a subcategory of a subcategory then although the values are loaded in to the page and viewable in the source code,
    they dont show because the correct class isnt loaded.

    So I need a way to loop through all the categories and subcategories first, looking for a matching categoryid. If there isnt one then load the category as normal,
    but if there is a match then all those categories and subcategories need the correct Div class value loaded when displayed on the page so that they show properly.


    Can anyone help with this code?

    This is a rough idea of what I think I need to do, if you know a better or quicker way or can help to code it please let me know:
    <%
    loop through TopLevel then Sublevel then subsublevel for URLstring categoryid

    Set DropDown = No

    If Categoryid found in TopLevel then
    Set DropDown = yes
    End If

    If Categoryid found in SubLevel then
    Set DropDown = yes
    End If

    If categoryid found in SubSub then
    Set DropDown Yes
    End IF


    %>
    before displaying recordset
    <%
    If DropDown = Yes Then
    Display Code for drop down level category for main cat

    Else
    Display normal Code for Categories
    %>

    If anyone wants to see the page or my code please pm me...

  2. #2
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is an example of the HTML code that I need to achieve by looping through the categories and loading the correct menu structure when a subcategory or sub sub category id is loaded:

    <!--Category-->
    <div class="panel panel-default">
    <div class="panel-heading">
    <h4 class="panel-title">
    <a data-toggle="collapse" href="#collapseCategory" class="collapseWill">
    <span class="pull-left"> <i class="fa fa-caret-right"></i></span> Category
    </a>
    </h4>
    </div>

    <div id="collapseCategory" class="panel-collapse collapse in">
    <div class="panel-body">
    <ul class="nav nav-pills nav-stacked tree">
    <li class="active dropdown-tree open-tree" > <a class="dropdown-tree-a" > <span class="badge pull-right">42</span> WOMEN COLLECTION </a>
    <ul class="category-level-2 dropdown-menu-tree">
    <li class="dropdown-tree open-tree"> <a class="dropdown-tree-a" href="#"> Tshirt</a>
    <ul class="category-level-2 dropdown-menu-tree">
    <li><a href="sub-category.html">New</a> </li>
    <li><a href="sub-category.html">Denim</a> </li>
    <li><a href="sub-category.html">Fragrances</a> </li>
    <li><a href="sub-category.html">Scarf</a> </li>
    <li><a href="sub-category.html">Sandal</a> </li>
    <li><a href="sub-category.html">Winter Collection</a> </li>
    <li><a href="sub-category.html"> Accessories</a> </li>
    </ul>
    </li>
    <li><a href="sub-category.html"> Shirt</a> </li>
    <li><a href="sub-category.html"> Fragrances</a> </li>
    <li><a href="sub-category.html"><Strong>Scarf</strong></a> </li>
    <li><a href="sub-category.html">Sandal</a> </li>
    <li><a href="sub-category.html">Winter Collection</a> </li>
    <li><a href="sub-category.html">Men Accessories</a> </li>
    </ul>
    </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> MEN COLLECTION </a> </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> Baby & Kids </a> </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> Home & Kitchen </a> </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> Baby & Kids </a> </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> More Stores </a> </li>
    <li > <a href="#"> <span class="badge pull-right">42</span> Offers Zone </a> </li>
    </ul>
    </div>
    </div>
    </div> <!--/Category menu end-->

    In this example the "Scarfs" category was loaded, which happens to be a sub category of the "Tshirt" category, which itself is a subcategory of the main top level "Women Collection" Category.
    as poorly illustrated below:

    WOMEN COLLECTION
    >Tshirt

    >>New
    >>Denim
    >>Fragrances
    >>Scarf
    >>Sandal
    >>Winter Collection
    >>Accessories

    >Shirt
    >Fragrances
    >Scarf
    >Sandal
    >Winter Collection
    >Men Accessories

    42 MEN COLLECTION
    42 Baby & Kids
    42 Home & Kitchen
    42 Baby & Kids
    42 More Stores
    42 Offers Zone

    I need to loop though and know before I display any category if it needs the: class="category-level-2 dropdown-menu-tree" or other drop down class loading or just a standard <li> tag.

    Can anyone help with this code?

  3. #3
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe you could use one like this

    http://aspwebsolution.com/articles/c.../asp/index.htm

  4. #4
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by webber123456 View Post
    Thank you for your reply, but it doesnt help me with my specific situation.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •