1and1 Help Centre Categories

print article

Shop script and PHP

Your shop software is written in PHP, a programming language that is often used for
on-line applications. There is, however, another more simple way of changing your
shop's logic or web design - so-called Shop script expansions.

In addition to HTML code, files that end in .shopscript also contain the necessary
programme logic for the web display. The standard templates contain the following
Shop script files: product_overview.shopscript (Display list of items/products)
product_details.shopscript (Detailed view of an item)
product_search.shopscript (Product search)
We recommend defining the Display logic in Shop script files. They should contain,
for example, how many product categories and items should be displayed per page,
whereas the design of the individually repeated listed elements (product category,
subgroup or product display) is defined in the template files.

If, for instance, you want to divide the start page of your on-line shop into
different frames, proceed as follows. Create a file index.php3 with, for example,
the following content:

<? include("init.inc"); # usertracking ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>On-line shop</title>
<FRAME SRC="blank.html" NAME="l" SCROLLING="NO">
<FRAME SRC="top.shopscript" NAME="top" SCROLLING="NO">
<FRAME SRC="navigation.shopscript" NAME="bottom" SCROLLING="NO">
<FRAME SRC="0010_Espressomachines/product_overview.shopscript" NAME="main">
<FRAME SRC="blank.html" NAME="r" SCROLLING="NO">
You will need an Internet browser that can display frames.
(http://www.netscape.com / http://www.microsoft.com)
This above example defines a 795 Pixel-wide cent red frame which in turn contains a
top.shopscript for the "Heading" / company logo, a frame for the navigation and one
for the product overview. When the shop is called the file
product_overview.shopscript is started in the product group Espresso machines, and
the products available in the product category Espresso machines are displayed.

The file product_overview.shopscript has the following content:

$font = "<font face='$global_fontface' color='$global_fontcolor_dark'
$_font = "</font>";
<body color="$global_fontcolor_dark" link="$global_color1_dark" alink="$global_color1_light"
vlink="$global_color1_dark" text="$global_fontcolor_dark"
bgcolor="$global_backgroundcolour" <% BACKGROUNDTILE %>>

<% GetGroups() %> # Select groups from Structure
Catalogue overview:
<font color='$global_color1_light'><b> >>> </b></font>
<A Href='$path/productoverview.shopscript'>$name</a>

<table cellpadding=0 cellspacing=2 border=1 width=100%>
<td align=center>
<table bgcolor=red width=%>
<% GetItems() %> # Select item from the current product category
Because both PHP and Shop script can be used at the same time in your shop,
Shop script commands and functions are embedded in special tags "<% %>".
The above example starts with a PHP line in which the variables $font and $_font
are each given a value.

The Shop script functions command <% SetVar("DEFAULT_STRUCTURE_DEPTH",1) %>
sets the value of the variable DEFAULT_STRUCTURE_DEPTH to "1". The following
Shop script command <% INIT_STRUCTURE %> effects the initialisation of the
internal data

Because the DEFAULT_STRUCTURE_DEPTH will have been set to "1", both the current
category and the first level of any existing subcategories will be read.

With a value of "0" only the current level would be read; with "2" two levels would
be read, and so on.

Your shop's catalogue structure is available from this point on. Normal HTML code
now follows, which is in turn complemented during operation by shop system
parameters such as $global_fontcolor_dark etc. In the example, a table is then
opened in which the individual elements are inserted by the Shop script commands

&amp;lt;syntax&amp;gt;&amp;lt;% ITEMLOOP %&amp;gt;&amp;lt;/syntax&amp;gt;, &amp;lt;syntax&amp;gt;&amp;lt;% TEMPLATE %&amp;gt;&amp;lt;/syntax&amp;gt; and &amp;lt;syntax&amp;gt;&amp;lt;% END_ITEMLOOP %&amp;gt;&amp;lt;/syntax&amp;gt;.   
The corresponding template template_categorymain.template in this example has the
following content:

&amp;lt;td valign=middle align=left&amp;gt;
&amp;lt;b&amp;gt;&amp;lt;a href="$path/productoverview.shopscript"&amp;gt;$name&amp;lt;/a&amp;gt;&amp;lt;/b&amp;gt;
As you can see, you can easily make changes to the way your shop works with
Shop script without having to learn a programme language.