<?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>Sud Web Design</title>
	<atom:link href="http://sudwebdesign.com/feed" rel="self" type="application/rss+xml" />
	<link>http://sudwebdesign.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 17 May 2012 08:12:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Refreshing a widget in Yii</title>
		<link>http://sudwebdesign.com/refreshing-a-widget-in-yii/843</link>
		<comments>http://sudwebdesign.com/refreshing-a-widget-in-yii/843#comments</comments>
		<pubDate>Thu, 17 May 2012 08:12:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[yii]]></category>
		<category><![CDATA[yii cart widget]]></category>
		<category><![CDATA[yii refresh widget]]></category>
		<category><![CDATA[yii shopping basket]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=843</guid>
		<description><![CDATA[Yesterday, I wrote an AJAX shopping basket widget which, as I&#8217;m sure you can imagine, I wanted to refresh when items are added or deleted. &#160;However, having written the code to display the widget it confused me for a while &#8230; <a href="http://sudwebdesign.com/refreshing-a-widget-in-yii/843">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-844 alignleft" title="Ajax shopping basket" src="http://sudwebdesign.com/wp-content/uploads/2012/05/ajax-shopping-baskets.jpg" alt="Ajax shopping basket" width="225" height="156" />Yesterday, I wrote an AJAX shopping basket widget which, as I&#8217;m sure you can imagine, I wanted to refresh when items are added or deleted. &nbsp;However, having written the code to display the widget it confused me for a while how I would update the widget through AJAX. &nbsp;How do you access the widget from a javascript front-end? &nbsp;You can&#8217;t have external methods that can be called externally, so how would I re-use the display code?</p>
<h2>The Solution</h2>
<p>I trawled the net archives for a short while and couldn&#8217;t find any way of calling a refresh on the widget directly. In fact, the answer I came up with is so simple that it should have seemed obvious straight away!</p>
<p>I added an action to my shopping basket controller which calls a view with just the widget embedded and nothing else. &nbsp;After all, the purpose of a widget is just to display it. &nbsp;</p>
<p>In that way, I call my new &#8220;refreshBasket&#8221; action using an ajax call. &nbsp;The returned data is the widget HTML which I inject back into the basket div.</p>
<p>In reality, this is included within the Javascript function that handles updates to the basket as follows:-</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Javascript"><div class="devcodeoverflow"><ol><li> <span style="color: #003366; font-weight: bold;">function</span> changeBasket<span style="color: #009900;">&#40;</span>vitem<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qty<span style="color: #339933;">=</span>vitem.<span style="color: #660066;">value</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #003366; font-weight: bold;">var</span> url<span style="color: #339933;">=</span>vitem.<span style="color: #660066;">attributes</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;?qty=&quot;</span><span style="color: #339933;">+</span>qty<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jQuery.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #3366CC;">'url'</span><span style="color: #339933;">:</span> url<span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #3366CC;">'success'</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;basketVisible<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#shopping-cart-items'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':visible'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#shopping-cart-wrapper&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>basketVisible<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;showBasket<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<h2>How it works</h2>
<p>The link calling this routine is embedded within the detailed cart. &nbsp;In one case this is using an input field so that users can change the quantity</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-32&quot;</span> url<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/basket/updateQty/32&quot;</span> <span style="color: #000066;">onchange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js:changeBasket(this);&quot;</span>&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>The URL for the update is created within Yii and then embedded as an HTM attribute. &nbsp;This URL is then extracted in the changeBasket routine with the line starting &#8220;url=&#8221;&nbsp;</p>
<p>This url is then used as the AJAX call.</p>
<p>On successful completion of the AJAX call, firstly see if the drop down detail of the basket was visible and store true/false.</p>
<p>Then inject the returned HTML back into the basket wrapper.</p>
<p>If the detailed basket was visible, then redisplay it.</p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/refreshing-a-widget-in-yii/843/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yii &#8211; Example of Creating a submenu widget</title>
		<link>http://sudwebdesign.com/yii-example-of-creating-a-submenu-widget/792</link>
		<comments>http://sudwebdesign.com/yii-example-of-creating-a-submenu-widget/792#comments</comments>
		<pubDate>Tue, 01 May 2012 12:16:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[yii]]></category>
		<category><![CDATA[yii cmenu]]></category>
		<category><![CDATA[yii dynamic submenu]]></category>
		<category><![CDATA[yii submenu]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=792</guid>
		<description><![CDATA[This is a continuation of two previous articles,&#160;How to make a dynamic Sub-menu&#160;and&#160;How to make a dynamic sub-menu – UPDATE, which show the mechanisms by which you can build a dynamic submenu system, populating the dropdowns from the relevant controller. &#8230; <a href="http://sudwebdesign.com/yii-example-of-creating-a-submenu-widget/792">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a continuation of two previous articles,&nbsp;<a href="http://sudwebdesign.com/yii-how-to-make-a-dynamic-sub-menu/376">How to make a dynamic Sub-menu</a>&nbsp;and&nbsp;<a title="Yii: How to make a dynamic sub-menu – UPDATE" href="http://sudwebdesign.com/yii-how-to-make-a-dynamic-sub-menu-update/386">How to make a dynamic sub-menu – UPDATE</a>, which show the mechanisms by which you can build a dynamic submenu system, populating the dropdowns from the relevant controller. &nbsp;For example; with a customer booking system, if you had a menu for customers and a menu for bookings, you may wish to control the customer drop down from the customer controller and the bookings dropdown from the bookings controller.</p>
<p>This post will bring these two previous posts into reality with an example layout view.</p>
<p>The first factor is that your main menu line will remain as you have already defined it, probably using a cMenu class.</p>
<p>Your submenu is defined as a DIV element immediately after your main menu container.</p>
<p>You can then manage the visual integration of these two elements using CSS.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li></li><li><span style="color: #000000; font-weight: bold;">&lt;?php</span></li><li><span style="color: #666666; font-style: italic;">// if controller name matches current controller then this must be the active menu</span></li><li><span style="color: #000000; font-weight: bold;">function</span> activeMenu<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$menuName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$activeMenu</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cid</span><span style="color: #339933;">==</span><span style="color: #000088;">$menuName</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'active'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$activeMenu</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li><li><span style="color: #000000; font-weight: bold;">?&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page&quot;</span>&gt;</span></li><li>&nbsp;</li><li>	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mainmenu&quot;</span>&gt;</span></li><li>		<span style="color: #000000; font-weight: bold;">&lt;?php</span>&nbsp;&nbsp;</li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$cid</span><span style="color: #339933;">=</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isGuest</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$menu</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/site/login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Register'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registrationUrl</span><span style="color: #339933;">,</span>&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>		&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$user</span><span style="color: #339933;">=</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #666666; font-style: italic;">//var_dump($user);</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">superuser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$menu</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Manage User'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'/user/admin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'List User'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'/user'</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$menu</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span></li><li>				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Subscription Details'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/user/profile'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'active'</span><span style="color: #339933;">=&gt;</span>activeMenu<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cid</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'profile'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> </li><li>				<span style="color: #009933; font-style: italic;">/** Other User menus **/</span></li><li>				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'label'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">t</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Logout'</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: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&gt;</span>Yii<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logoutUrl</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'itemOptions'</span><span style="color: #339933;">=&gt;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'right'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widget</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zii.widgets.CMenu'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'items'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$menu</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'activateItems'</span><span style="color: #339933;">=&gt;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">?&gt;</span></li><li>	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!-- mainmenu --&gt;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submenu&quot;</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widget</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SubMenu'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/yii-example-of-creating-a-submenu-widget/792/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Logging in Yii</title>
		<link>http://sudwebdesign.com/advanced-logging-in-yii/775</link>
		<comments>http://sudwebdesign.com/advanced-logging-in-yii/775#comments</comments>
		<pubDate>Tue, 24 Apr 2012 12:36:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[yii]]></category>
		<category><![CDATA[yii configuration]]></category>
		<category><![CDATA[yii debug]]></category>
		<category><![CDATA[yii logging]]></category>
		<category><![CDATA[yii trace]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=775</guid>
		<description><![CDATA[Here are some nice examples of using the logging facilities in Yii 'log'=&#62;array&#40; 'class'=&#62;'CLogRouter', 'routes'=&#62;array&#40;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;array&#40;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'class'=&#62;'CWebLogRoute',&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// you can include more levels separated by commas&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'levels'=&#62;'trace, info, error, warning, vardump',&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// categories are those you used in the call to Yii::trace&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'categories'=&#62;'*',&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// This is self-explanatory &#8230; <a href="http://sudwebdesign.com/advanced-logging-in-yii/775">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here are some nice examples of using the logging facilities in Yii</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li></li><li> <span style="color: #0000ff;">'log'</span><span style="color: #339933;">=&gt;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>			<span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'CLogRouter'</span><span style="color: #339933;">,</span></li><li>			<span style="color: #0000ff;">'routes'</span><span style="color: #339933;">=&gt;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'CWebLogRoute'</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #666666; font-style: italic;">// you can include more levels separated by commas</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'levels'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'trace, info, error, warning, vardump'</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #666666; font-style: italic;">// categories are those you used in the call to Yii::trace</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'categories'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'*'</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #666666; font-style: italic;">// This is self-explanatory right? but also works in Chrome!</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'showInFireBug'</span><span style="color: #339933;">=&gt;</span><span style="color: #009900; font-weight: bold;">true</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'CFileLogRoute'</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">'levels'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'trace, info, error, warning, vardump'</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #666666; font-style: italic;">/*&nbsp;&nbsp;array(</span></li><li><span style="color: #666666; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'class'=&gt;'CEmailLogRoute',</span></li><li><span style="color: #666666; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'levels'=&gt;'error, warning',</span></li><li><span style="color: #666666; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'emails'=&gt;'me@example.com',</span></li><li><span style="color: #666666; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ),*/</span></li><li>			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li>		<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>I use a function to create a trace log, defined in my base index.php as follows:-</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li></li><li><span style="color: #000000; font-weight: bold;">function</span> fb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span><span style="color: #000088;">$where</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'fb.somewhere'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$what</span><span style="color: #339933;">=</span><span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; Yii<span style="color: #339933;">::</span><span style="color: #004000;">trace</span><span style="color: #009900;">&#40;</span>CVarDumper<span style="color: #339933;">::</span><span style="color: #004000;">dumpAsString</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'trace'</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Yii<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'info'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'application'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>In this way, I just need to add &#8220;fb ($variable, &#8220;optional category or comment&#8221;);&#8221; in my code!</p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/advanced-logging-in-yii/775/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yii &#8211; simple email and mail merge</title>
		<link>http://sudwebdesign.com/yii-simple-email-and-mail-merge/416</link>
		<comments>http://sudwebdesign.com/yii-simple-email-and-mail-merge/416#comments</comments>
		<pubDate>Thu, 05 Apr 2012 10:43:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[send email yii]]></category>
		<category><![CDATA[yii]]></category>
		<category><![CDATA[yii email]]></category>
		<category><![CDATA[yii email plugin]]></category>
		<category><![CDATA[yii email system]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=416</guid>
		<description><![CDATA[I needed an email mechanism for a customer that was light and easy to configure. Yii extensions I tried several email extensions from the Yii website all of which I found overly complex to setup and use. &#160;I then remembered &#8230; <a href="http://sudwebdesign.com/yii-simple-email-and-mail-merge/416">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed an email mechanism for a customer that was light and easy to configure.</p>
<h2>Yii extensions</h2>
<p>I tried several email extensions from the Yii website all of which I found overly complex to setup and use. &nbsp;I then remembered that I had used a simple class on a PHP website a few years previously and went back to look at how easy it would be to lift out and use in my Yii application.</p>
<p>It turned out to be a very compact set of 3 classes, which were well documented in the code and easy to setup.</p>
<p>All you need to do is copy these three classes into your models directory and then you can use them within your code as any other Yii class:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPMailer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// defaults to using php &quot;mail()&quot;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>IsSendmail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #990000;">WordWrap</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>AddReplyTo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;someone@gmail.com&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetFrom<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;another@gmail.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Another Gmail address'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Subject&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>AltBody&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;To view the message, please use an HTML compatible email viewer!&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// optional, comment out and test</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Message sent to <span style="color: #006699; font-weight: bold;">$to</span>!&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>&nbsp;</p>
<p>Further resources:-</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>Software<span style="color: #339933;">:</span> PHPMailer <span style="color: #339933;">-</span> PHP email <span style="color: #000000; font-weight: bold;">class</span></li><li><span style="color: #339933;">|</span> Contact<span style="color: #339933;">:</span> via sourceforge<span style="color: #339933;">.</span>net support pages <span style="color: #009900;">&#40;</span>also www<span style="color: #339933;">.</span>worxware<span style="color: #339933;">.</span>com<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span></li><li><span style="color: #339933;">|</span> Info<span style="color: #339933;">:</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//phpmailer.sourceforge.net |</span></li><li><span style="color: #339933;">|</span> Support<span style="color: #339933;">:</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//sourceforge.net/projects/phpmailer/ |</span></li><li><span style="color: #339933;">|</span> <span style="color: #339933;">-------------------------------------------------------------------------</span> <span style="color: #339933;">|</span></li><li><span style="color: #339933;">|</span> Admin<span style="color: #339933;">:</span> Andy Prevost <span style="color: #009900;">&#40;</span>project admininistrator<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span></li><li><span style="color: #339933;">|</span> Authors<span style="color: #339933;">:</span> Andy Prevost <span style="color: #009900;">&#40;</span>codeworxtech<span style="color: #009900;">&#41;</span></li><li><span style="color: #339933;">|</span> <span style="color: #339933;">:</span> Marcus Bointon <span style="color: #009900;">&#40;</span>coolbru<span style="color: #009900;">&#41;</span></li><li><span style="color: #339933;">|</span> Founder<span style="color: #339933;">:</span> Brent R<span style="color: #339933;">.</span> Matzelle <span style="color: #009900;">&#40;</span>original founder<span style="color: #009900;">&#41;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/yii-simple-email-and-mail-merge/416/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP eCommerce by GetShopped is now fully integrated</title>
		<link>http://sudwebdesign.com/wordpress-ecommerce-plugin-by-getshopped-is-now-fully-integrated-with-wp/689</link>
		<comments>http://sudwebdesign.com/wordpress-ecommerce-plugin-by-getshopped-is-now-fully-integrated-with-wp/689#comments</comments>
		<pubDate>Thu, 29 Mar 2012 15:39:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[getshopped]]></category>
		<category><![CDATA[getshopped.org]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress eCommerce]]></category>
		<category><![CDATA[wp ecommerce]]></category>
		<category><![CDATA[wpec]]></category>
		<category><![CDATA[wpsc]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=689</guid>
		<description><![CDATA[WordPress 3.0 introduced the ability for plugin developers to build their own custom post types.  This means that the main data is held in the same table as your WordPress posts and pages and therefore means that other core wordpress &#8230; <a href="http://sudwebdesign.com/wordpress-ecommerce-plugin-by-getshopped-is-now-fully-integrated-with-wp/689">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.0 introduced the ability for plugin developers to build their own custom post types.  This means that the main data is held in the same table as your WordPress posts and pages and therefore means that other core wordpress functions and thus other plugins can see them.</p>
<p>In the case of an eCommerce system, this would mean that all your products are now held in the same table as your posts and pages.  One obvious advantage of this is that to search your site just became a whole lot  easier!</p>
<p>I&#8217;ve just finished a large upgrade to WP-eCommerce website using GetShopped&#8217;s latest 3.8 architecture with that integration into WordPress model  - <a href="http://rockwaterstudio.com"> see rockwaterstudio.com</a>.   Along with a cosmetic face-lift it makes the site far more concise, easier to navigate and also better for Search Engines (SEO).</p>
<h3>If you think your site could  do with a face lift, giving it a breath of fresh air and perhaps better search engine visibility, then <a title="Contact me" href="http://sudwebdesign.com/contact-me">drop me a line</a> or give me a call.</h3>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/wordpress-ecommerce-plugin-by-getshopped-is-now-fully-integrated-with-wp/689/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPEC &#8211; hacking the product URL to exclude categories</title>
		<link>http://sudwebdesign.com/wpec-hacking-the-product-url-to-exclude-categories/677</link>
		<comments>http://sudwebdesign.com/wpec-hacking-the-product-url-to-exclude-categories/677#comments</comments>
		<pubDate>Wed, 21 Mar 2012 10:45:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technical Ramblings]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp ecommerce]]></category>
		<category><![CDATA[wp-e-commerce]]></category>
		<category><![CDATA[wpec]]></category>
		<category><![CDATA[wpec categories url]]></category>
		<category><![CDATA[wpec product url]]></category>
		<category><![CDATA[wpsc]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=677</guid>
		<description><![CDATA[Preamble For several weeks now I have been on the holy grail, trawling through OLD wpsc/wpec documentation and scouring the interweb for the answer to the primary SEO criticism of WordPress eCommerce.  Even the latest 3.8.8 beta still does not &#8230; <a href="http://sudwebdesign.com/wpec-hacking-the-product-url-to-exclude-categories/677">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>For several weeks now I have been on the holy grail, trawling through OLD wpsc/wpec documentation and scouring the interweb for the answer to the primary SEO criticism of WordPress eCommerce.  Even the latest 3.8.8 beta still does not address this very fundamental issue.</p>
<p>The problems lies in the organisation of products within categories.  The very structure of wpec encourages you to show the same product in more than one category.  having done so, you will then find that that one product has multiple URLs (http://your-store.com/category1/product-title and http://your-store.com/category2/product-title).</p>
<p>You may think that is a great idea, that you now have twice as many products as you had and Google is bound to love it! WRONG!</p>
<p>Google does not like duplicate content.  you now have the same page displaying in two different places and Google (and Bing) will not look kindly on that.</p>
<p>Moreover, if you ever want to move that product from category1 to category3 you now have a dead link that both search engines and peoples&#8217; bookmarks might be pointing to.  Your product no longer exists at http://your-store.com/category1/product-title</p>
<p>The way it should work is that all you products should appear at something like: http://your-store.com/products/product-title.</p>
<p>Then  whether you are looking at the product in category1 or category2 &#8211; they point to the same URL.  If you then move the product from category1 to category3, the URL of the product does not change!</p>
<p>Firstly, I tried using .htaccess redirects which you can read about in my previous post &#8220;<a title="WPEC Products in multiple categories cause SEO duplicates" href="http://sudwebdesign.com/wordpress-ecommerce-wpec-products-in-multiple-categories-cause-seo-duplicates/606">WPEC Products in multiple categories cause SEO duplicates</a>&#8220;</p>
<h2>The Hack</h2>
<p>So, the hack to core wpec/wpsc files to get this to work is really simple but boy!, did it take me a long time to find it.</p>
<p>You will find a file called functions.php in plugins/wp-e-commerce/wpsc-core</p>
<p>Change line 1241</p>
<p>from: $our_permalink_structure = $wpsc_page_titles['products'] . &#8220;/%wpsc_product_category%/%postname%/&#8221;;</p>
<p>to:  $our_permalink_structure = $wpsc_page_titles['products'] . &#8220;/%postname%/&#8221;;</p>
<p><strong>That is it!</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/wpec-hacking-the-product-url-to-exclude-categories/677/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPEC Products in multiple categories cause SEO duplicates</title>
		<link>http://sudwebdesign.com/wordpress-ecommerce-wpec-products-in-multiple-categories-cause-seo-duplicates/606</link>
		<comments>http://sudwebdesign.com/wordpress-ecommerce-wpec-products-in-multiple-categories-cause-seo-duplicates/606#comments</comments>
		<pubDate>Wed, 21 Mar 2012 10:25:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[getshopped]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpec]]></category>
		<category><![CDATA[wpec duplicate categories]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=606</guid>
		<description><![CDATA[Overview Whilst trying to customise a bought in template and digging around in a customer&#8217;s WordPress eCommerce system, it occurred to me that there is a fundamental design flaw in the system from two perspectives.  Both have to do with the way that Products are assigned to &#8230; <a href="http://sudwebdesign.com/wordpress-ecommerce-wpec-products-in-multiple-categories-cause-seo-duplicates/606">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>Whilst trying to customise a bought in template and digging around in a customer&#8217;s WordPress eCommerce system, it occurred to me that there is a fundamental design flaw in the system from two perspectives.  Both have to do with the way that <em>Products</em> are assigned to <em>Categories</em> and how you navigate from a <em>Category</em> to a <em>Product</em>.</p>
<h2>Permanent Categories</h2>
<p>If my understanding is right, which it could easily not be, then when you assign a Product to a Category this must be a permanent assignment. Why &#8211; If you ever remove it, you may end up with an orphaned URL which Google and the rest of the world might have book-marked.</p>
<p>For example; say we are a book store and have divided our store into three basic categories; fiction, non-fiction and General Interest.</p>
<p>We receive a new book eg: (&#8220;Zen and the Art of Motorcycle Maintenance&#8221;) and decide to assign it to the <em>non-fiction</em> category.  Depending how we have setup our Permalinks we might end up with a URL to this book as <span style="text-decoration: underline;">http://www.ourbookstore.com/non-fiction/Zen-and-the-Art-of-Motorcycle-Maintenance</span></p>
<p>However, the next day we decide that we shouldn&#8217;t have put it in non-fiction but general interest.  We therefore go into WPEC and change the category assignment from <em>non-fiction</em> to <em>general-interest</em>.  Great!  It all works and now we can see the book at <span style="text-decoration: underline;">http://www.ourbookstore.com/general-interest/Zen-and-the-Art-of-Motorcycle-Maintenance</span></p>
<p>The day after that, we are browsing through our server logs (as we all do) and notice that someone is still trying to access the old URL of <span style="text-decoration: underline;">http://www.ourbookstore.com/non-fiction/Zen-and-the-Art-of-Motorcycle-Maintenance</span>.   Further  investigation shows that during the first night Google spidered our site and caught the non-fiction URL and has not corrected it.</p>
<h2>SEO and duplicate content</h2>
<p>The second reason this is a fundamental flaw is from an SEO perspective.  If I assign a product to more than one category (eg: non-fiction and general-interest) then this book will have two URLs.  Whereas, you might think that is no bad thing, in fact, maybe even a good thing, Google won&#8217;t like it.  It is one of Google&#8217;s objectives to cut down on duplication on the internet.  It is even believed that they may <strong>penalise</strong> a site that is consistently producing duplicate content.</p>
<p>If you have hundreds or even thousands of products and each product is in 2 or more categories, then you could be penalised by Google.  Maybe you already have been!</p>
<h2>Solution</h2>
<p>Ideally, WPEC shouldn&#8217;t reference the product as part of the category.  The book should always be stored at, for example, <span style="text-decoration: underline;">http://www.ourbookstore.com/books/Zen-and-the-Art-of-Motorcycle-Maintenance</span>.  In this way, if you move the product from A to B, the product URL itself doesn&#8217;t move.</p>
<p>Well, I&#8217;m not a WordPress guru.  I can find my way around OK but navigating the multiple layers of WPEC as well &#8230;</p>
<p>In the meantime, it dawned on me the other evening whilst walking the dogs, that we could easily correct this URL by using a technique called &#8220;URL rewriting&#8221;. By setting up some simple rules we could re-write the offending URLs so that it always appeared as if the product had a permanent URL independent of category.</p>
<p>Step 1; we need to setup a catch all Category.  In this case, as in my example just above, I&#8217;m going to call it <strong>books</strong>.  Now, every product I add to the system, I assign to the category <strong>books</strong> as well as to fiction, non-fiction or general-interest.  So, if I navigated to <span style="text-decoration: underline;">http://www.ourbookstore.com/books/</span> I would see every book in the store.</p>
<p>Step 2; we define a rule to redirect any category/product URL which isn&#8217;t  books/book-title to books/book-title.</p>
<p>How do we setup a rule, you may well ask.  The answer is, it depends on your experience and the size of your store.  If you are not a nerdy type and you maintain your own WPEC store, then you can use a &#8220;redirect&#8221; plugin (like this one <a href="http://urbangiraffe.com/plugins/redirection/">http://urbangiraffe.com/plugins/redirection/</a>) or if you are a serious techy you can use htaccess.</p>
<p>So the logic of the rule is</p>
<p>1. If the URL does not contain my &#8220;catch all&#8221; category (eg: &#8220;books&#8221;) then</p>
<p>2. and the URL contains a category <strong>followed by something else</strong> then</p>
<p>3. re-write the URL to my new catch-all category (<strong>books</strong>) plus whatever followed that part of the URL</p>
<p>Lets have a look at some examples;</p>
<p>/non-fiction/zen-and-the-art -&gt; /books/zen-and-the-art</p>
<p>/non-fiction/zen-and-the-art/search=some-text -&gt; /books/zen-and-the-art/search=some-text</p>
<p>/non-fiction -&gt; doesn&#8217;t get re-written as there is nothing after the category name</p>
<p>/something-else -&gt; doesn&#8217;t get re-written because it isn&#8217;t a category</p>
<p>To make this easier, WPEC preceeds all its&#8217; URLs with a /p/ showing that this is a URL to a product or category/product</p>
<p>Therefore we can use this &#8220;/p/&#8221; to distinguish WPEC urls from other wordpress urls.</p>
<p>With htaccess we can achieve all of this with just 2 lines of code as follows:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> ^<span style="color: #009900;">&#40;</span>?<span style="color: #339933;">!/</span>p<span style="color: #339933;">/</span>books<span style="color: #009900;">&#41;</span><span style="color: #339933;">.*</span>$</li><li><span style="color: #666666; font-style: italic;"># this RewriteCond is needed to stop a rewrite loop</span></li><li><span style="color: #666666; font-style: italic;"># In other words, ignore any URL which already contains /p/books</span></li><li>RewriteRule ^p<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.+</span>?<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ <span style="color: #339933;">/</span>p<span style="color: #339933;">/</span>books<span style="color: #339933;">/</span>$<span style="color:#800080;">2</span> <span style="color: #009900;">&#91;</span>R<span style="color: #339933;">=</span><span style="color: #cc66cc;">301</span><span style="color: #339933;">,</span>L<span style="color: #009900;">&#93;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>On further testing, I found that there was a huge limitation in this approach.</p>
<p>Whereas, it will work perfectly if you have a flat category structure, as soon as you have nested categories, you can never tell whether the last branch of the URL is a product title or a category title and therefore you cannot write a rule for it &#8230;</p>
<p><strong>I did finally find a way of hacking the core WPSC product permalink function to do this and now I have my products all pointing to http://www.mystore.com/p/product-permalink &#8230; you can find a short post about it <a href="/wpec-hacking-the-product-url-to-exclude-categories">here</a>, but you will need to be happy editing core wordpress files to do this. If not, you can always ask me to do it for a small charge</strong></p>
<p>Happy categorising!</p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/wordpress-ecommerce-wpec-products-in-multiple-categories-cause-seo-duplicates/606/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yii – How to customize a CGridView CbuttonColumn &#8211; part 2</title>
		<link>http://sudwebdesign.com/yii-how-to-customize-a-cgridview-cbuttoncolumn-part-2/590</link>
		<comments>http://sudwebdesign.com/yii-how-to-customize-a-cgridview-cbuttoncolumn-part-2/590#comments</comments>
		<pubDate>Tue, 28 Feb 2012 10:27:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[cbuttoncolumn]]></category>
		<category><![CDATA[cgridview]]></category>
		<category><![CDATA[customize cgridview]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=590</guid>
		<description><![CDATA[Part 2 (see part 1 here) array&#40; 'class'=&#38;gt;'CButtonColumn', 'template'=&#38;gt;'{update}{add}{delete}', Always set the class to CButtonColumn. The &#8216;template&#8217; option enables you to name your buttons as you wish. Yii understands the basic crud names of &#8216;update&#8217;, &#8216;view&#8217; and &#8216;delete&#8217; but you &#8230; <a href="http://sudwebdesign.com/yii-how-to-customize-a-cgridview-cbuttoncolumn-part-2/590">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Part 2</h2>
<p><a title="Yii – How to customize a CGridView CbuttonColumn" href="http://sudwebdesign.com/yii-how-to-customize-a-cgridview-cbuttoncolumn/431">(see part 1 here)</a><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>		<span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'CButtonColumn'</span><span style="color: #339933;">,</span></li><li>		<span style="color: #0000ff;">'template'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'{update}{add}{delete}'</span><span style="color: #339933;">,</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
Always set the class to CButtonColumn.</p>
<p>The &#8216;template&#8217; option enables you to name your buttons as you wish. Yii understands the basic crud names of &#8216;update&#8217;, &#8216;view&#8217; and &#8216;delete&#8217; but you can specify custom names as you wish as I have here with &#8216;add&#8217;.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #0000ff;">'buttons'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>	<span style="color: #0000ff;">'update'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span></li><li>		<span style="color: #0000ff;">'url'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'$this-&amp;gt;grid-&amp;gt;controller-&amp;gt;createUrl(&quot;/Extras/update&quot;, array(&quot;id&quot;=&amp;gt;$data-&amp;gt;id,&quot;asDialog&quot;=&amp;gt;1,&quot;gridId&quot;=&amp;gt;$this-&amp;gt;grid-&amp;gt;id))'</span><span style="color: #339933;">,</span></li><li>		<span style="color: #0000ff;">'click'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'function(){$(&quot;#cru-frame&quot;).attr(&quot;src&quot;,$(this).attr(&quot;href&quot;)); $(&quot;#cru-dialog&quot;).dialog(&quot;open&quot;);&nbsp;&nbsp;return false;}'</span><span style="color: #339933;">,</span></li><li>		<span style="color: #0000ff;">'visible'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">'($data-&amp;gt;id===null)?false:true;'</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
The &#8216;buttons&#8217; option then gives details about each button using the options:-</p>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>url </td>
<td>the url which is called</td>
</tr>
<tr>
<td>click</td>
<td>javascript which is executed with the onClick event</td>
</tr>
<tr>
<td>visible</td>
<td>conditions under which this button is visible, perhaps using isAdmin() to check superuser status</td>
</tr>
<tr>
<td>label</td>
<td>the label that is used if no image is specified</td>
</tr>
<tr>
<td>imageURL</td>
<td>the url of the icon image for this button</td>
</tr>
<tr>
<td>options</td>
<td>array of HTML options (eg: &#8216;class&#8217;=&gt;&#8217;gridButton&#8217;, &#8216;width&#8217;=&gt;&#8217;16px&#8217;)</td>
</tr>
</table>
<h2></h2>
<p>In my code I specified</p>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>url=&gt;&#8217;$this-&gt;grid-&gt;controller-&gt;createUrl(&#8220;/Extras/update&#8221;, array(&#8220;id&#8221;=&gt;$data-&gt;id,&#8221;asDialog&#8221;=&gt;1,&#8221;gridId&#8221;=&gt;$this-&gt;grid-&gt;id))&#8217;</td>
</tr>
</table>
<h2></h2>
<p>This calls <em>createUrl</em> to generate a URL with parameters for <strong>id</strong>, <strong>asDialog</strong> and <strong>gridId</strong> which results in a GET style url such as</p>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>http://myserver.net/extras/update/56?asDialog=1&amp;gridID=extras-grid</td>
</tr>
</table>
<h2></h2>
<p>I then specified an onClick function which generates a javascript function.  In an admin backend, where I do NOT have the general public, I find it much quicker and easier using iframes to serve poop-up dialogs than embedded AJAX functions.  I find you get less conflicts with jQuery libraries etc.  You can find the original article by <a href="http://www.yiiframework.com/user/6785/">joblo </a>on the <a href="http://www.yiiframework.com/wiki/263/cgridview-update-create-records-in-a-cjuidialog/">Yii wiki</a></p>
<h2></h2>
<p>In summary, this javascript sets the <em>src</em> attribute of an embedded iframe object</p>
<h2></h2>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>&#8216;function(){$(&#8220;#cru-frame&#8221;).attr(&#8220;src&#8221;,$(this).attr(&#8220;href&#8221;));</td>
</tr>
</table>
<h2></h2>
<p>Then you set the object to visible</p>
<h2></h2>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>$(&#8220;#cru-dialog&#8221;).dialog(&#8220;open&#8221;);</td>
</tr>
</table>
<h2></h2>
<p>Always return false to avoid any javascript failures.</p>
<h2></h2>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>return false;}&#8217;,</td>
</tr>
</table>
<h2></h2>
<p>This means that the iframe object can reference a controller action which is independant of your current page.  This makes testing far easier as you can easily grab the URL and open another browser window to test this call.  In the Controller Action being called, you can use the asDialog parameter to check whether this action is being called through an iframe and use a very basic layout to render this view.</p>
<h2></h2>
<p>Also, in the Controller Action, you embed the javascript code to close the iframe when complete.  At the same time, you can inject any returned results into you parent frame. See this post for more details on this&#8230;</p>
<p>Lastly, I set the <em>visible</em> option to true or false depending on a value within the grid.  This particular example displays all the options you can buy with this holiday and whether the customer has selected them or not.  Therefore, using the id of the linking table as an indication of whether this item has been created or not enables or disables the &#8216;Add&#8217; button</p>
<table style="border-spacing: 5px; margin-left: 20px; background: #666666; border: 1px solid #BEBEBE;">
<tr>
<td>&#8216;visible&#8217;=&gt;&#8217;($data-&gt;id===null)?true:false;&#8217;</td>
</tr>
</table>
<h2></h2>
<p>Further reading:-</p>
<p><a href="http://www.yiiframework.com/wiki/106/using-cbuttoncolumn-to-customize-buttons-in-cgridview/">http://www.yiiframework.com/wiki/106/using-cbuttoncolumn-to-customize-buttons-in-cgridview/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/yii-how-to-customize-a-cgridview-cbuttoncolumn-part-2/590/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding an additional column as part of CDbCriteria</title>
		<link>http://sudwebdesign.com/adding-an-additional-column-as-part-of-cdbcriteria/586</link>
		<comments>http://sudwebdesign.com/adding-an-additional-column-as-part-of-cdbcriteria/586#comments</comments>
		<pubDate>Thu, 23 Feb 2012 13:18:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[CDBcriteria]]></category>
		<category><![CDATA[cdbcriteria additional columns]]></category>
		<category><![CDATA[yii]]></category>
		<category><![CDATA[yii additional columns]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=586</guid>
		<description><![CDATA[This was a tough one today and I found the solution in a number of places, but this one was the most helpful. Problem I&#8217;ve got an Property Rental application which also holds availability by dates for each property.  If &#8230; <a href="http://sudwebdesign.com/adding-an-additional-column-as-part-of-cdbcriteria/586">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This was a tough one today and I found the solution in a number of places, but<a href="http://www.yiiframework.com/forum/index.php/topic/13248-how-to-get-the-value-of-a-explicitly-selected-column-of-a-cdbcriteria/"> this one</a> was the most helpful.</p>
<h2>Problem</h2>
<p>I&#8217;ve got an Property Rental application which also holds availability by dates for each property.  If you want to search for properties that available (or have <strong>some</strong> availability) between two dates, I wanted to add a column to the gridview which indicated this.</p>
<h2>Solution</h2>
<p>I already use additional attributes in my models quite often.  they are so useful for storing additional values or transformations of existing values.  This is the route that I found, thanks to <em><a title="External link" href="http://dhluther.lutherweb.com/" rel="nofollow">Dana Luther &#8211; Web Design &amp; Development</a> </em>on the Yii forums.</p>
<p>Now, my search function in my model is already pretty complex with some INNER joins and some OUTER joins depending on whether various fields are selected in the Advanced Search form on the CGridview.</p>
<p>However, a simple change to some existing code was all it needed.</p>
<p>My existing code was something like this:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from_date</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to_date</span><span style="color: #009900;">&#41;</span>&nbsp;&nbsp;<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$ds</span><span style="color: #339933;">=</span>CDateTimeParser<span style="color: #339933;">::</span><span style="color: #004000;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from_date</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'dd/MM/yyyy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$from</span><span style="color: #339933;">=</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y/m/d'</span><span style="color: #339933;">,</span><span style="color: #000088;">$ds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$ds</span><span style="color: #339933;">=</span>CDateTimeParser<span style="color: #339933;">::</span><span style="color: #004000;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to_date</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'dd/MM/yyyy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$to</span><span style="color: #339933;">=</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y/m/d'</span><span style="color: #339933;">,</span><span style="color: #000088;">$ds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot; inner JOIN (SELECT DISTINCT property_id from availability WHERE available_dt BETWEEN '<span style="color: #006699; font-weight: bold;">$from</span>' AND '<span style="color: #006699; font-weight: bold;">$to</span>' AND availability='A') as A ON A.property_id=t.id&quot;</span> <span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li><li><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$criteria</span><span style="color: #339933;">-&gt;</span><span style="color: #990000;">join</span><span style="color: #339933;">=</span><span style="color: #000088;">$sql</span><span style="color: #339933;">;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>And a simple change to this as follows:-</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$sql</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot; INNER JOIN (SELECT a.property_id, COUNT(*) AS FreeDays FROM availability a WHERE (a.available_dt BETWEEN '<span style="color: #006699; font-weight: bold;">$from</span>' AND '<span style="color: #006699; font-weight: bold;">$to</span>' ) AND a.availability='A' GROUP BY a.property_id having count(*)&gt;1) as p3 ON p3.property_id=t.id&quot;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000088;">$criteria</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;t.*, p3.FreeDays as freedays&quot;</span><span style="color: #339933;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Plus define the public variable at the top of the model &#8220;Public $freedays;&#8221;</p>
<p>The next challenge is how to convert this into a parametrised query and then merge it with the existing CDbcriteria &#8230;. any ideas?</p>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/adding-an-additional-column-as-part-of-cdbcriteria/586/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the width of a filter column in CGridview</title>
		<link>http://sudwebdesign.com/changing-the-width-of-a-filter-column-in-cgridview/573</link>
		<comments>http://sudwebdesign.com/changing-the-width-of-a-filter-column-in-cgridview/573#comments</comments>
		<pubDate>Tue, 21 Feb 2012 10:07:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[cgridview]]></category>
		<category><![CDATA[cgridview column]]></category>
		<category><![CDATA[cgridview column width]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://sudwebdesign.com/?p=573</guid>
		<description><![CDATA[I recently spent an hour or so trying to reduce the width of columns in a CGridView. As I was trying to squash the grid into a narrow space, I wanted some columns to be narrower than others. I tried &#8230; <a href="http://sudwebdesign.com/changing-the-width-of-a-filter-column-in-cgridview/573">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently spent an hour or so trying to reduce the width of columns in a CGridView. As I was trying to squash the grid into a narrow space, I wanted some columns to be narrower than others.</p>
<p>I tried setting the headerHtmlOptions and the HtmlOptions and I could see these coming through in the HTML but found that it was the width of the input boxes in the filter row that was throwing out width of the column.</p>
<p>I finally found a solution that works (for me). I know this is a bit of a hack but it works!</p>
<p>I ended up using attribute names in CSS to determine the max-width of the input boxes as follows:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>input<span style="color: #009900;">&#91;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Properties[ref]&quot;</span><span style="color: #009900;">&#93;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;max<span style="color: #339933;">-</span>width<span style="color: #339933;">:</span> 55px<span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
It doesn&#8217;t seem quite the right way to do it, but it works. I would be interested if anyone has found a better way &#8230;</p>
<div id="attachment_574" class="wp-caption alignleft" style="width: 735px"><a href="http://sudwebdesign.com/wp-content/uploads/2012/02/gridview-column_width.png"><img class=" wp-image-574  " title="gridview-column_width" src="http://sudwebdesign.com/wp-content/uploads/2012/02/gridview-column_width.png" alt="" width="725" height="150" /></a>
<p class="wp-caption-text">Setting the width of columns in a CGridView</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://sudwebdesign.com/changing-the-width-of-a-filter-column-in-cgridview/573/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

