I have decided to write a template ASP file as most of the ones I write do the same thing (run a query and show a table) with slight variations between each one.
I usually check one field to see if it’s time to start processing the input…
if request.querystring(“field”) = “” then
But I am pretty sure this isn’t the most correct way of doing it. So what is?
Another question. I want to give me the option of including a file or not. Since an ASP include is already using html comments is there a way of doing it without adding asp wrappers (<% and %> and then adding a quote?) that seems ott and only confuses the code… I’m tring to simplify the code.
In other words I want a way to disable a line like this…
You can’t do an include that way. Includes are processed BEFORE any code is executed. If you want to do a conditional include, you need to use the EXECUTE method.
What you might not be realizing is that I’m creating a template. The idea being that I’ll create a new file with it and manually, with my fingers, make the include ‘work’ again.
So the thing that decides the condition is not code, it’s me. (in the future when I come to use this template)
Not to my knowledge (not that it’s impossible … I’m no encyclopedia …). I would just split the string at “.asp”, take Array(0), and re-concatenate it with a new “.asp” on the end.
Who will be viewing this template? If you might publish the page without activating the include, I’d recommend commenting it out with the leading apostrophe, instead. The way you do it above, anyone can see the name of your included file by choosing “view source” in their browser. The other way, it’s invisible. Just something to consider.
Is it right for comments to be included as page source? Wouldn’t it be more sensible for the browser to leave them out?
Anyway, the template is likely only ever to be seen by me, but anyone who uses my creations (a medium size team of people) can, if they wanted to, view source and see what’s in those includes anyway… That is to say they’ll see the compiled HTML, not the ASP
p.s. I’ll give your string manipulation idea a try.
I think what I was asking might be possible in PHP but that isn’t much more than a guess.