Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetFileName

Status
Not open for further replies.

danieljoo

MIS
Oct 9, 2002
43
0
0
US
I would like to make my website more dynamic/easier to maintain. I have a main menu on my website with links like Products and Services. These main menu items when clicked on, will display thier own submenu items. These submenu items may change over time. Since each submenu page also displays the links for the other submenu items in that category, i do not want to go through all the pages and update the submenu links when a change is to be made. What I would like to do is use an include file (submenu.asp). This include file should check the name of the page to see which main menu item it falls under and display the appropriate submenu. The subpages will have the following structure -- mainmenuitem_submenuitem.html (ex. products_newitems.html). Can anyone offer assistance on how, within the include file, I can check the name of the current page and if it is similar, for example to products, it will display the submenu for products. Thank you.
 
I would set up something a bit different. You could use a database to hold the catagories and sub-catagories, which means you could then create another page to actually edit these or add new ones. I would set it up like so:
Table: Category
cat_id - autonumber or auto incrementing integer
cat_name - text field to hold the name

Table: SubCategory
sub_id - autonumber or auto incrementing integer
cat_id - category this belongs to
sub_name - text field to hold the name

Then the easiest way to use this would be in the submenu.asp page.
Code:
'1 create your database connection and execute a query
'   "SELECT cat_name, sub_name FROM Category, SubCategory WHERE Category.cat_id = SubCategory.cat_id"
'
'2 then to display them simply: (pretend rs is our recordset
Dim curCat

rs.MoveFirst

Do Until rs.EOF
   'if the cat from the recordset is different form the last one we looked at
   If rs(&quot;cat_name&quot;) <> curCat Then
      'if this is not the first cat to be displayed
      If curCat <> &quot;&quot; Then
         Response.Write &quot;</div></div>&quot; 'finish cat and sub divs
      End if
      Response.Write &quot;<div class=&quot;&quot;cat_box&quot;&quot;>&quot; & rs(&quot;cat_name&quot;) & &quot;<div class=&quot;&quot;sub_box&quot;&quot;>&quot;
      curCat = rs(&quot;catName&quot;)
   End If
   Response.Write &quot;<a href=&quot;&quot;&quot; & rs(&quot;cat_name&quot;) & &quot;_&quot; & rs(&quot;sub_name&quot;) & &quot;.asp&quot;&quot;>&quot; & rs(&quot;sub_name&quot;) & &quot;</a><br>&quot;
   rs.MoveNext
Loop
'finish last cat and sub divs
Response.Write &quot;</div></div>&quot;

Now I don't know what your javascript looks like for the menu, but the above might be a good place for you to start.

other additions would include a page that allowed you to add a new category, select a category from a drop down box and add or delete a category from it, etc.

You could also use the FileSystemObject to validate that the files exists as category_subcategory.asp before displaying the link so you know you won't be displaying dead links.

The reason I split it into two tables above is in case you want to add extra content on either level.

-Tarwn

[sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top