<?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>Craig Murray</title>
	<atom:link href="http://craigmurray.me.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://craigmurray.me.uk</link>
	<description>The website of me, Craig Murray</description>
	<lastBuildDate>Sun, 16 Jan 2011 15:07:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Before you buy an eCommerce template check out the Product pages</title>
		<link>http://craigmurray.me.uk/ecommerce/before-you-buy-an-ecommerce-template-check-out-the-product-pages/</link>
		<comments>http://craigmurray.me.uk/ecommerce/before-you-buy-an-ecommerce-template-check-out-the-product-pages/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 17:17:08 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[eCommerce]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=193</guid>
		<description><![CDATA[I&#8217;ve been designing a few eCommerce templates based on OpenCart recently and have been thinking a lot about what to get right. A lot of sites that offer templates for eCommerce sites have lovely Home pages with wonderful graphics and &#8230; <a href="http://craigmurray.me.uk/ecommerce/before-you-buy-an-ecommerce-template-check-out-the-product-pages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been designing a few eCommerce templates based on OpenCart recently and have been thinking a lot about what to get right.  A lot of sites that offer templates for eCommerce sites have lovely Home pages with wonderful graphics and advanced features such as AJAX sliders or image galleries.  But there&#8217;s one problem&#8230;<br />
<span id="more-193"></span></p>
<p>Since starting an eCommerce site 3 months ago, with only 50 products, my Home page has had 1,800 unique page views.  Not bad I guess, but the site has had 22,300 unique page views. So should I concentrate on making my Home page beautiful, or should I make the other pages the best they can be, to turn visits into sales?</p>
<p>Those templates with the lovely graphics on the Home page, the AJAX sliders and image galleries&#8230; they look beautiful. They look tempting. They look like they are worth $10. Hell, they look like they are worth $150.  I want to lick them. I want to design a site that looks that beautiful. If I could, I&#8217;d die happy. But those lovely graphics are not there to help you sell your products. They are there to sell you a template. Don&#8217;t be a sucker.</p>
<p>When I look at the demos these sites have to offer and visit the Category pages and the Product pages I am almost always disappointed. They have hardly been changed from the default. They look&#8230;, well&#8230; frankly, a lot of them look rubbish.</p>
<p>Why is that a problem when you have such a beautiful Home page?  Because, if you&#8217;re doing things right, most of your visitors will never even look at the Home page. Unless you&#8217;re Amazon the only impression visitors will have of your site is from looking at a Product page. If you&#8217;ve done your SEO properly, and I hope you have, someone searching for one of your products will find that product&#8217;s page. If they like what they see they will buy it, or look for more information.</p>
<p>If a visitor doesn&#8217;t like what they see they will leave and go to a competitor. If visitors do look at the Home page, it&#8217;s only because they decided to check out another page on your site after looking at a Product page.</p>
<p>Remember, no one ever buys anything from the Home page. So when buying a template, or designing your own site, forget about the Home page and ask yourself, would you buy from this Product page?</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/ecommerce/before-you-buy-an-ecommerce-template-check-out-the-product-pages/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to exclude some categories when listing categories in the header in OpenCart</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-exclude-some-categories-when-listing-categories-in-the-header-in-opencart/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-exclude-some-categories-when-listing-categories-in-the-header-in-opencart/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 14:16:05 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=185</guid>
		<description><![CDATA[In trying to introduce a bit more flexibility into OpenCart I&#8217;ve realised that category pages are great for special promotions or themed pages in OpenCart. However, you may not want these promotional pages or themed pages to show up in &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-exclude-some-categories-when-listing-categories-in-the-header-in-opencart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In trying to introduce a bit more flexibility into OpenCart I&#8217;ve realised that category pages are great for special promotions or themed pages in OpenCart. However, you may not want these promotional pages or themed pages to show up in your main navigation.  Here&#8217;s how to exclude some categories from the main navigation in your header in OpenCart.<span id="more-185"></span></p>
<p>As an example, at this time of year you might have some products that you want to promote for Christmas.  You could use a Category page to create a beautiful Christmas page and list your Christmas products there.  However, you may prefer to promote this page on your home page with a big splash image and link to it from there, rather than have it appear in your main navigation, which you may want to keep the same all year round.</p>
<p>This bit of code adapts the original code in my <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/">How to list categories in the header in OpenCart</a> post. It starts by creating an array of the categories that you wish to exclude from the main navigation. I&#8217;ve used some of the original OpenCart default categories as examples. You will need to enter the names of the specific categories you do not want to list in the first line.</p>
<p>If you use more than one language, you&#8217;ll have to list all the translations of the category name. Sorry about that. Admittedly this could have been avoided if I had excluded categories by category id, but if you are using SEO URLs it is difficult to find out what the id of a category is without having a look at your database and I wanted to make this as easy to use as possible.</p>
<p>This is how it works. Before listing a category the code loops through the $excludes array. If the name of the category appears in the array then $listcat is set to false and the category is not listed.  It&#8217;s as simple as that.<br />
<code><br />
&lt;?php<br />
$excludes = array('Desktops', 'Components', 'Software');<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories();<br />
if ($results) {$output = '&lt;ul&gt;';}<br />
foreach ($results as $result) {<br />
$listcat = true;<br />
foreach ($excludes as $exclude) {<br />
if ($result['name'] == $exclude) {$listcat = false;}<br />
}<br />
if ($listcat == true) {<br />
$output .= '&lt;li&gt;';<br />
$new_path = $result['category_id'];<br />
$unrewritten = HTTP_SERVER.'index.php?route=product/category&amp;path='.$new_path;<br />
$rewritten = $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
$output .= '&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['name'].'&lt;/a&gt;';<br />
$output .= '&lt;/li&gt;';<br />
}<br />
}<br />
if ($results) {$output .= '&lt;/ul&gt;';}<br />
echo $output;<br />
?&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-exclude-some-categories-when-listing-categories-in-the-header-in-opencart/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to put the Category module in the footer in OpenCart without editing the source code</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-put-the-category-module-in-the-footer-in-opencart-without-editing-the-source-code/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-put-the-category-module-in-the-footer-in-opencart-without-editing-the-source-code/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 21:39:56 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=177</guid>
		<description><![CDATA[I&#8217;ve been busy setting up a shop recently, but I&#8217;ve now started developing themes for OpenCart again. I&#8217;ve sorted out the problems with my post on how to add the Information module in the footer in OpenCart and have applied &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-put-the-category-module-in-the-footer-in-opencart-without-editing-the-source-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been busy setting up a shop recently, but I&#8217;ve now started developing themes for OpenCart again. I&#8217;ve sorted out the problems with my post on <a href="http://craigmurray.me.uk/opencart-mods/how-to-put-the-information-module-in-the-footer-in-opencart-without-editing-the-source-code/">how to add the Information module in the footer in OpenCart</a> and have applied the same technique to add the Category module in the footer in OpenCart without editing the source code.<span id="more-177"></span></p>
<p>The principle is exactly the same as listing the Information in the footer. Firstly you need to load the category model.  You can then run the getCategories function and output the results.  In order to work with SEO URLs you also need to load the SEO URL tool. Finally, in order for the heading to work with other languages you also need to load the category language data.</p>
<p>Anyway, here&#8217;s the code. Just stick it in your footer and enjoy:<br />
<code><br />
&lt;?php<br />
$this-&gt;language-&gt;load('module/category');<br />
$heading_title = $this-&gt;language-&gt;get('heading_title');<br />
?&gt;<br />
&lt;h3&gt;&lt;?php echo $heading_title ?&gt;&lt;/h3&gt;<br />
&lt;?php<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$this-&gt;load-&gt;model('catalog/category');<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories();<br />
if ($results) {$output = '&lt;ul&gt;';}<br />
foreach ($results as $result) {<br />
$new_path = $result['category_id'];<br />
$unrewritten = HTTP_SERVER.'index.php?route=product/category&amp;path=' . $new_path;<br />
$rewritten = $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
$output .= '&lt;li&gt;&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['name'].'&lt;/a&gt;&lt;/li&gt;';<br />
}<br />
if ($results) {$output .= '&lt;/ul&gt;';}<br />
echo $output;<br />
?&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-put-the-category-module-in-the-footer-in-opencart-without-editing-the-source-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to put the Information module in the footer in OpenCart without editing the source code</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-put-the-information-module-in-the-footer-in-opencart-without-editing-the-source-code/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-put-the-information-module-in-the-footer-in-opencart-without-editing-the-source-code/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 20:17:39 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=158</guid>
		<description><![CDATA[Not being a programmer, it&#8217;s taken me a while, but I&#8217;ve started to work out how OpenCart works. So when I decided I wanted to try and put the Information details in the footer without editing any source code it &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-put-the-information-module-in-the-footer-in-opencart-without-editing-the-source-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Not being a programmer, it&#8217;s taken me a while, but I&#8217;ve started to work out how OpenCart works. So when I decided I wanted to try and put the Information details in the footer without editing any source code it wasn&#8217;t too hard.<span id="more-158"></span></p>
<p>Firstly you need to load the SEO URL tool (incase people are using SEO URLs, which they should be) and you need to load the Information language module (to allow for different language options).  After that you can use the getInformations() function to access most of the Information module.</p>
<p>getInformations() doesn&#8217;t include &#8220;Contact Us&#8221; or &#8220;Site Map&#8221; for some reason, so you have to add them at the end. Apart from that, it&#8217;s pretty straightforward. Here&#8217;s the code:</p>
<p>Edit: This now includes adaptations as suggested in the comments following the article. That&#8217;ll teach me to post before I&#8217;ve fully tested!</p>
<p>Second edit: This now doesn&#8217;t include the adaptations as suggested in the comments because I worked out how to make it work without having the Information module enabled.  This should work perfectly now.<br />
<code><br />
&lt;?php<br />
$this-&gt;language-&gt;load('module/information');<br />
$heading_title = $this-&gt;language-&gt;get('heading_title');<br />
?&gt;<br />
&lt;h3&gt;&lt;?php echo $heading_title ?&gt;&lt;/h3&gt;<br />
&lt;ul&gt;<br />
&lt;?php<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$this-&gt;load-&gt;model('catalog/information');<br />
$output = '';<br />
$results = $this-&gt;model_catalog_information-&gt;getInformations();<br />
foreach ($results as $result) {<br />
$output .= '&lt;li&gt;';<br />
$new_path = $result['information_id'];<br />
$unrewritten = HTTP_SERVER.'index.php?route=information/information&amp;information_id='.$new_path;<br />
$rewritten = $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
$output .= '&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['title'].'&lt;/a&gt;';<br />
$output .= '&lt;/li&gt;';<br />
}<br />
echo $output;<br />
$text_contact = $this-&gt;language-&gt;get('text_contact');<br />
$text_sitemap = $this-&gt;language-&gt;get('text_sitemap');<br />
?&gt;<br />
&lt;li&gt;&lt;a href="&lt;?php HTTP_SERVER ?&gt;index.php?route=information/contact"&gt;&lt;?php echo $text_contact ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="&lt;?php HTTP_SERVER ?&gt;index.php?route=information/sitemap"&gt;&lt;?php echo $text_sitemap ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-put-the-information-module-in-the-footer-in-opencart-without-editing-the-source-code/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How to highlight the current category in the header in OpenCart</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-highlight-the-current-category-in-the-header-in-opencart/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-highlight-the-current-category-in-the-header-in-opencart/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 23:39:14 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=151</guid>
		<description><![CDATA[If you use categories in the header in OpenCart as navigation, it helps with usability to highlight the parent, or top-level category of the page your user is on. Here&#8217;s how to list categories and highlight the parent category without &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-highlight-the-current-category-in-the-header-in-opencart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you use categories in the header in OpenCart as navigation, it helps with usability to highlight the parent, or top-level category of the page your user is on. Here&#8217;s how to list categories and highlight the parent category without any edits to the source code.<br />
<span id="more-151"></span></p>
<p>Following on from my previous posts about <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/">listing categories in the header</a> and <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-all-categories-and-sub-categories-in-the-header-in-opencart/">listing categories and sub-categories in the header in OpenCart</a>, I thought I&#8217;d try to work out how to highlight the top-level category, just to finish the job I&#8217;d started.</p>
<p>It turned out to be reasonably easy.</p>
<p>If you are on a category page, or on a product page reached via a category, and you run $this-&gt;request-&gt;get['path'] it outputs the category path that you see in the URL.  For example, if you are on a page with a URL like this:<br />
index.php?route=product/product&amp;path=25_28&amp;product_id=33<br />
then $this-&gt;request-&gt;get['path'] will output &#8220;25_28&#8243;.</p>
<p>All we need to do is then get the first number from that string, which will give us the category ID of the top level category.  I&#8217;m not a PHP programmer so there&#8217;s probably a much better way of doing this, but the method I&#8217;ve used works. I &#8216;explode&#8217; the output, using &#8220;_&#8221; as the delimiter.  This means if you explode 25_28 using &#8220;_&#8221; you will get an array with key zero (the first key) having a value of 25 and key one (the second key) having a value of 28. What we want to use is the first one, key zero, which is stored at $the_array[0].</p>
<p>We can now easily highlight the top-level category.  As we list the categories using &lt;li&gt;, when we come across the one with the top-level ID we list it using &lt;li id=&#8221;current-cat&#8221;&gt; and then give #current-cat a style in the stylesheet, e.g:<br />
#current-cat {background-color: #cccccc;}</p>
<p>Job done!</p>
<p>Below is the code for listing top-level categories and highlighting the one your user is in.  If you want to list subcategories too, see my other post on listing subcategories mentioned above.</p>
<p><code>&lt;?php<br />
$top_cat_id = '';<br />
if (isset($this-&gt;request-&gt;get['path'])) {<br />
$path = $this-&gt;request-&gt;get['path'];<br />
$cat_array = explode ("_", $path);<br />
$top_cat_id = $cat_array[0];<br />
}<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories();<br />
if ($results) {$output = '&lt;ul&gt;';}<br />
	foreach ($results as $result) {<br />
		$new_path = $result['category_id'];<br />
		$unrewritten = HTTP_SERVER.'index.php?route=product/category&amp;path=' . $new_path;<br />
		$rewritten =  $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
		if ($new_path == $top_cat_id) {<br />
			$output .= '&lt;li id="current-cat"&gt;&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['name'].'&lt;/a&gt;';<br />
	} else {<br />
		$output .= '&lt;li&gt;&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['name'].'&lt;/a&gt;';<br />
		}<br />
		$output .= '&lt;/li&gt;';<br />
		}<br />
if ($results) {$output .= '&lt;/ul&gt;';}<br />
echo $output;<br />
?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-highlight-the-current-category-in-the-header-in-opencart/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to list all categories and sub-categories in the header in OpenCart</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-list-all-categories-and-sub-categories-in-the-header-in-opencart/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-list-all-categories-and-sub-categories-in-the-header-in-opencart/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 17:54:52 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=134</guid>
		<description><![CDATA[In an earlier post I detailed how to list categories in the header in OpenCart without changing any of the source files. I&#8217;ve now extended the script to list sub-categories. Basically, the original script looped through all the top-level categories &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-all-categories-and-sub-categories-in-the-header-in-opencart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In an earlier post I detailed <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/">how to list categories in the header in OpenCart</a> without changing any of the source files. I&#8217;ve now extended the script to list sub-categories.<span id="more-134"></span></p>
<p>Basically, the original script looped through all the top-level categories and put them in an unordered list. In this new script I&#8217;ve just repeated the loop within each top-level category.  It loops through all the sub-categories of the top-level category (if there are any) and puts them in an unordered list too.</p>
<p>Please note that it will only output the top-level, and second-level categories.  If you have third- and fourth-level categories you will need to repeat the loop again within each sub-category in order to list them. But, honestly, if you have third- and fourth-level categories in your shop I&#8217;d think about restructuring how you&#8217;ve ordered it. <img src='http://craigmurray.me.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Edit: Shahz, in the comments below, has written a version that lists the third level. You can find it here: <a href="http://www.shahz.net/web-development/open-cart-header-navigation-three-level-list.html">http://www.shahz.net/web-development/open-cart-header-navigation-three-level-list.html<br />
</a><br />
Thanks Shahz.</p>
<p>Anyway, here&#8217;s the code: </p>
<p><code>&lt;?php<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories();<br />
if ($results) {$output = '&lt;ul&gt;';}<br />
foreach ($results as $result) {<br />
$output .= '&lt;li&gt;';<br />
$new_path = $result['category_id'];<br />
$unrewritten = HTTP_SERVER.'index.php?route=product/category&amp;path=' . $new_path;<br />
$rewritten =  $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
$output .= '&lt;a href="' . $rewritten . '"&gt;' . $result['name'] . '&lt;/a&gt;';<br />
$sub_results = $this-&gt;model_catalog_category-&gt;getCategories($new_path);<br />
if ($sub_results) {$output .= '&lt;ul&gt;';}<br />
foreach ($sub_results as $sub_result) {<br />
$output .= '&lt;li&gt;';<br />
$new_sub_path = $sub_result['category_id'];<br />
$sub_unrewritten = $unrewritten.'_'. $new_sub_path;<br />
$sub_rewritten =  $this-&gt;model_tool_seo_url-&gt;rewrite($sub_unrewritten);<br />
$output .= '&lt;a href="' . $sub_rewritten . '"&gt;' . $sub_result['name'] . '&lt;/a&gt;';<br />
$output .= '&lt;/li&gt;';<br />
}<br />
if ($sub_results) {$output .= '&lt;/ul&gt;';}<br />
$output .= '&lt;/li&gt;';<br />
}<br />
if ($results) {$output .= '&lt;/ul&gt;';}<br />
echo $output;<br />
?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-list-all-categories-and-sub-categories-in-the-header-in-opencart/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Better search in OpenCart &#8211; search product descriptions by default</title>
		<link>http://craigmurray.me.uk/opencart-mods/better-search-in-opencart-search-product-description-by-default/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/better-search-in-opencart-search-product-description-by-default/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 15:12:08 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=118</guid>
		<description><![CDATA[By default, the search function in OpenCart is pretty limited and only searches product names. In Advanced Search there is an option to Search in product descriptions. Here&#8217;s how to make OpenCart search in product descriptions, and in all categories, &#8230; <a href="http://craigmurray.me.uk/opencart-mods/better-search-in-opencart-search-product-description-by-default/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, the search function in OpenCart is pretty limited and only searches product names.  In Advanced Search there is an option to Search in product descriptions.  Here&#8217;s how to make OpenCart search in product descriptions, and in all categories, by default.<span id="more-118"></span></p>
<p>If you are running a large shop with thousands of products you don&#8217;t want to search the product descriptions by default as it will take a long time. However, if you&#8217;ve only got a small or medium-sized shop you can give your visitors a better search experience by enabling search in product description by default.</p>
<p>The javascript for the search, located near the base of the header template file, header.tpl is as follows:</p>
<p><code>&lt;script type="text/javascript"&gt;&lt;!--<br />
$('#search input').keydown(function(e) {<br />
if (e.keyCode == 13) {<br />
moduleSearch();<br />
}<br />
});<br />
function moduleSearch() {<br />
url = 'index.php?route=product/search';<br />
var filter_keyword = $('#filter_keyword').attr('value')<br />
if (filter_keyword) {<br />
url += '&amp;keyword=' + encodeURIComponent(filter_keyword);<br />
}<br />
var filter_category_id = $('#filter_category_id').attr('value');<br />
if (filter_category_id) {<br />
url += '&amp;category_id=' + filter_category_id;<br />
}<br />
location = url;<br />
}<br />
//--&gt;&lt;/script&gt;</code></p>
<p>If you want to search product descriptions and all categories by default, change this javascript to the following:</p>
<p><code>&lt;script type="text/javascript"&gt;&lt;!--<br />
$('#search input').keydown(function(e) {<br />
if (e.keyCode == 13) {<br />
moduleSearch();<br />
}<br />
});<br />
function moduleSearch() {<br />
url = 'index.php?route=product/search';<br />
var filter_keyword = $('#filter_keyword').attr('value')<br />
if (filter_keyword) {<br />
url += '&amp;keyword=' + encodeURIComponent(filter_keyword) + '&amp;description=true';<br />
}<br />
location = url;<br />
}<br />
//--&gt;&lt;/script&gt;</code></p>
<p>Notice we&#8217;ve added &#8220;description=true&#8221; and removed the category filter. That&#8217;s all you need to do. If you do so, I&#8217;d recommend deleting the categories select box from the search div (div9 in the default template). I&#8217;d also lose the link to Advanced Search as you are already providing an advanced search.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/better-search-in-opencart-search-product-description-by-default/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to list categories in the header in OpenCart</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 14:31:46 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=115</guid>
		<description><![CDATA[I&#8217;m working on a one column layout theme for OpenCart. This of course means that there are no sidebars at the left or right hand side so, as well as putting the cart in the header area, I needed to &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a one column layout theme for OpenCart.  This of course means that there are no sidebars at the left or right hand side so, as well as putting the cart in the header area, I needed to list the top level categories in the header. This is how I did it without editing the OpenCart source code.<span id="more-115"></span></p>
<p>I searched the OpenCart forums for a long time and didn&#8217;t find a solution I was happy with. All the solutions I found involved creating new modules and/or editing source code to include them in the header. Finally, with only a basic knowledge of PHP, I decided to jump in and try and write my own solution, and after a lot of trial and error (and many, many error messages) I got it working and it seems to work without any issues.</p>
<p>I started with the getCategories function from catalog/controller/module/category.php.  Here it is:</p>
<p><code>protected function getCategories($parent_id, $current_path = '') {<br />
$category_id = array_shift($this-&gt;path);<br />
$output = '';<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories($parent_id);<br />
if ($results) {<br />
$output .= '&lt;ul&gt;';<br />
}<br />
foreach ($results as $result) {<br />
if (!$current_path) {<br />
$new_path = $result['category_id'];<br />
} else {<br />
$new_path = $current_path . '_' . $result['category_id'];<br />
}<br />
$output .= '&lt;li&gt;';<br />
$children = '';<br />
if ($category_id == $result['category_id']) {<br />
$children = $this-&gt;getCategories($result['category_id'], $new_path);<br />
}<br />
if ($this-&gt;category_id == $result['category_id']) {<br />
$output .= '&lt;a href="' . $this-&gt;model_tool_seo_url-&gt;rewrite(HTTP_SERVER . 'index.php?route=product/category&amp;path=' . $new_path)  . '"&gt;&lt;b&gt;' . $result['name'] . '&lt;/b&gt;&lt;/a&gt;';<br />
} else {<br />
$output .= '&lt;a href="' . $this-&gt;model_tool_seo_url-&gt;rewrite(HTTP_SERVER . 'index.php?route=product/category&amp;path=' . $new_path)  . '"&gt;' . $result['name'] . '&lt;/a&gt;';<br />
}<br />
$output .= $children;<br />
$output .= '&lt;/li&gt;';<br />
}<br />
if ($results) {<br />
$output .= '&lt;/ul&gt;';<br />
}<br />
return $output;<br />
}</code></p>
<p>I put this in the header template file, header.tpl, and ran it but it threw up a lot of errors.  I then went through it bit by bit and stripped it right down.  I could detail the whole process but that would be dull. In the end, the code that worked was this:</p>
<p><code>&lt;?php<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
$results = $this-&gt;model_catalog_category-&gt;getCategories();<br />
if ($results) {$output = '&lt;ul&gt;';}<br />
foreach ($results as $result) {<br />
$output .= '&lt;li&gt;';<br />
$new_path = $result['category_id'];<br />
$unrewritten = HTTP_SERVER.'index.php?route=product/category&amp;path='.$new_path;<br />
$rewritten =  $this-&gt;model_tool_seo_url-&gt;rewrite($unrewritten);<br />
$output .= '&lt;a href="'.str_replace('&amp;', '&amp;amp;', $rewritten).'"&gt;'.$result['name'].'&lt;/a&gt;';<br />
$output .= '&lt;/li&gt;';<br />
}<br />
if ($results) {$output .= '&lt;/ul&gt;';}<br />
echo $output;<br />
?&gt;<br />
</code></p>
<p>And that&#8217;s all you need. No extra modules or adding code to four or five files.  Just put the above code in your header and it will list your top-level categories. It works with both the default URL structure and with the SEO friendly URL option. If you want to create a navigation bar that also displays sub-categories, in drop-downs for example, you&#8217;ll probably have to do something different, but I&#8217;m happy with this solution.  It&#8217;s light, doesn&#8217;t affect the OpenCart source code, and I&#8217;m not a huge fan of drop-downs anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-list-categories-in-the-header-in-opencart/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>How to add an AJAX cart in the header in OpenCart</title>
		<link>http://craigmurray.me.uk/opencart-mods/how-to-add-an-ajax-cart-in-the-header-in-opencart/</link>
		<comments>http://craigmurray.me.uk/opencart-mods/how-to-add-an-ajax-cart-in-the-header-in-opencart/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 13:42:33 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[OpenCart Mods]]></category>

		<guid isPermaLink="false">http://craigmurray.me.uk/?p=94</guid>
		<description><![CDATA[I&#8217;ve started working on some templates for OpenCart.  Some of these require having a cart in the header area rather than in the left or right column. In this post I&#8217;ll tell you, step-by-step, how to do it in, what &#8230; <a href="http://craigmurray.me.uk/opencart-mods/how-to-add-an-ajax-cart-in-the-header-in-opencart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started working on some templates for OpenCart.  Some of these require having a cart in the header area rather than in the left or right column. In this post I&#8217;ll tell you, step-by-step, how to do it in, what I believe, is the best, most satisfactory way.<br />
<span id="more-94"></span></p>
<p>I&#8217;m not really a programmer, so I searched the OpenCart forums and found several ways of doing it.  However, they all involved editing the source code of OpenCart, and when I design a template I want it to be easy to install and uninstall and I don&#8217;t want to have to alter the source code of the CMS. Finally, after a lot of searching I found a post by peterban which was exactly what I was looking for.  You can read the post here: <a href="http://forum.opencart.com/viewtopic.php?f=21&amp;t=14764">http://forum.opencart.com/viewtopic.php?f=21&amp;t=14764</a></p>
<p>I made some slight alterations to peterban&#8217;s solution and it seems to work fine, so here&#8217;s what you do.</p>
<p>Basically, if you want to display a cart in your  header you can put the following in your header.tpl file:</p>
<p><code>&lt;div id="cart_in_header"&gt;<br />
&lt;?php<br />
$cart_number = $this-&gt;cart-&gt;countProducts();<br />
if ($cart_number == 1) {echo "1 item in shopping cart";}<br />
else {echo $cart_number." items in shopping cart";}<br />
echo"&lt;br /&gt;";<br />
echo "Total: ".$this-&gt;currency-&gt;format($this-&gt;cart-&gt;getTotal());<br />
?&gt;<br />
echo"&lt;br /&gt;";<br />
&lt;a href="index.php?route=checkout/cart"&gt;View Cart&lt;/a&gt; |<br />
&lt;a href="index.php?route=checkout/shipping"&gt;Checkout&lt;/a&gt;<br />
&lt;/div&gt;<br />
</code></p>
<p>If you are not using the AJAX add-to-cart function in OpenCart then that is all you need to do. You now have a basic cart in your header that functions perfectly. However, if you want to add the AJAX function to your cart then here&#8217;s what you need to do next.  It does involve editing the source code, but you are only adding an extra function to the source, not altering anything that already exists, which I can live with.</p>
<p>In catalog/controller/module/cart.php add the following at the bottom, before the final }:</p>
<p><code>public function minicart() {<br />
$this-&gt;language-&gt;load('module/cart');<br />
$this-&gt;load-&gt;model('tool/seo_url');<br />
if ($this-&gt;request-&gt;server['REQUEST_METHOD'] == 'POST') {<br />
if (isset($this-&gt;request-&gt;post['option'])) {<br />
$option = $this-&gt;request-&gt;post['option'];<br />
} else {<br />
$option = array();<br />
}<br />
$this-&gt;cart-&gt;add($this-&gt;request-&gt;post['product_id'], $this-&gt;request-&gt;post['quantity'], $option);<br />
unset($this-&gt;session-&gt;data['shipping_methods']);<br />
unset($this-&gt;session-&gt;data['shipping_method']);<br />
unset($this-&gt;session-&gt;data['payment_methods']);<br />
unset($this-&gt;session-&gt;data['payment_method']);<br />
}<br />
$cart_number = $this-&gt;cart-&gt;countProducts();<br />
if ($cart_number == 1) {$output = '1 item in shopping cart &lt;br /&gt;';<br />
} else {$output = $cart_number.' items in shopping cart &lt;br /&gt;';}<br />
$output .= 'Total: '.$this-&gt;currency-&gt;format($this-&gt;cart-&gt;getTotal()).'&lt;br /&gt;';<br />
$output .= '&lt;a href="index.php?route=checkout/cart"&gt;View Cart&lt;/a&gt; |<br />
&lt;a href="index.php?route=checkout/shipping"&gt;Checkout&lt;/a&gt;';<br />
$this-&gt;response-&gt;setOutput($output, $this-&gt;config-&gt;get('config_compression'));<br />
}</code></p>
<p>Now that you&#8217;ve done that, all that is left to do is call the function when the Add to Cart button is pressed.  You do that by adding the following javascript to your header.tpl file, just under the code for your basic cart.</p>
<p><code>&lt;script type="text/javascript"&gt;&lt;!--<br />
$(document).ready(function () {<br />
$('#add_to_cart').removeAttr('onclick');<br />
$('#add_to_cart').click(function () {<br />
$.ajax({<br />
type: 'post',<br />
url: 'index.php?route=module/cart/minicart',<br />
dataType: 'html',<br />
data: $('#product :input'),<br />
success: function (html) {<br />
$('#cart_in_header').html(html);<br />
},<br />
complete: function () {<br />
var image = $('#image').offset();<br />
var cart  = $('#cart_in_header').offset();<br />
$('#image').before('&lt;img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" /&gt;');<br />
params = {<br />
top : cart.top + 'px',<br />
left : cart.left + 'px',<br />
opacity : 0.0,<br />
width : $('#cart_in_header').width(),<br />
heigth : $('#cart_in_header').height()<br />
};<br />
$('#temp').animate(params, 'slow', false, function () {<br />
$('#temp').remove();<br />
});<br />
}<br />
});<br />
});<br />
});<br />
//--&gt;&lt;/script&gt;<br />
</code></p>
<p>And that is you sorted.  You now have a basic AJAX shopping cart in your header that doesn&#8217;t involve any real editing of the OpenCart source code.  A couple of points:</p>
<ol>
<li>This basic cart doesn&#8217;t work together with the cart module in the right or left column so you must uninstall the cart module in your admin panel.</li>
<li>You will probably need to give the cart_in_header div a width in your stylesheet in order to get that nice effect of the product shrinking as it glides towards the cart e.g. #cart_in_header {width: 150px;}.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://craigmurray.me.uk/opencart-mods/how-to-add-an-ajax-cart-in-the-header-in-opencart/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

