1and1 Help Centre Categories

print article

List of Shopscript commands, functions and variables

Please note:
Parameters in square brackets [] may be omitted.

Reading item and product category data
These commands

focus

on a part of your product range. The selected data will be used later by the

ITEMLOOP

commands.

<% SetVar("DEFAULT_STRUCTURE_DEPTH",1) %>   

gives a value to a variable. In the example, the number of subcategory levels to be initialised (displayed) is set at 1.

<% INIT_STRUCTURE %>   

Initialises the overview displays, reads in all the elements of the range structure of your shop, and provides the variables of the elements for use in the loop constructs (see

<% ITEMLOOP %>   

). The items and product categories are read as far as the depth set in variable

$DEFAULT_STRUCTURE_DEPTH

.

<% GetGroups("<path>") %>   

Selects from the range structure of all product categories in the given path. The paths may be relative (e.g.

../Offer

) or absolute (e.g.

/Kitchen equipment/Mixers

).

<% GetItems("<path>") %>   

Selects all of the items in the given path from the range structure read in.

<% GetAll("<path>") %>   

Selects all of the items and product categories in the given path from the range structure read in.

Please note:
If you select items or product categories with
GetGroups()
,
GetItems()
or
GetAll()
, the templates of the group from which this selection is made will be used. If, for instance, you use another small-list template in
/Offer
than in the root directory and select the items in this product category with
<% GetItems("/Offers") %>   
, the root directory templates will be used.
Please note:
<% INIT_STRUCTURE %>   
stores the data of all items and product categories to the structure depth given in
DEFAULT_STRUCTURE_DEPTH
into the memory. If you have a very extensive range of products and a great depth, you may get the "Internal Server Error" message as the shop gets to its memory limit or times out.
<% GetStructure([<depth>]) %>   

(deprecated)
Reads the entire structure of the product range to the depth given, and provides the attributes of the item and product categories. Was used in old templates instead of

<% INIT_STRUCTURE %>   

. Should not be used any more.

Looping stored files

<% ITEMLOOP %>   

and

<% END_ITEMLOOP %>   

Loop construct that runs through all currently selected elements (products, product categories, product subcategories etc.). The HTML part between the first and last tag is issued once for each selected element. Is used to display the product list(s). Just which ones are the "currently selected elements" depends on the variable

DEFAULT_STRUCTURE_DEPTH

and on the last used function command

GetGroups

,

GetItems

or

GetAll

.

<% ITEMLOOP([itemloop_min]; [itemloop_max]) %>   

and

<% END_ITEMLOOP %>   

As

<% ITEMLOOP %>   

, the only difference being that the elements are shown from itemloop_min to itemloop_max. (please also see the information on displaying X products on a page )

Variables in the ITEMLOOP
The following variables are available after the initialisation functions have been called up and within an ITEMLOOP loop:

$path

- contains the path to the file system directory of the corresponding element

$name

- the name of the element (product category or item)

$description

- descriptive text on the element (product category or item)

$type

- "maingroup", "subgroup1", .. ,"item", "item1"

All other item attributes are also available in the form of PHP variables.

$[Item attribute description]

Other Shop script commands in ITEMLOOPs
Use the following tags as required in one of the above ITEMLOOP loop constructions. They facilitate the conditional execution of programme sections or the conditions issue of HTML fragments.

<% IF_MAINGROUP %>   

If the current element is a main product category (product group of the current level).

<% IF_SUBGROUP %>   

If the current element is an item subcategory (a product category below the current level).

<% IF_ITEM %>   

If the current element is an item.

<% IF_LAST_ITEM %>   

If the current element is the last item in the product list.

<% IF_NOT_LAST_ITEM %>   

If the current element is not the last item in the product list.

<% IF_LAST_GROUP %>   

If the current element is the last product category in the product list.

<% IF_NOT_LAST_GROUP %>   

If the current element is not the last product category in the product list.

<% IF_LAST_ENTRY %>   

If the current element (item or group) is the last in the product list.

<% IF_NOT_LAST_ENTRY %>   

If the current element (item or group) is not the last in the product list.

<% IF_NO_ARTICLES %>   

If there are no items (on the current level).

