Click to See Complete Forum and Search --> : need help using multiple include files...


chqdznr
09-11-2006, 01:02 PM
Hi,

I was reading on a few forums and googling all morning trying to find code for using one include file to call multiple include files for various asp pages. For example, we have created nav bars for several regions in the US. As such, each region needs a unique top and right nav to include geographic specific information. I've created 6 include files, but I would like to put all the nav include files in one main include file and call the unique include files as needed.

I started doing a select case or If then functions. Now once that's done, (being a newbie) I don't understand how to write the asp code that calls the unique include file on the page where it applies.

Here's where I started:

[code]
<%
select case action
case "region_al"
%>
<!--#include virtual="/include/al/top_right.inc"-->
<%
case "region_la"
%>
<!--#include virtual="/include/la/top_right.inc"-->
<%
case "region_az"
%>
<!--#include virtual="/include/az/top_right.inc"-->
<%
case "region_tx"
%>
<!--#include virtual="/include/tx/top_right.inc"-->
<%
case "region_nm"
%>
<!--#include virtual="/include/nm/top_right.inc"-->
<%
case "region_ok"
%>
<!--#include virtual="/include/ok/top_right.inc"-->
<%
case else
%>
<!--#include virtual="/include/all/top_right.inc"-->
<%
end select
%>
[code]

Can I put the above case function in one include file, put that include file on every page, and then if a particular page matches one of the cases listed, the appropriate include file containing the particular navigation will be diplayed? If so, how would I write the asp code on the page so that this will happen?

OR,

What would be even better is to get rid of all the include files, place the code for each include within ONE include file, name them as "case" or use "if then" statements (I guess) and then have the appropriate nav code write to the appropriate page.


For instance, on the texas page, I want the texas navigation to display, on the Oklahoma page, I want the OK navigation to display and so on. But I don't want a whole bunch of include files. Just one with all the navigation for each page in that one include file. If this can be doable, I would need to know how to get the right navigation to show up on the right page.

I would really prefer to do it this way to merge all the include files into one.

On the asp page, would I code something like this:

[code]
<%
Site_Subname = ""
Page_Title = "Texas Region"
Home_Page = true
Site_style = tx_top_right
%>
[code]

and then in the include file I'd write:

[code]
<% If Site_Style = case tx_top_right Then %>

<table class="MainContentTable" align="center" cellpadding="0" cellspacing="0" border=0>
<tr>
<td colspan="2" class="SecondaryNavContainer">
<ul id="nav">
<li>
<div CLASS="SecondaryNavCell">
<a href="subsection_home.asp" class="SecondaryNavLink">Subsection 1</a>
</div>
<ul>
<li><a href="content_page.asp" CLASS="ddLink">Content Page</a></li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
[code]

I know that was a long explanation :o, and I'm using to different ways to set up this function, but I'm trying to make sense of it all, but getting more confused! Could someone tell me how to code something like this in the include file as well as on each asp page? :confused:


THANKS in advance!!!!

Ubik
09-14-2006, 12:24 PM
"Can I put the above case function in one include file, put that include file on every page..."

Yes.

However, it seems like you might be thinking that Include files are your solution, when they probably aren't the best way to attack the different navigation elements you have.

While you can do the massive case statement, and it will appear to work, however, this isn't the best solution for the server, because ALL of the include files will be included, but the code in the include files will not be executed unless the case statement is true.

I would suggest making a generic nav file, then populate it with dynamic navigation information based on which state the user is using.