Category Tags

From Shopp Documentation

Jump to: navigation, search

Category shopp() tags are used to display information for a specific category and are only used in the category.php template file - the generic template that creates the layout for how products are displayed in a given category.

Contents

id

Overview

<?php shopp('category','id'); ?>

Displays the database ID of the category.

Options

  • None

name

Overview

<?php shopp('category','name'); ?>

Displays the name of the category.

Options

  • None

slug

Overview

<?php shopp('category','slug'); ?>

Displays the slug (or pretty URL name) for the category.

Options

  • None

description

Overview

<?php shopp('category','description'); ?>

Displays the description of the category.

Options

  • None

url

Overview

<?php shopp('category','url'); ?>

Displays the full link to the current category.

Options

  • None

total

Overview

<?php shopp('category','total'); ?>

Shows the total number of products in the category.

Options

  • None

hasproducts

Overview

<?php if(shopp('category','hasproducts')) {} ?>

Checks the database to determine if any products are available for the category. If products are available, the product data is loaded for use in a shopp('category','products') loop and evaluates to true. Otherwise, it will evaluate false. Provides a simple test mechanism to allow different template layouts to be shown depending on whether there are products available in the category or not.

Options

  • load: Used to specify what product data to load ahead of time in a single database query. Accepts multiple options separated by commas including: prices, images, categories, specs, tags. Product prices are loaded by default. This option is useful for speeding up your store's performance. The tradeoff is that it requires more server memory to process. The more information you request, and the more products per page displayed requires more and more memory. Not preloading (or bulk loading) product data will force Shopp into a load-on-demand mode. Any Product Tags that you use that require information not currently available will trigger a new query to the database automatically. This is done on a per product basis, meaning that a separate database query is run for each data set requested and for each product listed on a category page (25 products per page x 5 data sets = up to 126 queries including the initial product query). In some cases, for better memory bandwidth management and query scheduling, especially for heavy traffic it may be worthwhile to load-on-demand rather than bulk load. If you have the memory resources to spare, bulk loading is absolutely the best practice.

Examples

Display category products by thumbnail and name
<?php if(shopp('category','hasproducts')): ?>
	<div>
	<?php while(shopp('category','products')): ?>
		<?php shopp('product','thumbnail'); ?>
		<h3><?php shopp('product','name'); ?></h3>
	<?php endwhile; ?>
	</div>
<?php else: ?>
	<p>There are no products for this category.</p>
<?php endif; ?>

products

Overview

<?php while(shopp('category','products')) {} ?>

Loops through the products in a given category to display information specific to a single product in the collection. This is a construct similar to "The Loop" in WordPress and operates in much the same manner. It is the main product loop where you typically use Product Tags to layout how an individual product looks in your category view.

Options

  • None

row

Overview

<?php if(shopp('category','row')) {} ?>

Provides a test mechanism for grouping/splitting up product listings into rows (useful for grid-style displays).

Options

  • products: Default is 3. Sets the number of products to display per row. This allows you to adjust the number of products per row to accommodate designs with a larger content space for product display.

thumbnail

Overview

<?php shopp('category','thumbnail'); ?>

Displays the default thumbnail for the category. The default thumbnail is the image that is set as the first image when using a custom image order, or which ever image is automatically sorted to be first when using other image order settings set in the Presentation Settings screen.

Options

  • class: No default setting. Allows you to specify a custom CSS class for the thumbnail.

has-images

Overview

<?php if(shopp('category','has-images')) {} ?>

Tests whether the category has any images.

Options

  • None

Examples

<?php if(shopp('category','has-images')): ?>
	<?php while(shopp('category','images')): ?>
		<?php shopp('category','image'); ?>
	<?php endwhile; ?>
<?php endif; ?>

images

Overview

<?php while(shopp('category','images')) {} ?>

Loops through the category images so that you can display each category image of a set type. This is similar to "The Loop" structure in WordPress for displaying a custom layout for WordPress posts.

Options

  • type: Default is thumbnail. Used to set what type of images to show in a the loop. Set to small to display the small preview size images, or image to display the original full size images as they were uploaded to your store (note longer download times for the larger images).

Examples

<?php if(shopp('category','has-images')): ?>
	<?php while(shopp('category','images')): ?>
		<?php shopp('category','image'); ?>
	<?php endwhile; ?>
<?php endif; ?>

image

Overview

<?php shopp('category','image','options…'); ?>

Used in the 'images' loop to show an individual category image of the type set in the loop. Alternatively, you can use the has-images test and this tag to show the default category image of a specific type. The default image for a category is determined by the image sorting options specified in the Presentation Settings.

Options

  • type: Default is thumbnail. When the tag is used outside of the loop, you can use this option to specify the type of image for the default category image. Set to small to display the small preview size images, or image to display the original full size images.
  • class No default setting. Allows you to specify a CSS class for the image.
  • zoom: Default is off. When set to on the Thickbox zoom effect is enabled when clicking on the image.

subcategory-list

Overview

<?php shopp('category','subcategory-list'); ?>