<% IF_NO_MAINGROUPS %>   

If there are no product categories (on the current level).

<% END_IF %>   

Closes a condition command or HTML block that opened with "IF_...".

<% TEMPLATE %>   

Issues the HTML fragment allocated to the element.

<% ORDER_URL %>   

Is available in the "Product overview" and inserts an order URL.
Note: This link is the simplified version of "Shop integration".
No item variants are possible with this process.
Example:

<a href="<% ORDER_URL %>">on the order sheet</a>   
<% BASKET_URL %>   

Inserts a link to the shopping basket. Use this tag as follows, for example:

<a href='<% SHOPPINGBASKET_URL %>'>Your personal shopping basket</a>   
<% URL_ITEM("[Template file]") %>   

Issues the link to the detailed view. The parameter is optional, the standard references is to

productoverview.shopscript

.

In the detailed view

productview.shopscript
<% INIT_ITEMVIEW %>   

or

<% INIT_PRODUCTVIEW %>   

is used to provide the item details for the detailed view.
After this command the same variables and values as are provided by the

<% ITEMLOOP%>   

- construct will be available to you.

Shop script commands that generate URLs

<% URL_MAINFRAME("productoverview.shopscript") %>   

This command is used to indicate the first frame that should be displayed on entering the shop, in the start frameset. The parameter may also be omitted, in which case the file

about_us.shopscript

is called up as the default.

<% GetCategoryNavigation($root_text,$separator,$link_all_levels,$root_index,$specialfield,$overview_file,$no_links) %>   

creates a string that shows the customer where he is in the product category hierarchy

Parameter Meaning
$link_all_levels
if TRUE then the current product category will be given as a link
$root_text
the text that is used for the root directory
$root_index
the level from which counting should start (0=root directory, 1=first group subcategory etc.
$specialfield
here you can given an attribute for the product category whose content should be given instead of the name (e.g.
Description
). Special treatment for
image
: in this case the image (or the corresponding HTML-img tag) is given.
$overview_file
own product overview template that is to be linked.
$no_links
suppress all links and display only text

other Shop script commands

<% GetVar(varname) %>   

gives the variable value of

$var
<% SetVar(varname,value) %>   

gives a value to a variable.

<% SetSessVar(name, value) %>   

Sets the value of a session variable

varname

to

value

. A key feature of session variables is that they are automatically available on all the following pages in your shop. With session variables, for instance, so-called

Affiliate IDs

can easily be administrated by the shop. Or you can save entries from your own form fields with session variables for later use.

Access protocol commands
Your on-line shop is able to maintain a highly expressive access protocol. Your shop software writes a log file in which the activities of every single visitor to your shop are recorded. It can record whether customers called up the product display, product overview or product search. It can also record which items visitors search for and view. This information can later be stored with special evaluation programs (such as

Shopsuxess

) to produce expressive evaluations.

The individual protocol events are initiated by the following tags. Please note that the protocols should be inserted at the end of your file so that taking the protocol does not hinder the performance of your shop site during the customer's visit.

<% LOG_PRODUCTVIEW %>   

Makes the corresponding product view protocol entry in the access protocol (log file).

<% LOG_PRODUCTOVERVIEW %>   

Makes the corresponding product overview protocol entry in the access protocol (log file).

<% LOG_PRODUCTSEARCH %>   

Protocols the search query including the sought item in the access protocol (log file).

<% LOG_PRODUCTVIEW %>   

Makes the corresponding product view protocol entry in the access protocol (log file).

<% LOG_PRODUCTOVERVIEW %>   

Makes the corresponding product overview protocol entry in the access protocol (log file).

<% LOG_PRODUCTSEARCH %>   

Protocols the search query including the sought item in the access protocol (log file).

Product search commands

<% INIT_SEARCH %>   

Initialises the product search.

<% IF_SEARCHTERM %>   

If a search item is entered.

<% SEARCH_ITEMLOOP %>   

and

<% END_SEARCH_ITEMLOOP %>   

Loop construct that runs through the search results. The hits are given in this loop.

other variables

$toshopdata   

This is the path to the shop's root directory, and - depending on the version being used - displays either

shopdata

(on-line shop) or

bs_shopdata

(shop preview).