Dynamic (?) include

M

Mike Mueller

My home page is time sensitive and changes on a weekly basis. I currently
have the home page set to use jscript to check what week it is and redirect
to the current weeks page. This works fine, but I have concerns mostly in
regards to search engine placement. What I want to do is to use an >Include
type of statement to pull that page into the default site as opposed to just
redirecting to it. Looking for any and all comments and suggestions on
this.

Mike
 
T

Thomas A. Rowe

You would need to use a server-side script, such as ASP, PHP, etc. to
include the current weeks content in you default page (home page).

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

Hi Mike,

Say your week pages are named as yearmonthday.htm eg today's page would be
2004126.htm you could use server.transfer, eg
<%
server.execute year(date) & month(date) & day(date) & ".htm"
%>
This would pull in the current content to yout page. Normal include
statements eg <!--#include file="page.htm"--> wouldn't work too well in any
kind of dynamic setup. I'm assuming asp here
 
D

David Baxter

Your concerns about search engines and jscript redirects are justified.

Spiders can't follow jscript - they need text. Google recommends you
view your web pages in Lynx, a text-based browser. You don't need to
worry about whether your pages look pretty in Lynx, but if Lynx can see
something on your page, so can the 'bots - if Lynx can't see it, neither
can the bots.

This, of course, is only a problem if you need/want those "daily" pages
indexed by search engines...
 
M

Mike Mueller

OK I think I get it- I just need to know the correct syntax. Here is what I
have so far-

<body>
<%
Dim WeekNumber
Dim WeekPage

WeekNumber = DatePart("ww", Date, 1,1)
WeekPage = "default_wk"& WeekNumber &".htm"

%>
<p><!--#include file= WeekPage --></p>
</body>
 
T

Thomas A. Rowe

Almost, but it is not possible to dynamically set a SSI statement.

What kind of content do you want to include, as a database may be a better
solution, then individual pages?

But back to the SSI statement...

<%
<% If WeekPage = "wk1" then %>
<!--#include file="week1.asp" -->
<% End If %>
<% If WeekPage = "wk2" then %>
<!--#include file="week2.asp" -->
<% End If %>

Now the above would require 52 statements and 52 pages, whereas with a
database you wouldn't need any additional pages, just your home page.

Your database could be stuctured at a minimum with the following fields:

RecID = Autonumber/Primary
WkNo = Week Number
Title = Title/Subject
Description = If required
Link = If required



--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

or
<%
WeekNumber = DatePart("ww", Date, 1,1)
WeekPage = "default_wk"& WeekNumber &".htm"
server.execute Weekpage
%>
 
J

Jon Spivey

ps to this - if you went the database route you'd probably want to cache the
data for a week rather than htting the database every time the page is
viewed

Jon
 
M

Mike Mueller

I am not quite ready to go down the database route yet- but it is something
I will keep in mind for the future. There are 2 different sections of the
page that change weekly (activities for this & next weeks), and 1 that
changes bimonthly (next drill). (www.lannonfire.com/default_wk5.htm). If
you can give me other suggestions on my site that would be appreciated also.
I have the pages already done for a couple of weeks, I just am aiming to
have the info change Sunday AM without me having to change files names.

Mike
 
T

Thomas A. Rowe

Mike,

To keep it simple, say for one month at a time, you could do the following,
but you home page must be name with a .asp extensions:

Insert the following before the opening <html> tag on your home page

<%
Dim CurDte
CurDte = Date()
%>


Insert the following in your table in HTML View on your home page, then each
month just change the date ranges

<% If CurDte >= "1/1/2004" and CurDte <= "1/3/2004" then %>
<!--#include file="week1.asp" -->
<% ElseIf CurDte >= "1/4/2004" and CurDte <= "1/10/2004" then %>
<!--#include file="week2.asp" -->
<% ElseIf CurDte >= "1/11/2004" and CurDte <= "1/17/2004" then %>
<!--#include file="week3.asp" -->
<% ElseIf CurDte >= "1/18/2004" and CurDte <= "1/24/2004" then %>
<!--#include file="week4.asp" -->
<% ElseIf CurDte >= "1/25/2004" and CurDte <= "1/31/2004" then %>
<!--#include file="week5.asp" -->
<% Else &>
<!--#include file="None.asp" -->
<% End If %>

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
M

