PDA

View Full Version : HOW TO: Display multiple columns on category pages


Quiche Jackson
04-14-06, 10:40 PM
So you want to display your category pages with multiple product columns?
We are going to display products 3 columns x 4 rows

NOTE: This 'HOW TO' is for MIVA Merchant5 users.
This example assumes your using the 'Original' template version, if you are not then adjust instruction accordingly.
Login to admin.mvc
Expand Stores >> Expand Your Store Name >> Click Pages
Edit 'CTGY Category Display'
Click 'Category Product List Layout' Tab
For ease of use lets strip the page of as much as possible before we edit the template code.
Uncheck 'Product Code'
Uncheck 'Add One To Basket'
Uncheck 'Buy One Now'
Select 'Image': None
Select 'Inventory Level Message': None
Set Pagination: 12
Click Update
Click 'Advanced Mode'Before i begin let me explain what is taking place before we edit the code.

<tr> = Table Row
<td> = Table Data Cell

The mvt:foreach tag loops through the product array and prints out a new table row for each product.
We want to have it print out 3 table data cells per table row with a product in each cell.
I removed the pagination code just to save space in this how to

<!-- BEGIN 'Category Product List Layout' ORIGINAL PAGE TEMPLATE CODE -->
<table border=0 cellpadding=2 cellspacing=0>
<mvt:foreach iterator="product" array="products">
<tr>
<td align="left" valign="top">
&nbsp;
</td>
<td align="left" valign="top" colspan=2>
<mvt:item name="fonts" param="body_font">
<a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;">&mvt:product:name;</a><br>
Price: <b>&mvt:product:formatted_price;</b><br>
Quantity in Basket:
<mvt:if expr="l.settings:product:quantity EQ 0">
<i>none</i>
<mvt:else>
<b>&mvt:product:quantity;</b>
</mvt:if>
<br>
</mvt:item>
</td>
</tr>
</mvt:foreach>
</table>
<!-- END 'Category Product List Layout' ORIGINAL PAGE TEMPLATE CODE -->

NOTE: There is a variable that exists that lets us know what position we are at in the set of product records were going to display that variable is: 'pos1'
Move the mvt:foreach tags inside the first and last table row (<tr> </tr>) tags.
If you were to stop here you would get a single horizontal row of products instead of a vertical one.
In the first table cell tag set align="center" valign="bottom" and remove colspan=2
Just before the close </mvt:foreach> tag you will notice the snippit of code that generates the columns
<!-- BEGIN 'Category Product List Layout' CUSTOM PAGE TEMPLATE CODE -->
<table border=0 cellpadding=2 cellspacing=0>
<tr>
<mvt:foreach iterator="product" array="products">
<td align="left" valign="top">
&nbsp;
</td>
<td align="center" valign="bottom">
<mvt:item name="fonts" param="body_font">
<a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;">&mvt:product:name;</a><br>
Price: <b>&mvt:product:formatted_price;</b><br>
Quantity in Basket:
<mvt:if expr="l.settings:product:quantity EQ 0">
<i>none</i>
<mvt:else>
<b>&mvt:product:quantity;</b>
</mvt:if>
<br>
</mvt:item>
</td>
<!--
This mvt:if prints out code only when pos1 is evenly divisible by 3
ex: ( pos1 MOD x ) where x equals how many columns you want. It starts a new column
-->
<mvt:if expr = "(pos1 MOD 3 ) EQ 0">
</tr>
<tr>
<td colspan=3><HR width="100%" color=#cccccc SIZE=1></td>
</tr>
<tr>
</mvt:if>
</mvt:foreach>
</tr>
</table>
<!-- END 'Category Product List Layout' CUSTOM PAGE TEMPLATE CODE -->

choupoum
05-02-06, 05:41 PM
i am trying to use this code but I am having trouble. I think that there is something broken in it.
Where can I have the right code the I can see the thumbnail and clik on it?
I can't get that code working with the "add to basket". It displays only 1 Add to basket for 3 products.

thanks

