TEMPLATE INSTRUCTIONS FOR closedShop 2.2 With the advent of version 1.6 of closedShop, you can use templates to totally customize the Display of items and the diplay of categories. You can even use programming inside the template to achieve any need you have When you use templates, they will replace the header and footer files normally used. To use templates, just enter in the name of the file you want to use as a template in the Change Variables section in the Admin program INSTRUCTIONS FOR INDIVIDUAL ITEM DISPLAY The simplest way to use the templates is to insert different data about the item. To do this, use a special tag like the following <# name #> that tag will be replaced by name of the item The following tags are availabe Item id -- <# id #> Item name -- <# name #> Item price -- <# price #> Item shipping price -- <# shipping #> Item description -- <# description #> Quantity left -- <# quantity #> Category name -- <# category #> Attributes -- <# attributes #> (NOT CURRENTLY IMPLEMENTED) Image URL -- <# image_url #> Category URL -- <# cat_url #> URL to add item to the cart -- <# add_url #> URL to add item to wishlist -- <# wish_url #> Begginning of form data needed to use a POST to add the item to the cart -- <# add_formpost #> In addition, you can use Perl Code within the template and it will be evaluated. If there is an error in your Perl Code it will be displayed on the screen, along with the line Example: <# { for (my $k = 0l $k < 50; $k++) { print $k . "
"; } } #> Note: The code is to be bracketed on both side. Make sure there is only one space between the # and the { The variables that you are able to use for items when you use the Perl code are as follows Item Code: $code Item Category: $category Item Name: $name Item Price: $price Quantity Left: $qty Description: $desc So for example, if you wanted to have a special message appear if quantity drops below 5, then you would do the following (If you have problems with multiple lines, put it all the code on one line) <# { if ($quantity < 5) { print "You must buy $name now!!!"; } else { print "You can wait awhile until you buy $name"; } } #> INSTRUCTIONS FOR CATEGORY TEMPLATE The category template follows the same format as the item template, but there are different variables. The following tags are available: Category -- <# category #> Category Introduction text -- <# intro #> Category URL -- <# cat_url #> Category Code -- <# cat_code #> The programming lets you have some more options and is a little more complicated The variables you can use are: Category Name: $category Item Hash: %items The Item hash has all the items of the category inside of it. Each spot in the hash is actually an array of the data from an item So... To output all the items in a list: <# { foreach (keys %items) { my ($id,$name,$price,$quantity,$itemurl,$imageurl) = split(/~#~/,$items{$_}); print "
  • $name for only \$$price"; } } #> Each hash spot will contain a line of data that is separated by a "~#~" marker. That line must be split and the resulting array is arranged so that the order of variables is: ID,Item Name,Item Price,Quantity Left, Item URL, Image URL Item URL is the URL to go to the Item display page INSTRUCTIONS FOR ALL CATEGORY TEMPLATE The all category template is fairly simple. The data that is passed is just a hash (called %categories), with the category code as the hashed item and the data as an array, in the form <# { my ($intro,$style,$numimages,$status, $name,$children,$parent,$href) = @{$categories{$_}}; } #> $intro is the introductory text you can set $style is text/thumbnails $numimages is number of images you want to display per page $status is private/public $children is id of child categories $parent is id of parent category $href is a link to the category. See the template.allcat for an example of how to display all categories. Hopefully, these instructions are useful for your purposes. You do not need to use templates and you may use just category or just item or both if you choose. ** Notice: Attributes will not work properly with templates as of recent attribute updates. Future work needs to be done to enable this.