开发者

Redirect category to a static page

Is it possible to开发者_开发百科 redirect some specific category to a static page?

So far I tried to do it with custom redirect but it complains about non-unique request path. Target path is disabled when editing category rewrite too


Yes it's possible but not without writing some custom code and adding an observer.

Without entering in much detail you could :

public function observe($observer) {
   $request = $observer['controller_action']->getRequest();
   $requestUrl = $request->getRequestUri();

   if($requestUrl == 'mycategoryname'){
       $destinationUrl = 'http://www.mysite.com/static_page';
       $response = Mage::app()->getResponse();
       $response->setRedirect($destinationUrl, 301);
       $response->sendResponse();
       exit;
   }
 }

And on the config.xml you are going to need

<frontend>
  <events>
    <controller_action_predispatch>
       <observers>
         <mycompany_mymodule_model_myclass>
          <type>singleton</type>
          <class>mycompany_mymodule_model_myclass</class>
          <method>observe</method>
         </mycompany_mymodule_model_myclass>
       </observers>
     </controller_action_predispatch>
   </events>
 </frontend>


Just came across this. I'm doing the same thing essentially and just had a thought that maybe this could be accomplished relatively easily with a module that adds a category attribute along with some additional and/or custom code for the nav bar.

I'm thinking that a new category attribute could be the url to rewrite to, and then a check in the navigation/top.phtml template to check if that attribute is filled in and then rewrite to that url if so.

I'll post here later if I get this to work as desired.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