1and1 Help Centre Categories

print article

How to display only X items on a Search Results page

Enter the text displayed in red in the product_search.shopscript. You can access
product_search.shopscript as follows: 'eShop Administration' -> 'Shop design' -> 'product_search.shopscript'The number of search results to be displayed are set in the variable $maxlistIn this example, we have set it to 5.


<?php
$font = "<font face='$global_fontface' color='$global_fontcolor_bright'
size='$global_text_size'>"; $_font = "</font>";

if (empty($startitem)) $startitem=0;
$maxlist=5;

php?>
#################################################################################################
#
# ShopScript 1.2
# File: product_search.shopscript
#
#################################################################################################
<HTML>
<HEAD>
<TITLE>$text_search_heading</TITLE>
<% INCLUDE_VAR($CUSTOM_HEAD) %>
</HEAD>

<body color="$global_fontcolor_dark" link="$global_color1_dark" alink="$global_color1_bright" vlink="$global_color1_dark" text="$global_fontcolor_dark" bgcolor="$global_background_color" <% BACKGROUND_TILE %>>
<% INCLUDE_VAR($CUSTOM_HEADER) %>
<% EchoHeadline($text_search_heading) %>

<% START_SEARCH %> # start query

<% IF_NO_ITEMS_FOUND %> # if no articles were found
<% IF_QUERY %> # and a search string was entered (i. e. page is not called initially)
<table width=550>
<tr>
<td>
<font face="$global_fontface" color="$global_fontcolor_dark" size="$global_text_size">
<% INCLUDE_VAR($text_search_nothing_found) %><br>
</font>
</td>
</tr>
</table>
<br>
<% END_IF %>
<% ELSE_IF %>
############## HTML output
<TABLE border=0>
<tr>
<td colspan=2>
<font face="$global_fontface" color="$global_fontcolor_dark" size="$global_text_size">
<% INCLUDE_VAR($text_search_found_items) %><br>

 

</font>
</td>
</tr>
<% SEARCH_ITEMLOOP($startitem;$startitem+$maxlist)%>

&amp;lt;% TEMPLATE %&amp;gt;
&amp;lt;% END_SEARCH_ITEMLOOP %&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td align="center" colspan="3" valign="bottom"&amp;gt;
&amp;lt;table border="0"&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td align="center"&amp;gt;
&amp;lt;?php
$items_back=$startitem-$maxlist;
if ($items_back&amp;gt;=0) {
echo "&amp;lt;a href='product_search.shopscript?startitem=$items_back".
"&amp;amp;amp;query=$query&amp;amp;amp;search_logical=$search_logical'&amp;gt;
&amp;lt;b&amp;gt;Previous $maxlist Articles&amp;lt;/b&amp;gt;&amp;lt;/a&amp;gt;";
}
php?&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;td align="center"&amp;gt;
&amp;lt;?php
$enditem=$startitem+$maxlist;
if ($enditem&amp;gt;$found_items) $found_items;
echo " "
.($startitem+1).
" to $enditem of "
.$found_items.
" Articles";
php?&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;td align="center"&amp;gt;
&amp;lt;?php
$items_next=$startitem+$maxlist;
if ($items_next&amp;lt;$found_items) {
echo "&amp;lt;a href='product_search.shopscript?startitem=$items_next".
"&amp;amp;amp;query=$query&amp;amp;amp;search_logical=$search_logical'&amp;gt;
&amp;lt;b&amp;gt;Next $maxlist Articles&amp;lt;/b&amp;gt;&amp;lt;/a&amp;gt;";
}
php?&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td align="center"&amp;gt;Search page:
&amp;lt;?php
for ($i=0; $i&amp;lt;$found_items; $i += $maxlist)
echo "&amp;lt;a href='product_search.shopscript?startitem=$i&amp;amp;amp;query=$query&amp;amp;amp;search_logical=$search_logical'&amp;gt;&amp;lt;b&amp;gt;".($i/$maxlist+1)."&amp;lt;/b&amp;gt;&amp;lt;/a&amp;gt; ";
php?&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/TABLE&amp;gt;
&amp;lt;% END_IF %&amp;gt;

# &amp;lt;% IF_NO_ITEMS_FOUND %&amp;gt; # uncomment (i. e. remove # sign at start of line) to hide search input field if items where found
&amp;lt;table width=550&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;
&amp;lt;font face="$global_fontface" color="$global_fontcolor_dark" size="$global_text_size"&amp;gt;
&amp;lt;% INCLUDE_VAR($text_search) %&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/font&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;
&amp;lt;table width=400 cellpadding=5 cellspacing=0 border=0 align=center&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td bgcolor="$global_color1_bright" align=left valign=bottom&amp;gt;
$font
&amp;lt;b&amp;gt;&amp;lt;nobr&amp;gt;
$text_search_inputbox_heading
&amp;lt;/b&amp;gt;
$_font
&amp;lt;/td&amp;gt;
&amp;lt;td width=10% bgcolor="$global_color2_bright" colspan=2&amp;gt;
&amp;amp;nbsp;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;FORM action="$PHP_SELF_FILENAME"&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td colspan=3 align=center valign=bottom bgcolor="$global_color2_bright"&amp;gt;
$font
&amp;lt;font color="$global_fontcolor_dark" size="$headlinetextsize"&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;input type=text name="query" value="$query"&amp;gt;
&amp;lt;br&amp;gt;
$text_search_or &amp;lt;input type="radio" name="search_logical" value="or" &amp;lt;% IF ($search_logical!="and") %&amp;gt;checked&amp;lt;% END_IF %&amp;gt;&amp;gt;
$text_search_and &amp;lt;input type="radio" name="search_logical" value="and" &amp;lt;% IF ($search_logical=="and") %&amp;gt;checked&amp;lt;% END_IF %&amp;gt;&amp;gt;
&amp;lt;/font&amp;gt;
$_font
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td colspan=3 align=right valign=middle bgcolor="$global_color2_bright"&amp;gt;&amp;lt;BR&amp;gt;
&amp;lt;input type=image src="./img/$button_search" border="0"&amp;gt;
&amp;amp;nbsp;&amp;amp;nbsp;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
# &amp;lt;% END_IF %&amp;gt; # uncomment (i. e. remove # sign at start of line) to hide search input field if items where found

&amp;lt;% INCLUDE_VAR($CUSTOM_FOOTER) %&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&amp;lt;% LOG_PRODUCTSEARCH %&amp;gt;