Reputation: 147
I have some code blocks that I include on every page: header.asp, footer.asp etc.
They exist under the subfolder /myincludes/ on my main domain.
So naturally I use the command
<!--#include virtual="/myincludes/header.asp"-->
on my pages to include them, and it works just fine.
The thing is, from time to time I want to change the subdirectory's name (to something like /myincludes2/)
But I'd prefer it if I wouldn't have to re-write all of the include virtual commands all over again.
I tried doing this:
<% thefolder="/myincludes2" %>
<!--#include virtual=thefolder&"/header.asp"-->
<!--#include virtual=thefolder&"/footer.asp"-->
But it just doesn't work.
Upvotes: 0
Views: 866
Reputation: 106
Could you create a single file that is reference on every page such as:
<!--#include virtual="/root-includes.asp"-->
Then within this file have:
<!--#include virtual="/myincludes/header.asp"-->
<!--#include virtual="/myincludes/header.asp"-->
That way if you change the folder name you only have to reference it in one file. It also allows the use of further code (select case statement for example) to further manipulate the references to includes files. The only downside is an initial rewriting of the include path
*just seen @Lankymart answer which is the same as I suggested
Upvotes: 2