DesignExtend-MSI
05-02-06, 08:23 PM
i am trying to use this code but I am having trouble. I think that there is something broken in it.
Where can I have the right code the I can see the thumbnail and clik on it?
I can't get that code working with the "add to basket". It displays only 1 Add to basket for 3 products.

thanks

Just go to MIVA's site and look at their demo store.

noizmatik
05-17-06, 12:09 AM
I was able to do that for my categy display and it works thanks, but now how can i have the search result page to do the same ...

Dar-us-Salam.com
05-22-06, 01:53 PM
Thank you for posting the code to display mutiple columns on the category page. I had spent a lot of time figuring out how I could do this as it was mentioned in the MM5 help but it only gave one line of it without any real help. It is very difficult as where you put the MOD line code exactly determines how the category page is displayed.

After working on the modifying the code mentioned I was able to customize it for my website and will provide it here as it may be helpful for others.


<!-- BEGIN Category Product List Layout -->
<table border=0 cellpadding=2 cellspacing=2>
<tr><mvt:foreach iterator="product" array="products">
<td align="center" valign="top"><mvt:if expr="NOT ISNULL l.settings:product:thumbnail">
<a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;"><img src="&mvte:product:thumbnail;" border=0 /></a>
<mvt:else>&nbsp; </mvt:if> </td>
<td valign="top" align="left"><mvt:item name="fonts" param="body_font"> <a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;">&mvt:product:name;</a><br>
Code: <b>&mvt:product:code;</b><br>
Price: <b>&mvt:product:formatted_price;</b><br>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :Format"> &mvt:customfield_names:customfields:Format;: <b>&mvt:product:customfield_values:customfields:Format ;</b><br>
</mvt:if>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :Author"> &mvt:customfield_names:customfields:Author;: <b>&mvt:product:customfield_values:customfields:Author ;</b><br>
</mvt:if>
<mvt:if expr="l.settings:product:inv_active"> &mvt:product:inv_short;<br>
</mvt:if>
Quantity in Basket:
<mvt:if expr="l.settings:product:quantity EQ 0"> <i>none</i>
<mvt:else>
<b>&mvt:product:quantity;</b> </mvt:if>
</mvt:item>
<br />
<form method="post" action="&mvt:global:sessionurl;">
<mvt:item name="fonts" param="body_font">
<input type="hidden" name="Action" value="ADPR">
<input type="hidden" name="Screen" value="&mvte:global:Screen;">
<input type="text" name="Quantity" value=1 size="3">
<input type="hidden" name="Attributes" value="Yes">
<input type="hidden" name="Store_Code" value="&mvte:store:code;">
<input type="hidden" name="Offset" value="&mvte:global:Offset;">
<input type="hidden" name="Product_Code" value="&mvte:product:code;">
<input type="hidden" name="Current_Product_Code" value="&mvte:global:Product_Code;">
<input type="hidden" name="Category_Code" value="&mvte:global:Category_Code;">
<mvt:item name="buttons" param="AddToBasket" />
</mvt:item>
</form></td>
<mvt:if expr = "(pos1 MOD 2 ) EQ 0">
</tr>
<tr>
<td colspan=4><HR width="100%" color=#cccccc SIZE=1></td>
</tr>
</mvt:if>
</mvt:foreach>
</table>
<!-- END Category Product List Layout-->

