<?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>K. Aning&#039;s Web Log &#187; Zend</title>
	<atom:link href="http://blog.kaning.co.uk/archives/category/php/zend/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kaning.co.uk</link>
	<description>Web development for the inexperienced and mildly skilled</description>
	<lastBuildDate>Mon, 31 Oct 2011 10:20:16 +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>A note on Zend Pagination</title>
		<link>http://blog.kaning.co.uk/archives/246</link>
		<comments>http://blog.kaning.co.uk/archives/246#comments</comments>
		<pubDate>Tue, 07 Sep 2010 13:52:40 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend_Paginator]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=246</guid>
		<description><![CDATA[Having gone round in so many circles I finally found out that when useing Zend Pagination and the current route you are using has more than one dynamic variable i.e $router-&#62;addRoute( 'listingswithpage', new Zend_Controller_Router_Route( '/listing/:type/:page', array('controller' =&#62; 'listing', 'action' =&#62; &#8230; <a href="http://blog.kaning.co.uk/archives/246">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Having gone round in so many circles I finally found out that when useing Zend Pagination and the current route you are using has more than one dynamic variable i.e</p>
<pre class="brush:php">$router-&gt;addRoute(
                'listingswithpage',
                new Zend_Controller_Router_Route(
                        '/listing/:type/:page',
                        array('controller' =&gt; 'listing',
                            'action' =&gt; 'index')
                )
        );</pre>
<p>Your pagination view helper gets a bit thrown if you go by the documentation. The first thing you need to do is find a way to specify the first page initially. I went with specifying my first page in my route definition so it looked something like this</p>
<pre class="brush:php">$router-&gt;addRoute(
                'listingswithpage',
                new Zend_Controller_Router_Route(
                        '/listing/:type/:page',
                        array('controller' =&gt; 'listing',
                            'action' =&gt; 'index',
                            'page' =&gt; 1)
                )
        );</pre>
<p>And that worked. Failing that you have to figure out a way to pass the complete URL path to you pagination view which might be something like &#8220;controls.phtml&#8221; or &#8220;pagination.phtml&#8221;. and constructing the url properly there.</p>
<p>I will perhaps post a more detailed description of what this means but leave a comment if you are impatient and I will try and respond when I get a moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/246/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mod_Rewrite and Zend Framework 1.10.x and Ubuntu</title>
		<link>http://blog.kaning.co.uk/archives/242</link>
		<comments>http://blog.kaning.co.uk/archives/242#comments</comments>
		<pubDate>Mon, 06 Sep 2010 21:22:35 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=242</guid>
		<description><![CDATA[So all the tutorials on configuring your development server to run Zend Framework successfully say that you need to enable mod_rewrite in apache2 so that .htaccess and Zend_Router* works well. What they all say is to make sure it&#8217;s loaded &#8230; <a href="http://blog.kaning.co.uk/archives/242">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So all the tutorials on configuring your development server to run Zend Framework successfully say that you need to enable mod_rewrite in apache2 so that .htaccess and Zend_Router* works well.</p>
<p>What they all say is to make sure it&#8217;s loaded and enabled. I will raise my hand and say it wasn&#8217;t that easy for me to find because Ubuntu lays out Apache2 a little differently from say Fedora. First of all in the /etc/apache2 folder there are a few folders to take note of.</p>
<p>sites-enabled and mods-enabled actually tell you what has been enabled or not and not an uncommented list in some httpd.conf file. Basically the folders in there have symbolic links that come from sites-available and mods-available. This perhaps is a better idea as you can add new mods and not have to recompile apache or whatever.</p>
<p>I digress, to enable mod_rewrite in apache2 in Ubuntu 10.04.1 you need to create a symbolic link from mods-available to mods-enabled to do this you can either use the command:</p>
<pre class="brush:shell">sudo ln -s /etc/mods-available/rewrite.load /etc/mods-enabled/rewrite.load</pre>
<p>or if you prefer GUIs you have to run nautilus as root so you can try</p>
<pre class="brush:shell">sudo nautilus</pre>
<p>and navigate to &#8220;/etc/mods-available&#8221;, right-click on rewrite.load and select &#8220;make link&#8221; and the cut the new file created called &#8220;link to rewrite.load&#8221; paste it in mods-enabled and rename it to &#8220;rewrite.load &#8221;</p>
<p>Now all you need to do is restart your web server and you&#8217;re all set to reroute anyhow you want.</p>
<pre class="brush:shell">sudo /etc/init.d/apache2 restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/242/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Image Manipulation with Zend</title>
		<link>http://blog.kaning.co.uk/archives/233</link>
		<comments>http://blog.kaning.co.uk/archives/233#comments</comments>
		<pubDate>Sun, 15 Aug 2010 12:20:33 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=233</guid>
		<description><![CDATA[I had been on the prowl for an MVC approach to image manipulation. Especially a method that did it the Zend way. In the forums and documentation for the framework the developers didn&#8217;t see a real need to implement a &#8230; <a href="http://blog.kaning.co.uk/archives/233">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had been on the prowl for an MVC approach to image manipulation. Especially a method that did it the Zend way. In the forums and documentation for the framework the <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Image+Proposal+-+Davey+Shafik">developers didn&#8217;t see a real need to implement</a> a &#8220;Zend_Image&#8221; class in the libraries as this was already available through the PHP GD and Imagick hooks.</p>
<p>Some of us however did and there are a <a href="http://www.ajaxray.com/blog/2008/09/12/image-manipulation-in-zend-framework-with-php-thumbnailer-class-v20/" target="_blank">few tutorials</a> on how to incorporate the <a href="http://www.gen-x-design.com/projects/php-thumbnailer-class/" target="_blank">PHPThumb library</a> into Zend. I have used the PHPThumb Library on the <a href="http://mokocharlie.com" target="_blank">mokocharlie.com</a> project and found it I however stumbled on a much simpler way of doing this that feels more native to the framework Zend_Image is that implementation hidden <a href="http://code.google.com/p/zend-image/" target="_blank">somewhere on the code.google.com</a> hosting servers.</p>
<pre class="brush:php">$image = new Zend_Image( APPLICATION_PATH.'/../public/media/images/large/'.$filename,
   new Zend_Image_Driver_Gd());
   $transform = new Zend_Image_Transform($image);
   if($image-&gt;getWidth() &gt; $image-&gt;getHeight()){
       $transform-&gt;fitToWidth(295)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/medium/'.$filename);
       $transform-&gt;fitToWidth(147)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/small/'.$filename);
       $transform-&gt;center()-&gt;middle()-&gt;crop(74, 74)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/tiny/'.$filename);
   }else{
       $transform-&gt;fitToHeight(300)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/medium/'.$filename);
       $transform-&gt;fitToWidth(147)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/small/'.$filename);
       $transform-&gt;center()-&gt;middle()-&gt;crop(74, 74)
       -&gt;save(APPLICATION_PATH.'/../public/media/images/tiny/'.$filename);
   }</pre>
<p>The above is my implementation of it as I create three versions of an uploaded image.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/233/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Full Text Indexing with Zend_Search_Lucene</title>
		<link>http://blog.kaning.co.uk/archives/231</link>
		<comments>http://blog.kaning.co.uk/archives/231#comments</comments>
		<pubDate>Fri, 30 Jul 2010 09:54:39 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Lucene]]></category>
		<category><![CDATA[Zend_Search_Lucene]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=231</guid>
		<description><![CDATA[To provide a robust search facility for content you have stored on a MySQL database, you may be thinking of using MySQLs builting full text indexing facility. This comes with the MyISAM storage engine and can be slightly limiting especially &#8230; <a href="http://blog.kaning.co.uk/archives/231">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To provide a robust search facility for content you have stored on a MySQL database, you may be thinking of using MySQLs builting full text indexing facility. This comes with the MyISAM storage engine and can be slightly limiting especially if you would like to use foreign keys and such. So queries such has the following:</p>
<pre class="brush:sql"> "SELECT *, MATCH (page_content, page_title) AGAINST
(:keywords IN BOOLEAN MODE) AS relevance
FROM pages WHERE MATCH (page_content, page_title) AGAINST
(:keywords2 IN BOOLEAN MODE) ORDER BY relevance DESC";</pre>
<p>may not work for you although this may be how you want to go.</p>
<p>The best way I have found is to leave the indexing to another service in general. Enter Zend_Search_Lucene, i believe this is a PHP port of the Apache Lucene project written in Java&#8230;.</p>
<p>So basically we start by creating our index and document, personally i like to remove my personal classes and all that from the Zend Application as often as I can that way it&#8217;s mostly untainted and I can then use the same Zend Application with multiple custom code bases, enough on that already. However you chose to go you need a version of the following:</p>
<pre class="brush:php">class My_SearchService {

    protected
    $indexPath,
    $pageService,
    $pageIndexPath,
    $newsIndexPath,
    $document,
    $pageIndex;

    public function setIndexPath($indexPath) {
        $this-&gt;indexPath = $indexPath;
    }

    public function __construct($indexPath = NULL) {
        if (is_null($indexPath)) {
            $indexPath = APPLICATION_PATH . '/indexes/';
        }
        $this-&gt;setIndexPath($indexPath);
        $this-&gt;pageIndexPath = $this-&gt;indexPath . 'pageindex';
        $this-&gt;newsindexPath = $this-&gt;indexPath . 'newsindex';
        $this-&gt;pageService = new My_PageService();
    }

    public function createPageIndex() {
        $this-&gt;pageIndex = Zend_Search_Lucene::create($this-&gt;pageIndexPath);
// this is a simple Zend_Db_Table object returning data from my database
        $pages = $this-&gt;pageService-&gt;getAllPages()-&gt;toArray();

        foreach ($pages as $page) {
            $this-&gt;pageIndex
-&gt;addDocument(new My_Controller_Plugin_PageIndexer($page));
        }

        // commit index
        $this-&gt;pageIndex-&gt;commit();
    }

}</pre>
<p>This is assuming you have a folder structure that looks a bit like</p>
<p>/applications<br />
&#8211;/everything else here<br />
/library<br />
&#8211;/My<br />
&#8211;/PageService.php<br />
&#8212;&#8211;/Controller<br />
&#8212;&#8212;&#8212;-/Plugin<br />
&#8212;&#8212;&#8212;&#8212;&#8211;/PageIndexer.php</p>
<p>Our PageIndexer is just out extension of Zend_Search_Lucene_Document this is what we will be querying for all our page search needs.</p>
<pre class="brush:php">/**
 * Description of PageIndexer
 *
 * @author kaning
 */
class STEMNET_Controller_Plugin_PageIndexer extends Zend_Search_Lucene_Document {

    /**
     * Constructor. Creates our indexable document and adds all
     * necessary fields to it using the passed in document
     */
    public function __construct($document) {
       $this-&gt;addField(Zend_Search_Lucene_Field::Keyword('page_id', $document['page_id']));
        $this-&gt;addField(Zend_Search_Lucene_Field::UnIndexed('name', $document['page_name']));
        $this-&gt;addField(Zend_Search_Lucene_Field::UnIndexed('created', $document['publishdate']));
        $this-&gt;addField(Zend_Search_Lucene_Field::UnIndexed('caption', $document['page_caption']));
        $this-&gt;addField(Zend_Search_Lucene_Field::Text('title', $document['page_title']));
        $this-&gt;addField(Zend_Search_Lucene_Field::UnStored('content', $document['page_content']));
    }

}</pre>
<p>Not much introduction here besides the fact that I am adding the fields I want in my index bear in mind that the field data I am adding simply corresponds to what the Zend_Db_table select query returned for me.</p>
<p>Bear in mind that you really need to create the index only once. You will be updating it in subsequent times.</p>
<p>I formed the basis of this post from this <a title="PHPRiot website" href="http://www.phpriot.com/articles/zend-search-lucene" target="_blank">tutorial.</a> Look it up for more information</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 438px; width: 1px; height: 1px; overflow: hidden;">class STEMNET_SearchService {</p>
<p>protected<br />
$indexPath,<br />
$pageService,<br />
$pageIndexPath,<br />
$newsIndexPath,<br />
$document,<br />
$pageIndex;</p>
<p>public function setIndexPath($indexPath) {<br />
$this-&gt;indexPath = $indexPath;<br />
}</p>
<p>public function __construct($indexPath = NULL) {<br />
if (is_null($indexPath)) {<br />
$indexPath = APPLICATION_PATH . &#8216;/indexes/&#8217;;<br />
}<br />
$this-&gt;setIndexPath($indexPath);<br />
$this-&gt;pageIndexPath = $this-&gt;indexPath . &#8216;pageindex&#8217;;<br />
$this-&gt;newsindexPath = $this-&gt;indexPath . &#8216;newsindex&#8217;;<br />
$this-&gt;pageService = new STEMNET_PageService();<br />
}</p>
<p>public function createPageIndex() {<br />
$this-&gt;pageIndex = Zend_Search_Lucene::create($this-&gt;pageIndexPath);<br />
$pages = $this-&gt;pageService-&gt;getAllPages();</p>
<p>foreach ($pages as $page) {<br />
$this-&gt;pageIndex-&gt;addDocument(new STEMNET_Controller_Plugin_PageIndexer($page));<br />
}</p>
<p>// commit index<br />
$this-&gt;pageIndex-&gt;commit();<br />
}</p>
<p>}</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/231/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A question on Zend_Acls</title>
		<link>http://blog.kaning.co.uk/archives/228</link>
		<comments>http://blog.kaning.co.uk/archives/228#comments</comments>
		<pubDate>Wed, 28 Jul 2010 08:47:01 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend_Acl]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=228</guid>
		<description><![CDATA[So I have been playing with the Zend_Acl for a while now and I managed to integrate it with this site I am working on. I am however asking myself a few questions here. What is the best way to &#8230; <a href="http://blog.kaning.co.uk/archives/228">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I have been playing with the Zend_Acl for a while now and I managed to integrate it with this site I am working on.</p>
<p>I am however asking myself a few questions here. What is the best way to implement an ACL, which by the way is an Access Control List. On one hand I can do my &#8220;isAllowed&#8221; checks at the controller level, but do I want the user to get that far?</p>
<p>The other option is to implement our acl in the bootstrap file which always runs first and so makes it easier to check access even before the user gets to the routing and all that.</p>
<p>Now my problem is that I am a big fan of the MVC concept and by the very dynamic nature of the way I am working on this project, my ACLs are provided by a separate datastore i.e a database.</p>
<p>I don&#8217;t want to start calling in database adaptors and all that at bootstrap level, because that is just not nice. So I suppose the option here is to go with restricting access at in the init function of my controller.</p>
<p>Par example:</p>
<pre class="brush:php">$this-&gt;authObject = Zend_Auth::getInstance();
        // if not logged in, redirect to login form
        if (!$this-&gt;authObject-&gt;hasIdentity()) {
            $returnURL = urlencode('/admin');
            $this-&gt;_redirect('/login?returnUrl=' . $returnURL);
        } else {
            $this-&gt;userData = $this-&gt;authObject-&gt;getStorage();
            $this-&gt;userRole = $this-&gt;userData-&gt;read()-&gt;role;
        }
//some other instantiations here
if($this-&gt;accessControl-&gt;isAllowed($this-&gt;userRole)){
            $adminNavigation = Zend_Registry::get('AdminNavigation');
            $this-&gt;view-&gt;sideNavigation = $adminNavigation;

            $uri = $this-&gt;_request-&gt;getPathInfo();
            $this-&gt;view-&gt;uri = $uri;
        }else{
            $miscNavigation = Zend_Registry::get('MiscNavigation');
            $this-&gt;view-&gt;sideNavigation = $miscNavigation;
            $this-&gt;view-&gt;errorMessage = "This account does not have
enough permissions to be here";
        }</pre>
<p>You may notice from all this that I have an Admin Controller and based on our isAllowed value, we provide either an admin navigation or a misc one.</p>
<p>Obviously this can be rewritten to fit the purpose but it&#8217;s an example of using ACLs at the controller level.</p>
<p>Feedback welcome</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/228/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A note on CAPTCHA decorators and Zend_Form_&#8230;</title>
		<link>http://blog.kaning.co.uk/archives/222</link>
		<comments>http://blog.kaning.co.uk/archives/222#comments</comments>
		<pubDate>Fri, 09 Jul 2010 14:45:43 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=222</guid>
		<description><![CDATA[So if you have been struggling with setting up decorators with Zend_Form_Element_Captcha, here&#8217;s a note. I used to get an additional textbox with the hash returned by Zend creating the captcha image. And if you were stumped as to how &#8230; <a href="http://blog.kaning.co.uk/archives/222">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So if you have been struggling with setting up decorators with Zend_Form_Element_Captcha, here&#8217;s a note.</p>
<p>I used to get an additional textbox with the hash returned by Zend creating the captcha image. And if you were stumped as to how to remove them from your display try the following.</p>
<p>First of all your form element please note that I extracted this from my extension of the Zend_Form class</p>
<pre>
<pre class="brush:php">$captcha = new Zend_Form_Element_Captcha('captcha',
 array('label' =&gt; 'Type in the text you see in the image',
 'captcha' =&gt; array('captcha' =&gt; 'Image',
 'wordLen' =&gt; 6,
 'timeout' =&gt; 300,
 'height' =&gt; 60,
 'width' =&gt; 250,
 'font' =&gt; APPLICATION_PATH . '/../public/assets/fonts/arial.ttf',
 'fontSize' =&gt; 30,
 'imgDir' =&gt; APPLICATION_PATH . '/../public/assets/captcha/',
 'imgUrl' =&gt; 'http://' . $_SERVER['HTTP_HOST'] . '/assets/captcha/',
 ))
 );// there are certainly more options here but not necessary for my purposes.
//You can try altering the noise levels in the captcha image such as how many
// dots and lines should be created wiuth the image
// google noise levels in Zend_Form_Element_Captcha</pre>
</pre>
<p>This generates my captcha and I can add it to my form by going with</p>
<pre>
<pre class="brush:php">$this-&gt;addElements(array($email,$captcha,$submit));</pre>
</pre>
<p>Bear in mind that $name and $email and $submit are also new instances of their respective Zend_Form elements. In other words don&#8217;t include them if you&#8217;re copying and pasting.</p>
<p>Now after adding your elements you have to define a separate decorator for the Captcha because it&#8217;s obviously different from other form elements so here goes:</p>
<pre>
<pre class="brush:php">$captcha-&gt;setDecorators(array(
 'Captcha',
 'Errors',
 array('Label', array('separator' =&gt; '&lt;br /&gt;', 'requiredPrefix' =&gt; '* ')),
 array('HtmlTag', array('tag' =&gt; 'p', 'class' =&gt; 'form-element'))
 )
 );</pre>
</pre>
<p>Hope it&#8217;s helpful</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/222/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Having multiple instances of Zend Navigation in a single View</title>
		<link>http://blog.kaning.co.uk/archives/216</link>
		<comments>http://blog.kaning.co.uk/archives/216#comments</comments>
		<pubDate>Fri, 09 Jul 2010 10:30:44 +0000</pubDate>
		<dc:creator>Kwabena Aning</dc:creator>
				<category><![CDATA[MVC Frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Zend_Navigation]]></category>

		<guid isPermaLink="false">http://blog.kaning.co.uk/?p=216</guid>
		<description><![CDATA[so I have been playing around with the Zend Framework rather extensively over the past few weeks and it has been a very rewarding experience. I am posting this here because it was a bit difficult finding a work around &#8230; <a href="http://blog.kaning.co.uk/archives/216">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>so I have been playing around with the Zend Framework rather extensively over the past few weeks and it has been a very rewarding experience.</p>
<p>I am posting this here because it was a bit difficult finding a work around for the issue I describe below.</p>
<p>Zend Navigation had been giving me a lot of problems especially because I could not get the Navigation object passed to my view object to render two different navigation configs. The top menu which remains the same for all pages and is rendered in my layout and other sub menus rendered in my individual view pages.</p>
<p>Now getting to it:</p>
<p>in my bootstrap I initialise my navigation with something like this.</p>
<pre>
<pre class="brush:php">$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
 $miscNavConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/miscnavigation.xml', 'nav');
 $navigation = new Zend_Navigation($config);
 $miscNavigation = new Zend_Navigation($miscNavConfig);
 Zend_Registry::set(Zend_Navigation, $navigation);
 Zend_Registry::set('MiscNavigation', $miscNavigation);
 $view-&gt;navigation($navigation);</pre>
</pre>
<p>Now  lines 2, 4, and 6 are the new lines I have added for additional nagivation. I beleive you should be able to add new configurations as you move along if you need to.</p>
<p>The next bit was retrieving the sub navigation in my controller:</p>
<pre>
<pre class="brush:php">$miscNavigation = Zend_Registry::get('MiscNavigation');
$this-&gt;view-&gt;miscnavigation = $miscNavigation;</pre>
</pre>
<p>You can do this in your view but because I route several of my views through this controller I want to have to do it only once.</p>
<p>And finally in my view:</p>
<pre>
<pre class="brush:php">$options = array('ulClass' =&gt; 'submenu');
echo($this-&gt;navigation()-&gt;menu()-&gt;renderMenu($this-&gt;miscnavigation, $options));</pre>
</pre>
<p>Bear in mind that I use the renderMenu method instead of passing $this-&gt;miscnavigation into the menu method. If you do that you will overwrite any other instances of menu you have on the page with the miscnavigation object.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kaning.co.uk/archives/216/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

