How to Display Different Content Based on Category
Please note: The contents of this article apply only to licensed versions of the ProductCart software. They do not apply to stores running as a hosted application under a ProductCart Live agreement.
What if you wanted to change elements of your store design (e.g. navigation, graphics, etc.) depending on which category the customer is viewing? You can do so by using conditional statements based on the category ID. You can find out the ID of a category in many ways. For example, when editing the category in the Control Panel, look at the number that follows ?idcategory= in the browser address field.
In the storefront, the category ID is loaded onto the page ( viewcategories.asp) before header.asp and footer.asp are invoked. Therefore, you can place conditional statements in those files with the assumption that the category ID is known.
Here is a simple example. Let's assume you want to show something different when a certain category is shown. If it's just one category that you need to work with, you can use a simple “IF” statement. For instance, let's assume the category number is 100. The ASP code would be:
If you want to show different content depending on the category shown, and you are dealing with a number of different categories, the you will want to use a “SELECT CASE” statement. The ASP code in that case would be:
What if you wanted to change elements of your store design (e.g. navigation, graphics, etc.) depending on which category the customer is viewing? You can do so by using conditional statements based on the category ID. You can find out the ID of a category in many ways. For example, when editing the category in the Control Panel, look at the number that follows ?idcategory= in the browser address field.
In the storefront, the category ID is loaded onto the page ( viewcategories.asp) before header.asp and footer.asp are invoked. Therefore, you can place conditional statements in those files with the assumption that the category ID is known.
Example 1: One category
Here is a simple example. Let's assume you want to show something different when a certain category is shown. If it's just one category that you need to work with, you can use a simple “IF” statement. For instance, let's assume the category number is 100. The ASP code would be:
<% if pIdCategory=100 then %> Show special content to be displayed when category 100 is shown <% else %> Show something else <% end if %>
Example 2: Multiple categories
If you want to show different content depending on the category shown, and you are dealing with a number of different categories, the you will want to use a “SELECT CASE” statement. The ASP code in that case would be:
<% Select Case pIdCategory Case 100 response.write("Show this message when category 100 is loaded.") Case 101 response.write("Show this message when category 101 is loaded") Case 102 %> <strong>Use this HTML code when category 102 is loaded</strong>. <% Case else document.write("Show this message when other categories are loaded.") End Select %>