kelly
05-25-06, 05:49 AM
Hello, I followed the directions above. Basically I pasted your code into the category Product list layout (within the advanced mode) but I wanted 2 columns (each thumbnail is 280x75), so 2 thumbnails (making the 2 column)side by side with 10 rows. Where would I enter that criderier (you wanted 3 col x 4 rows right?). How would I edit that? As well as where would I enter the new size for the thumbnails?
In addition nothing shows up on my store front page? Not even when I secect the "bumper" category on home page www.politdecals.com (http://www.politdecals.com). If anyone has time to help? Thank you,
Kelly

Bruce - PhosphorMedia
05-25-06, 06:14 AM
You would change:

<mvt:if expr = "(pos1 MOD 3 ) EQ 0">

to

<mvt:if expr = "(pos1 MOD 2 ) EQ 0">


As for entering the size of the thumbnails, you don't really have to, but you would open the Category Product List Layout in advanced mode and enter the height width into the statement:

<img src="&mvte:product:thumbnail;" border=0>

Dar-us-Salam.com
05-25-06, 02:31 PM
Kelly, when I visited your site I see that you haven't assigned any of products to the Bumper category which is not allowing any thing to show up. You need to click on Category > Products tab > select the assoricated products and click update.

To enter a weolcome message on the main store front you need to write it here>
Stores > Click on Store name (not the plus sign) > click on Messages and enter the text/html code.

kelly
05-26-06, 05:20 AM
Hello,

I have the products selected and again selected update but still nothing? >Edit Category>products>5 items are selected and update, still nothing.

Thx,

Kelly

kelly
05-26-06, 06:17 AM
Bruce,

Hi, according to your reply you said to change this field <mvt:if expr = "(pos1 MOD 2 ) EQ 0">
Below is my code and it looks like it the mod is set to 2 already. The 2 columns don't appear though? Any idea why? Maybe bec the small thumbnails are 280/75? Help please :)
<!-- BEGIN Category Product List Layout -->
<table border=0 cellpadding=2 cellspacing=2>
<tr><mvt:foreach iterator="product" array="products">
<td align="center" valign="top"><mvt:if expr="NOT ISNULL l.settings:product:thumbnail">
<a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;"><img src="&mvte:product:thumbnail;" border=0 /></a>
<mvt:else>&nbsp; </mvt:if> </td>
<td valign="top" align="left"><mvt:item name="fonts" param="body_font"> <a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;">&mvt:product:name;</a><br>
Code: <b>&mvt:product:code;</b><br>
Price: <b>&mvt:product:formatted_price;</b><br>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :Format"> &mvt:customfield_names:customfields:Format;: <b>&mvt:product:customfield_values:customfields:Format ;</b><br>
</mvt:if>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :Author"> &mvt:customfield_names:customfields:Author;: <b>&mvt:product:customfield_values:customfields:Author ;</b><br>
</mvt:if>
<mvt:if expr="l.settings:product:inv_active"> &mvt:product:inv_short;<br>
</mvt:if>
Quantity in Basket:
<mvt:if expr="l.settings:product:quantity EQ 0"> <i>none</i>
<mvt:else>
<b>&mvt:product:quantity;</b> </mvt:if>
</mvt:item>
<br />
<form method="post" action="&mvt:global:sessionurl;">
<mvt:item name="fonts" param="body_font">
<input type="hidden" name="Action" value="ADPR">
<input type="hidden" name="Screen" value="&mvte:global:Screen;">
<input type="text" name="Quantity" value=1 size="3">
<input type="hidden" name="Attributes" value="Yes">
<input type="hidden" name="Store_Code" value="&mvte:store:code;">
<input type="hidden" name="Offset" value="&mvte:global:Offset;">
<input type="hidden" name="Product_Code" value="&mvte:product:code;">
<input type="hidden" name="Current_Product_Code" value="&mvte:global:Product_Code;">
<input type="hidden" name="Category_Code" value="&mvte:global:Category_Code;">
<mvt:item name="buttons" param="AddToBasket" />
</mvt:item>
</form></td>
<mvt:if expr = "(pos1 MOD 2 ) EQ 0">
</tr>
<tr>
<td colspan=4><HR width="100%" color=#cccccc SIZE=1></td>
</tr>
</mvt:if>
</mvt:foreach>
</table>
<!-- END Category Product List Layout-->

Much Thanks,

Kelly

newguyintown
03-12-08, 12:24 AM
Hello - pardon my jumping on board, but I'm trying to do the same thing and finally found this thread. I tried to add the "column" code in the same place as in the examples above, but I get no columns - everything stays in it's original layout. What am I doing wrong?

Here's the
<table border=0 cellpadding=2 cellspacing=0>
<mvt:foreach iterator="product" array="products">
<tr><td colspan=3>
<br>
<br>
<br>
</td></tr>
<tr><td align="left" valign="top">
&nbsp;
</td><td align="left" valign="top" colspan=2>
<mvt:item name="fonts" param="body_font">
<a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;&Category_Code=&mvta:category:code;">&mvt:product:name;</a><br>
Part #: <b>&mvt:product:code;</b><br>
<mvt:if expr="l.settings:product:price NE '0.01'">
Price: <b>&mvt:product:formatted_price;</b>
<mvt:else>
Price: <font size="1.5" color="blue"> Please call 877-928-1646 or email for price. </font>
</mvt:if><br>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :AIP">
&mvt:customfield_names:customfields:AIP;:
<b>&mvt:product:customfield_values:customfields:AIP;</b><br>
</mvt:if>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :NRT">
&mvt:customfield_names:customfields:NRT;:
<b>&mvt:product:customfield_values:customfields:NRT;</b><br>
</mvt:if>
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields :APP">
&mvt:customfield_names:customfields:APP;:
<font size="1.5"><b>&mvt:product:customfield_values:customfields:APP;</b></font><br>
</mvt:if>
<mvt:if expr="l.settings:product:inv_active">
</mvt:if>
Quantity in Basket:
<mvt:if expr="l.settings:product:quantity EQ 0">
<i>none</i>
<mvt:else>
<b>&mvt:product:quantity;</b>
</mvt:if>
<br>
</mvt:item>
</td></tr>
<mvt:if expr="l.settings:product:inv_level NE 'out'">
<tr>
<td>&nbsp;</td>
<form method="post" action="&mvt:global:sessionurl;">
<td align="left" valign="top">
<mvt:item name="fonts" param="body_font">
<input type="hidden" name="Action" value="ADPR">
<input type="hidden" name="Screen" value="&mvte:global:Screen;">
<input type="hidden" name="Quantity" value=1>
<input type="hidden" name="Attributes" value="Yes">
<input type="hidden" name="Store_Code" value="&mvte:store:code;">
<input type="hidden" name="Offset" value="&mvte:global:Offset;">
<input type="hidden" name="Product_Code" value="&mvte:product:code;">
<input type="hidden" name="Current_Product_Code" value="&mvte:global:Product_Code;">
<input type="hidden" name="Category_Code" value="&mvte:global:Category_Code;">
<mvt:item name="buttons" param="Add1ToBasket" />
</mvt:item>
</form></td>
<mvt:if expr = "(pos1 MOD 2 ) EQ 0">
</tr>
<tr>
<td colspan=4><HR width="100%" color=#cccccc SIZE=1></td>
</tr>
</mvt:if>
</mvt:foreach>
</table>
<mvt:if expr="g.Offset OR g.NextOffset">
<br>
<table border="0" width="90%" align="center">
<tr>
<mvt:if expr="g.Offset EQ 0">
<td>&nbsp;</td>
<mvt:else>
<td align="left">
<mvt:item name="fonts" param="body_font">
<form method="post" action="&mvt:global:sessionurl;">
<input type="hidden" name="Screen" value="&mvte:global:Screen;">
<input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;">
<input type="hidden" name="Category_Code" value="&mvte:global:Category_Code;">
<input type="hidden" name="Product_Code" value="&mvte:global:Product_Code;">
<input type="hidden" name="Search" value="&mvte:global:Search;">
<input type="hidden" name="Offset" value="&mvte:global:PrevOffset;">
<mvt:item name="buttons" param="Previous" />
</form>
</mvt:item>
</td>
</mvt:if>
<mvt:if expr="g.NextOffset EQ 0">
<td>&nbsp;</td>
<mvt:else>
<td align="right">
<mvt:item name="fonts" param="body_font">
<form method="post" action="&mvt:global:sessionurl;">
<input type="hidden" name="Screen" value="&mvte:global:Screen;">
<input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;">
<input type="hidden" name="Category_Code" value="&mvte:global:Category_Code;">
<input type="hidden" name="Product_Code" value="&mvte:global:Product_Code;">
<input type="hidden" name="Search" value="&mvte:global:Search;">
<input type="hidden" name="Offset" value="&mvte:global:NextOffset;">
<mvt:item name="buttons" param="Next" />
</form>
</mvt:item>
</td>
</mvt:if>
</tr>
</table>
</mvt:if>

Any help is appreciated. Thanks!