Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:18:02+00:00 2026-05-31T08:18:02+00:00

I’m trying to get some custom routing going on in Magento using the following

  • 0

I’m trying to get some custom routing going on in Magento using the following code (which I’ve only slightly modified from here https://stackoverflow.com/a/4158571/1069232):

class Company_Modulename_Controller_Router extends Mage_Core_Controller_Varien_Router_Standard {

public function match(Zend_Controller_Request_Http $request){
    $path = explode('/', trim($request->getPathInfo(), '/'));
    // If path doesn't match your module requirements
    if ($path[1] == 'home.html' || (count($path) > 2 && $path[0] != 'portfolios')) {
        return false;
    }
    // Define initial values for controller initialization
    $module = $path[0];
    $realModule = 'Company_Modulename';
    $controller = 'index';
    $action = 'index';
    $controllerClassName = $this->_validateControllerClassName(
        $realModule, 
        $controller
    );
    // If controller was not found
    if (!$controllerClassName) {
        return false; 
    }            
    // Instantiate controller class
    $controllerInstance = Mage::getControllerInstance(
        $controllerClassName, 
        $request, 
        $this->getFront()->getResponse()
    );

    // If action is not found
    if (!$controllerInstance->hasAction($action)) { 
        return false;
    }
    // Set request data
    $request->setModuleName($module);
    $request->setControllerName($controller);
    $request->setActionName($action);
    $request->setControllerModule($realModule);
    // Set your custom request parameter
    $request->setParam('url_path', $path[1]);
    // dispatch action
    $request->setDispatched(true);
    $controllerInstance->dispatch($action);
    // Indicate that our route was dispatched
    return true;
}

}

The result is a page where the template has loaded but with no content. If I comment out the $this->loadLayout() / $this->renderLayout() in my controller I can print to screen. But when I try and load a Template and/or Block it breaks somewhere.

home.html also loads fine (as the method returns false if the path is home.html).

Any assistance would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:18:03+00:00Added an answer on May 31, 2026 at 8:18 am

    I was implementing something similar to this and came across the same problem(That makes sense, because I copypasted your code)

    before $request->setDispatched(true);
    I added $request->setRouteName('brands'); (brands is the frontname of my module).
    And It worked.Don’t know if It’ll work for you, but definetely there was something missing so that magento didn’t know what layout to apply, because I could tell that teh controller was being reached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.