[ic] [timed-build] - search pages

Russ Mann interchange-users@interchange.redhat.com
Fri Feb 1 12:52:01 2002


Thank you Mike!  That was too cool.  Is the "file" parameter documented?  If
it is, I didn't see it.  Here's the code I actually used because of what I'm
doing specifically:
Note: Because I'm using the searchspecs to make my filenames, and because
I'm using the searchspecs to make the page title, I had to make the whole
page a search region, and put the [timed-build] within the [search-region].

[search-region]
[calc]
my @str = grep /\D/, @{$Values->{mv_searchspec}};
$main_category_1 = @str[0];
$media_type_1 = @str[1];
$main_category_file = $main_category_1;
$main_category_file =~ s/ //g;
$media_type_file = $media_type_1;
$media_type_file =~ s/ //g;
$time_build_file =
"timed/".$main_category_file.".".$media_type_file.".html";
$page_title = $main_category_1." - ".$media_type_1;
return;
[/calc]
[timed-build file="[calc]$time_build_file[/calc]" minutes=20]

[set page_title][calc]$page_title[/calc] - __COMPANY__[/set]
@_LEFTONLY_TOP_@

<!-- BEGIN CONTENT -->
[if scratch did_order]
[include file="templates/components/cart_display"]
[/if]
[if newsearch]
[set tmp_increment][/set]
[/if]
[set did_order][/set]
[comment]
[data table=media_type column=extra_text key='[scratch banner_text]']
[/comment]
<hr noshade color="#000000">
<center><font face="Arial" size="4">
[calc]$page_title[/calc]
</font></center>
<hr noshade color="#000000">
<p align="left">
[data table=main_category column=extra_text foreign=main_category
key='[calc]$main_category_1[/calc]']
</p>
<br>Media Type: [calc]$media_type_1[/calc]<br>

[comment]
<table border="0"><tr><td>
[seti selector_key]main_category=[calc]$main_category_1[/calc],
media_type=[calc]$media_type_1[/calc][/seti]
<img src="[data table=cat column=display_image foreign=selector
key='[scratch selector_key]']" align="left">
[scratch selector_key]
[data table=cat column=extra_text foreign=selector key='[scratch
selector_key]']
</td></tr></table>
[/comment]

<table border="0" cellspacing="0" cellpadding="4" width="100%">
[search-list]
[item-next][calc]return 1 if '[item-field inactive]' ==
'1'[/calc][/item-next]
[item-next][calc]return 1 if '[item-field sku]' eq ''[/calc][/item-next]
[if-item-field sub_category]
[item-change cat][condition][item-field sub_category][/condition]
[if !scratch flip]<td>&nbsp;</td></tr>[/if]
<tr><td width="100%" colspan="2" class="bgtopbar" align="center">
<font face="Arial" font color="#EEEEEE"><b>[item-field sub_category]</b><br>
<font size="2">[data table=sub_category column=extra_text
foreign=sub_category key='[item-field sub_category]']</font></font>
</td></tr>
[set flip]1[/set]
[/item-change cat]
[/if-item-field]
[if !scratch flip][set flip]1[/set][else][set flip][/set]<tr>[/else][/if]
[comment][item-alternate 2][else]<tr>[/else][/item-alternate][/comment]
[seti item_description][item-field description][/seti]
<!--
[perl]
$Scratch->{item_description} =~ s/ Commentary in MP3 on CD-ROM//ig;
$Scratch->{item_description} =~ s/ in MP3 on CD-ROM//ig;
$Scratch->{item_description} =~ s/ Commentary on Audio//ig;
[/perl]
-->
<td><small>[page href="[item-code]" send=1][scratch
item_description]</small></a></td>
[comment][item-alternate 2]</tr>[else][/else][/item-alternate][/comment]
[if scratch flip]</tr>[/if]
[/search-list]
</table>
<!-- END CONTENT -->
@_LEFTONLY_BOTTOM_@
[/timed-build]
[/search-region]


-----Original Message-----
From: interchange-users-admin@interchange.redhat.com
[mailto:interchange-users-admin@interchange.redhat.com]On Behalf Of Mike
Heins
Sent: Friday, February 01, 2002 6:59 AM
To: interchange-users@interchange.redhat.com
Subject: Re: [ic] [timed-build] - search pages


Quoting Kevin Walsh (kevin@cursor.biz):
> > I read the info on the [timed-build] tag, and it seems to be what I
need.  I
> > have a several complex searches which need to be "cached" so they don't
have
> > to query the database each time they're called up.  Unfortunately, the
> > [timed-build] tag seems to build the results.html page, and any time
that
> > results page is called, regardless of which query is being run, it shows
the
> > same contents.  Is there any way to accomplish the same type of work as
the
> > [timed-build] tag, only using it in a search results page that will have
> > several separate searches run on it, which need to be saved?
> >
> You really don't want to wrap the [timed-build] tag around your
> results.html page for a number of reasons.
>
> As you have found, [timed-build] will write its interpolated body to
> the specified file and then read from that file the next time it is
> called (until the specified timeout expires) saving the time it takes
> to read from the database and interpolate again.
>
> The results.html page will be called to display the results of your
> customers' searches, most of which will differ, so you don't want
> the first set of results to be cached in this way.
>
> You could make up a filename from the search parameters and read/write
> that, but that won't work for searches that span multiple pages.
>

You can, however, do:

	[timed-build
		file="[cgi param 1].[cgi param 2]"
		minutes=10
		]
	[query ....]
	[/query]
	[/timed-build]

	[timed-build
		file="[cgi param 3].[cgi param 4]"]
		minutes=10
		]
	[query ....]
	[/query]
	[/timed-build]

If there is static query, i.e. the parameters are hardcoded,
you can do:

	[timed-build auto=1 minutes=10]
	Something unique...
	[/timed-build]

There is an example in the vertical_category component in foundation.

--
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Research is what I'm doing when I don't know what I'm doing.
-- Wernher Von Braun
_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users