<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SEO WebMonkey &#187; enhancement</title>
	<atom:link href="http://seowebmonkey.com/stuff/enhancement/feed/" rel="self" type="application/rss+xml" />
	<link>http://seowebmonkey.com</link>
	<description>Web design &#38; development with an ample sprinkle of SEO</description>
	<lastBuildDate>Tue, 01 Jun 2010 09:03:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Magento &#8211; customising individual product category pages</title>
		<link>http://seowebmonkey.com/magento-customising-individual-product-category-pages/</link>
		<comments>http://seowebmonkey.com/magento-customising-individual-product-category-pages/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 10:49:52 +0000</pubDate>
		<dc:creator>ndixon</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[enhancement]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://seowebmonkey.com/?p=156</guid>
		<description><![CDATA[Magento's templating structure strikes me as a little odd in places, but is very capable. But capability invariably breeds complexity.]]></description>
			<content:encoded><![CDATA[<p><strong>Task: change the number of columns and displayed products on individual category pages.</strong></p>
<p>Magento uses a combination of xml layout directives and php/html (.phtml) template files to build the front-end interface (storefront) of a web shop. Fundamental changes to the look and feel of the store can and should be made directly in these files, all of which reside in the directory:</p>
<pre>/app/design/frontend/default/</pre>
<p>Smaller scale tweaks to page content can also be added from within the admin interface. Customising the content of an individual category page, for example, is achieved through adding xml code segments to the <em>Custom Design</em> tab of a category.</p>
<p><a href="http://seowebmonkey.com/wp-content/uploads/2010/01/category-custom-design.jpg"><img class="size-medium wp-image-157 alignright" title="category-custom-design" src="http://seowebmonkey.com/wp-content/uploads/2010/01/category-custom-design-300x169.jpg" alt="category-custom-design" width="300" height="169" /></a></p>
<p>The difficulty we found was that any customisations for an individual category were added to the page in addition to the standard category layout definitions, rather than replace them with a new, unique set of directives. Resulting, in our case, to duplicated elements on the page.</p>
<h2>Solution 1: Create an additional template</h2>
<p>The admin allows selection of an entirely different template for an individual category. A powerful option, that&#8217;s for sure, but hugely impractical for ongoing maintenance. Multiple templates means multiple changes to layout, phtml and possibly css files if any tweaks are required in the future.</p>
<h2>Solution 2: Add category-specific custom code to the master layout xml file</h2>
<p>The default category layouts are defined in <em>/app/design/frontend/default/-your-template-/layout/catelog.xml</em> (just look for the <em>&lt;catalog_category_default&gt;</em> element).</p>
<p>To add code for a specific category, all one needs to do is create a new element containing the internal ID of that category (changing XX to the category&#8217;s internal ID):</p>
<pre>&lt;CATEGORY_XX&gt;</pre>
<pre>  ....</pre>
<pre>&lt;/CATEGORY_XX&gt;</pre>
<p>A good solution which fails only in that it becomes less portable. These xml files are designed to handle the template as a whole. Having specific category designations here mean the template can only be used for a single store with the correct category ID values.</p>
<h2>Solution 3: Add custom xml code to the category via the Administration interface</h2>
<p>The most practical solution, without a doubt. Here the custom code affects only the single category (and its child-categories should that be selected as an option).</p>
<p>However, both Solution 2 and Solution 3 must solve the problem that additional xml is added to the default xml. In our case, however, we must override the default settings to avoid duplication.</p>
<h2>The <em>unsetChild</em> method</h2>
<p><a href="http://seowebmonkey.com/wp-content/uploads/2010/01/category-custom-design.jpg"><img class="alignright size-thumbnail wp-image-157" title="category-custom-design" src="http://seowebmonkey.com/wp-content/uploads/2010/01/category-custom-design-150x150.jpg" alt="category-custom-design" width="150" height="150" /></a>Thankfully, Magento provides a means of overriding the default elements, as defined in the layout template, to be replaced by new elements. You can see the <em>unsetChild</em> methods implimented in the screenshot here.</p>
<h4><em>unsetChild</em></h4>
<p>The method tells magento to remove whatever definitions that have already been created for the named elements. Usually, these would have been defined in the main template xml files. It does not remove the named elements themselves, so you are then free to redefine those elements as you wish.</p>
<p>In our case, we wanted to replace the c<em>ategory.products</em>, <em>product_list</em>, and <em>product_list_toolbar</em> elements to avoid duplicating the product grid.</p>
<p>Once <em>unsetChild</em> had been called, we were free to add our customised grid definition below it.</p>
<p>The results are a default, <a href="http://sawber.com/artists/neil-dixon/drawing.html" target="_blank">3-column, 9 product grid for most of the catalog</a>, but a <a href="http://sawber.com/artists/neil-dixon/collections/window.html" target="_blank">4-column, 12 product grid for some individual category</a> pages.</p>
<h2>The <em>remove</em> method</h2>
<p>Magento also provides the ability to entirely remove elements from the xml definition.</p>
<pre>&lt;remove name="xxxx" /&gt;</pre>
<p>This completely removes the defined element, by name. Inappropriate in our case, because it does not provide the option of re-inserting a new version of the element into the page; it removes that element name entirely.</p>
]]></content:encoded>
			<wfw:commentRss>http://seowebmonkey.com/magento-customising-individual-product-category-pages/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
