<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Zend Framework: If controller not found, use default</title>
	<atom:link href="http://www.karlkatzke.com/zend-framework-if-controller-not-found-use-default/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.karlkatzke.com/zend-framework-if-controller-not-found-use-default/</link>
	<description>Geek of the Week</description>
	<lastBuildDate>Tue, 27 Sep 2011 13:39:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Janther</title>
		<link>http://www.karlkatzke.com/zend-framework-if-controller-not-found-use-default/comment-page-1/#comment-1791</link>
		<dc:creator>Janther</dc:creator>
		<pubDate>Tue, 05 Oct 2010 02:47:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.karlkatzke.com/?p=254#comment-1791</guid>
		<description>Hi i studied a little more about this stuff and found a much cleaner way to do this. First i create a plugin with a predispatch function.
&lt;code&gt;
class Plugin_Default extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
	$front = Zend_Controller_Front::getInstance();
	$dispatcher = $front-&gt;getDispatcher();
	if (!$dispatcher-&gt;isDispatchable($request)) {
		echo &quot;redirected&quot;;
		$request-&gt;setControllerName(&#039;index&#039;);
		$request-&gt;setActionName(&#039;index&#039;);
	} else {
		echo &quot;not redirected&quot;;
	}
}
}
&lt;/code&gt;
So before dispatching you check if the controller exist or not. finally you register the plugin in the bootstrap file
&lt;code&gt;
  protected function _initPlugin() {
    $front = Zend_Controller_Front::getInstance();
    $front-&gt;registerPlugin(new My_Controller_Plugin_FallBack());
  }
&lt;/code&gt;

i hope it helps. this way you dont have to try to run twice the controller.</description>
		<content:encoded><![CDATA[<p>Hi i studied a little more about this stuff and found a much cleaner way to do this. First i create a plugin with a predispatch function.<br />
<code><br />
class Plugin_Default extends Zend_Controller_Plugin_Abstract {<br />
public function preDispatch(Zend_Controller_Request_Abstract $request) {<br />
	$front = Zend_Controller_Front::getInstance();<br />
	$dispatcher = $front-&gt;getDispatcher();<br />
	if (!$dispatcher-&gt;isDispatchable($request)) {<br />
		echo "redirected";<br />
		$request-&gt;setControllerName('index');<br />
		$request-&gt;setActionName('index');<br />
	} else {<br />
		echo "not redirected";<br />
	}<br />
}<br />
}<br />
</code><br />
So before dispatching you check if the controller exist or not. finally you register the plugin in the bootstrap file<br />
<code><br />
  protected function _initPlugin() {<br />
    $front = Zend_Controller_Front::getInstance();<br />
    $front-&gt;registerPlugin(new My_Controller_Plugin_FallBack());<br />
  }<br />
</code></p>
<p>i hope it helps. this way you dont have to try to run twice the controller.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

