<?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>indexu.com &#187; category listing</title>
	<atom:link href="http://www.indexu.com/tag/category-listing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indexu.com</link>
	<description>developer blog</description>
	<lastBuildDate>Wed, 30 Jun 2010 05:06:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Show category listing as list of images</title>
		<link>http://www.indexu.com/show-category-listing-as-list-of-images/</link>
		<comments>http://www.indexu.com/show-category-listing-as-list-of-images/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 07:47:48 +0000</pubDate>
		<dc:creator>dody</dc:creator>
				<category><![CDATA[Templates]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[category listing]]></category>

		<guid isPermaLink="false">http://www.indexu.com/?p=38</guid>
		<description><![CDATA[In this tutorial I will show you how to create an alternative category listing in front page where the categories will be listed as a series of images. 1) Prepare the image files. Create a folder called &#8216;cat&#8216; in template folder. Then put the images files here. 2) Edit category image file for each categories [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.indexu.com/up/catlistingimage.png" alt="alternative category listing" /></p>
<p>In this tutorial I will show you how to create an alternative category listing in front page where the categories will be listed as a series of images. </p>
<p>1) Prepare the image files. Create a folder called &#8216;<code>cat</code>&#8216; in template folder. Then put the images files here.</p>
<p>2) Edit category image file for each categories with admin panel or phpmyadmin. Put the filename of image file you have prepared for each categories.</p>
<p><img src="http://www.indexu.com/up/catlistingimage2.png" alt="edit category image file" /></p>
<p>3) Edit <code>index.html</code>, add the following code where you want to put this category list.<br />
You can change <code>$item_per_row</code> value as you desire.</p>

<div class="wp_codebox"><table><tr id="p383"><td class="code" id="p38code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span>php<span style="color: #000000; font-weight: bold;">%&gt;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$dbConn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$indexu</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$item_per_row</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$img_path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$indexu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'site_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/themes/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$indexu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'active_theme'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/cat'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select name, image
            from idx_category
            where parent_id = '0'&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dbConn</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Execute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">RecordCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FetchRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">%</span> <span style="color: #000088;">$item_per_row</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;div class='cat_nl'&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> SEOReplace<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;div class='cat_item'&gt;&lt;a href='<span style="color: #006699; font-weight: bold;">$url</span>'&gt;
           &lt;img src='<span style="color: #006699; font-weight: bold;">$img_path</span>/<span style="color: #006699; font-weight: bold;">{$row['image']}</span>' title='<span style="color: #006699; font-weight: bold;">{$row['name']}</span>' alt='<span style="color: #006699; font-weight: bold;">{$row['name']}</span>' /&gt;&lt;/a&gt;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">%</span> <span style="color: #000088;">$item_per_row</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$i</span><span style="color: #339933;">==</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #339933;">/</span>php<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></td></tr></table></div>

<p>4) Add the following css classes into css file, usually <code>style.css</code></p>

<div class="wp_codebox"><table><tr id="p384"><td class="code" id="p38code4"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.cat_nl</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.cat_item</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>



<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://www.indexu.com/show-category-listing-as-list-of-images/&amp;n=Show+category+listing+as+list+of+images&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.indexu.com/show-category-listing-as-list-of-images/&amp;title=Show+category+listing+as+list+of+images" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.indexu.com/show-category-listing-as-list-of-images/&amp;t=Show+category+listing+as+list+of+images" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.indexu.com/show-category-listing-as-list-of-images/&amp;title=Show+category+listing+as+list+of+images" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://www.indexu.com/show-category-listing-as-list-of-images/" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Show+category+listing+as+list+of+images+-+http://b2l.me/3mqnf&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.indexu.com/show-category-listing-as-list-of-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