Mike Mueller

Jon-
So I just need to replace
<!--#include file= WeekPage -->
with
server.execute Weekpage
?

Is it best for all the pages getting loaded in to just pull there Meta tags
and place them in the default.asp page?

Mike

"Jon Spivey" replied
 
J

Jon Spivey

Hi,

yes -
<%
server.execute weekpage
%>
is all you need

There's 2 good reasons why this type of code
<%if somevar = "1" then%>
<!--#include file= "page1.htm" -->
<%elseif somevar = "2" then%>
<!--#include file= "page2.htm" -->
....etc
is not good.
1/ Because includes are processed before asp each include will be parsed
before the asp logic can determine which file is actually needed - if you
have any number of includes this will slow your page down considerably
2/ Obviously as there's 52 weeks in the year you're going to have to do a
lot of typing to use includes:)
 
T

Thomas A. Rowe

I disagree on your first point about the speed issue, as we are taking in
ms, and on the second, I did suggest doing a month at a time, and not all 52
weeks, which would allow for only having 5 to 6 pages.

However the best approach would be to drive something like this from a
database.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
M

Mike Mueller

Thomas & Jon-

I appreciate both of your views. I do like the simplicity that the
server.execute option has. Unfortunately I get an error about the
execution. Not a problem. I implemented Thomas' solution and that works
fine. The amount of lines of script is not too bad as my primary concern
was the change that occurs on Sunday to the new week, so I only have 2
if...then statements at work.

Current issue:
Aside from the host changing my default to default.asp from default.htm,
what method will be the best way for people to get to the new page- issues
being #1- search engine placement and #2- bookmarked people. Both defaults
are currently open and the htm page uses a jscript redirect and the asp is
Thomas'.
Future:
I plan on pulling this information from a new database. I will be using 2
DRW regions on the page- 1 by the month and the other will be a next
occurence. Please view the page (www.lannonfire.com) and let me know what
way(s) would be the best.

Thank You

Mike
 
T

Thomas A. Rowe

Mike,

I am little confused now, was you goal to have links to different pages be
included or to include the content of the includes within the default.asp?

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

The speed difference would depend on the page in question - there'd be no
point doing a general test. But I'd suggest that using server.execute would
always be
a/faster
b/require less code
than using dynamic includes. Even if the speed saving proved to be small any
saving is a good saving.

The database option may well be best as long as the data was cached for the
week - I wouldn't agree with hitting the database on every page request.
Whether the db is appropriate would also depend on who's writing the content
to be included - the content authors may well find it easier to just produce
pages in FP than to stick their content into a database. I'd bet that if one
did a speed test the order would run
1/cached database result
2/server.execute
3/dynamic includes
With the difference between 1/ and 2/ being very small
 
M

Mike Mueller

Thomas-

The ultimate goal is to have 1 page whose content will be current. The
content in question is goint to be the upcoming schedule (currently this &
next weeks events) and when the next occurence of a particular event (drill)
will occur. Currently I am using the include sample that you provided
earlier, pulling full pages based on the week. As I learn the various
technologies better (and as my time at my FT job allows), the default page
will pull this information from a DB.
 
M

Mike Mueller

How would I set up a cached DB?


Mike

Jon Spivey said:
The speed difference would depend on the page in question - there'd be no
point doing a general test. But I'd suggest that using server.execute would
always be
a/faster
b/require less code
than using dynamic includes. Even if the speed saving proved to be small any
saving is a good saving.

The database option may well be best as long as the data was cached for the
week - I wouldn't agree with hitting the database on every page request.
Whether the db is appropriate would also depend on who's writing the content
to be included - the content authors may well find it easier to just produce
pages in FP than to stick their content into a database. I'd bet that if one
did a speed test the order would run
1/cached database result
2/server.execute
3/dynamic includes
With the difference between 1/ and 2/ being very small

--
Cheers,
Jon
Microsoft MVP - FP

all do be it
 
Top