[thelist] SSI's: what are the rules for depth and variable scope? (aardvark, a little help?)

Chris W. Parker cparker at swatgear.com
Mon Jun 10 13:01:01 CDT 2002


> from what i see, it's one i proposed, yes... it's also what i use on
> my site and a few client sites...

yes, that's what i'm talking about.

> > however, both pageA AND pageB need to use the same source
> file. we'll
> > call that pageC.
>
> what source file?  perhaps a breadcrumb function?

functions and database variable declarations...

i created a simple test pageA. here are the contents of that page.
---------------------------------------------
	Dim SQL
	Dim rsProdDetail

	SQL = "SELECT prodID FROM sfProducts"

	Set rsProdDetail = Server.CreateObject("ADODB.Recordset")
	rsProdDetail.Open SQL, cnn, adOpenForwardOnly, adLockReadOnly

	closeObj(rsProdDetail)
	closeObj(cnn)
---------------------------------------------

'cnn' comes from pageC which looks like this...
---------------------------------------------
	' Variable Declarations
	Dim cnn, DSN_Name

	' Object Creation
	Set cnn = Server.CreateObject("ADODB.Connection")

	DSN_Name = "storefrontTest2"

	cnn.open DSN_Name
---------------------------------------------

> > so if i do an include statement of pageC inside both pages A and B i
> > get an error. (i've seen a few different errors depending on which
> > combination of where and what include so i don't know if this is the
> > correct error exactly) "Name Redefined". and that would of course be
> > because both files are being included and therefore variables are
> > being redefined. that makes sense.
>
> right... but don't include anything in your content page -- only
> include files into the template, and then the template gets included
> (with its includes) into the content page...  only *one* include on
> your content page...

ok. i tried that but i get an error...
"Operation is not allowed on an object referencing a closed or invalid
connection."

what's happening, i think, is that by the time "Sub Content" is inserted
into pageB (the template) the connection to the database has already
been closed earlier in the template page. so that means it needs to be
reoponed when it comes to the Content of the page. i guess one thing i
could do is not close the 'cnn' variable until the end of the template
(pageB). but as far as i know that can/will create a performance problem
with the page and the db connection being open so long.

if i have 100 different pages (referred to as pageA's) where each one
needs a different include file (functions, etc.), won't pageB be wasting
server time parsing unnecessary include files if you include them (the
needed pageA includes) in pageB rather than their respective pageA's? in
other words instead of having one include (not counting the
pageB/tempalate include) in each pageA you would have 100 includes in
pageB.

> try what i said above -- copy your content page, dump all the code
> from the appropriate page into the place it's included...
>
> lemme know what happens then...

i did follow your recommendation and also what i thought of earlier. all
the includes so far, except for the template include of course, are
included in the template (pageB), and i also ONLY close the 'cnn' db
connection variable at the end of the template file. this has solved my
problem, although i think it will cause a performance hit. any other
suggestions/workarounds for this?

thanks for all the help so far, and the offer to look at the code. i can
zip up everything necessary if need be and send it to you if it comes to
that.

chris.



More information about the thelist mailing list