[ic] Generate static pages

Stefan Hornburg racke at linuxia.de
Thu Oct 16 15:06:37 EDT 2003


On Wed, 15 Oct 2003 21:45:11 -0400
Jon <prtyof5 at attglobal.net> wrote:

> > On Wed, 15 Oct 2003 11:07:41 -0700
> > Anthony Minero <anthony at urbanscooters.com> wrote:
> >
> > > Version: 4.8.7
> > > MySQL
> > >
> > > Could someone tell me what the generate static pages function does. I see
> > > the two lists of "force build" and "never build". I also see the entry page
> > > and regenerate but I'm really not too sure what that means. Where do these
> > > pages get created? How do I create them? It seems like it's just generating
> > > one page no matter how many I highlight and I don't see that page in the
> > > root any where.  I'm just wondering what it is doing exactly? I'd like to
> > > create static pages of all my pages for SEO reasons. I could just do this by
> > > hand but if there is a function built in for this then I'd rather do that.
> >
> > Static pages are pretty broken in the 4.8.x series and therefore removed
> > in the 4.9.x series, although you can do interesting things with 4.9.x
> > (jobs and capture_page tag).
> >
> >
> >
> 
>     Who knows where to find either documentation or examples of using the
> capture_page ?

Basic usage is:

[capture-page page="index" file="__STATIC_ROOT__/index" umask="002" hide=1]

Additonal options are:

scan     for capturing search results
expiry   only build the file if now > expiry or file doesn't exist
touch    update timestamp if the file isn't build due to expiry
auto_create_dir	  create any missing directories

Any comments/suggestions for improving this tag are welcome. 

A complex example follows:

=== START STATIC PAGES [tag time]%H:%M:%S[/tag] ===
[set usecache]1[/set]
[set locales]de_DE en_US fr_FR pl_PL ru_RU[/set]
[perl tables="component catrun"]
# determine URLs for various locales
$vendurl = $Config->{VendURL};
for (qw(fr_FR pl_PL ru_RU)) {
	$Scratch->{"vend_url_$_"} = "$vendurl/" . substr($_, 0, 2);
}
$Scratch->{vend_url_de_DE} = $vendurl;
@sites = split(/\s+/, '__ENGLISH_SITES__');
$Scratch->{vend_url_en_US} = "http://$sites[0]/";
my $set = $Db{component}->query(q{select distinct catid from component where sell=1 and catid > 0});
my (@cats, $stamp, $selstamp, $selcat);
$Scratch->{currentcat} = '';
for my $cat (@$set) {
	if ($stamp = $Db{catrun}->field($cat->[0], 'last_run')) {
		if (!$selstamp || $stamp < $selstamp) {
			$selcat = $cat->[0];
			$selstamp = $stamp;
		}
	} else {
		next if $Scratch->{currentcat};
		$Scratch->{currentcat} = $cat->[0];	
	}

	push @cats, $cat->[0];	
}
$Scratch->{currentcat} ||= $selcat;
$CGI->{cats} = join(',', @cats);
# now get line items for this category
my @set = $Db{component}->query(qq{select idf,partnumber,description,manufacturer,datecode,count,pricing from component where sell = 1 and catid = $Scratch->{currentcat} order by partnumber limit 500});
my $matches = @{$set[0]};
my $pages;
delete $Scratch->{catlist};
for ($pages = 0; $pages * 100 < $matches; $pages++) {
	my $offset = $pages * 100;
    my @catlist;
	if ($matches > $offset + 100) {
		@catlist = @{$set[0]}[$offset .. $offset + 100];
	} else {
		@catlist = @{$set[0]}[$offset .. $matches - 1];
	}
	$Scratch->{catlist}->[$pages] = [\@catlist, $set[1], $set[2]];
}
$Scratch->{catpages} = $pages;
return;
[/perl]
Current category: [catname component="[scratch currentcat]" iscatid=1]
--- CREATE HOMEPAGES ---
[loop prefix=lang list="[scratch locales]"]
[setlocale locale="[lang-code]" persist=1]
[calc]$Config->{VendURL} = $Scratch->{vend_url_[lang_code]}; return;[/calc]
[set llink_template]../%s/index.html[/set]
Index for [lang-code]: [capture-page page="static/catlist" file="__STATIC_ROOT__/[lang-code]/index.html" umask="002"]
[/loop]
--- HOMEPAGES FINISHED [tag time]%H:%M:%S[/tag] ---
--- CREATE CATEGORY PAGES ---
[loop prefix=lang list="[scratch locales]"]
[setlocale locale="[lang-code]" persist=1]
[calc]$Config->{VendURL} = $Scratch->{vend_url_[lang_code]}; return;[/calc]
[seti name][catname component="[scratch currentcat]" iscatid=1][/seti]
[seti filename][filter op='filesafe escape./' interpolate=1][scratch name][/filter][/seti]
[loop prefix=cats list="1..[scratch catpages]" ranges=1]
[calc]$Scratch->{pageindex} = [cats-code]; return;[/calc]
Category [scratch name] - Page [scratch pageindex]: [capture-page page="static/results" file="__STATIC_ROOT__/[lang-code]/[scratch filename]/[scratch filename][cats-code].html" umask="002" auto_create_dir=1]
[/loop]
[/loop]
[seti cattime][tag time]%Y%m%d%H%M%S[/tag][/seti]
[perl tables=catrun]
$Db{catrun}->set_slice($Scratch->{currentcat}, ['last_run'], [$Scratch->{cattime}]);
[/perl]
--- CATEGORY PAGES FINISHED [tag time]%H:%M:%S[/tag] ---
--- CREATE DETAIL PAGES ---
[query table=component sql="select idf,catid,UNIX_TIMESTAMP(last_modified) from component where sell=1 and catid = [scratch currentcat] order by partnumber limit 500" list=1][list][loop prefix=lang list="[scratch locales]"]
[setlocale locale="[lang-code]" persist=1]
[calc]$Config->{VendURL} = $Scratch->{vend_url_[lang_code]}; return;[/calc]
[seti name][catname [sql-pos 1] 1][/seti]
[seti filename][filter op='filesafe escape./' interpolate=1][scratch name][/filter][/seti]
[seti llink_template][area href="[sql-pos 0]"][/seti]
[capture-page page="[sql-pos 0]" file="__STATIC_ROOT__/[lang-code]/[scratch filename]/[sql-pos 0].html" umask="002" expiry="[sql-pos 2]" touch=1 auto_create_dir=1 hide=1][/loop]
[sql-alternate 100][sql-increment] pages done: [tag time]%H:%M:%S[/tag][/sql-alternate]
[/list]
[/query]
--- DETAIL PAGES FINISHED [tag time]%H:%M:%S[/tag] ---
=== END STATIC PAGES [tag time]%H:%M:%S[/tag] ===

Ciao
	Racke

-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team



More information about the interchange-users mailing list