Displays a linked list of sub-categories of this category to be used for navigation.

Options

  • after: default is (empty). Adds content or markup to display after the category list markup.
  • before: default is (empty). Adds content or markup to display before the category list markup.
  • class: default is (empty). Used to specify CSS classes for the outer category list <ul> element. Has no effect when the wraplist option is disabled.
  • depth: Default is 0. Limits the number of levels of subcategories displayed in the subcategory list.
  • dropdown: Default is off. Specifies whether to display the list as a set of unordered list items <li> or as a set of drop-down menu options <select><option></select> Example: <?php shopp('category','subcategory-list','dropdown=on'); ?>
  • hierarchy: Default is off. Displays the subcategory list showing subcategories indented provided that the active WordPress theme's CSS doesn't override
  • products: Default is off. Displays the number of products in the subcategory in parentheses after the category name.
  • showall: Default is off. Forces display of subcategories in the list regardless of if they have no products assigned or no products with available inventory.
  • title: Default is (empty). Allows you to specify a title that is displayed before the menu
  • order: Default is bestselling. Possible settings include: bestselling, highprice, lowprice, newest, oldest, random, and title

section-list

Overview

<?php shopp('category','section-list'); ?>

Displays a linked list of the categories in the current category section. A category section includes all of the descendant categories (and their descendants) of a top-level category. This provides a contextual menu of category relatives.

Options

  • after: default is (empty). Adds content or markup to display after the category list markup.
  • before: default is (empty). Adds content or markup to display before the category list markup.
  • class: default is (empty). Used to specify CSS classes for the outer category list <ul> element. Has no effect when the wraplist option is disabled.
  • depth: Default is 0. Limits the number of levels of subcategories displayed in the subcategory list.
  • dropdown: Default is off. Specifies whether to display the list as a set of unordered list items <li> or as a set of drop-down menu options <select><option></select> Example: <?php shopp('category','subcategory-list','dropdown=on'); ?>
  • exclude: Default is (empty). Allows you to specify one (or more) category ids to skip in the category list display.
  • hierarchy: Default is off. Displays the subcategory list showing subcategories indented provided that the active WordPress theme's CSS doesn't override
  • products: Default is off. Displays the number of products in the subcategory in parentheses after the category name.
  • showall: Default is off. Forces display of subcategories in the list regardless of if they have no products assigned or no products with available inventory.
  • title: Default is (empty). Allows you to specify a title that is displayed before the menu
  • wraplist: Default is on. Automatically wraps the category list items in a <ul> element when set to on. No outer <ul> is used when set to off.

hascategories

Overview

<?php if(shopp('category','hascategories')) {} ?>

Determines if the current category has any sub-categories and loads them for use with the shopp('category','subcategories') tag. This tag is required before using shopp('category','subcategories').

Options

  • None

Examples

<?php if(shopp('category','hascategories')): ?>
	…content/markup shown if the category has sub-categories…
<?php else: ?>
	…content/markup shown if the category has no sub-categories…
<?php endif; ?>

subcategories

Overview

<?php while(shopp('category','subcategories')) {} ?>

Loops through the loaded sub-categories in a given category to display information specific to a single sub-category in the collection. This tag requires calling shopp('category','hascategories') before this tag will operate correctly. This is a construct similar to "The Loop" in WordPress and operates in much the same manner. Subcategory tags use the same tag properties of the Category Tags to display information specific to the current sub-category in the loop. However, subcategory information must be called using shopp('subcategory') tags and not shopp('category').

Options

  • None

Examples

<?php if(shopp('category','hascategories')):
	while('''shopp('category','subcategories')'''): ?>
	<a href="<?php shopp('subcategory','url'); ?>">
	<?php shopp('subcategory','thumbnail'); ?>
	<?php shopp('subcategory','name'); ?></a>
	<?php endwhile; endif;?>

is-subcategory

Overview

<?php if(shopp('category','is-subcategory')) {} ?>

Detects if the current category is a subcategory or not.

Options

  • None

pagination

Overview

<?php shopp('category','pagination'); ?>

Displays a linked list of page numbers for navigating pages of products in a category.

Options

  • show: Default is 1000. Limit the number of visible links in the page navigation.
  • before: Default is <div>. Specify text or markup to be output in front of the page navigation.
  • after: Default is </div>. Specify text or markup to be output after the page navigation.
  • label: Default is Pages:. Specify text or markup to be used as the label for the page navigation that is displayed directly following the before option.
  • previous: Default is previous. Specify text or markup to be used as the label for the previous page navigation link.
  • next: Default is next. Specify text or markup to be used as the label for the next page navigation link.

has-faceted-menu

Overview

<?php if(shopp('category','has-faceted-menu')) {} ?>

Tests if the current category has faceted menus enabled.

Options

  • None

Examples

<?php if(shopp('category','has-faceted-menu')): ?>
…content displayed if the category has faceted menus enabled…
<?php endif; ?>

faceted-menu

Overview

<?php shopp('category','faceted-menu'); ?>

Shows a faceted menu of filter options to find products in the current category.

Options

  • None