tags:

views:

209

answers:

1

I am looking to create some new functionality to Magento. I am going to be looking to the url and grabbing a parameter. The issue is, this can be on any page. So I can't just extend a Catalog or Checkout Module.

I thought about extending the session classes but I wasn't sure it really fit. Basically I want to grab a parameter from the url and from there add some functionality if it is set or not. I don't think a class will get auto loaded unless it is instantiated somewhere else with a getModel method, am I wrong?

How can you add a module that doesn't have a url path for controller and what not, but doesn't fit extending one of the core modules?

I looked for a generic event but didn't really see one like before_page_load or something

+3  A: 

Take a look at the event controller_action_predispatch in app/code/core/Mage/Core/Controller/Varien/Action.php. This event should get called on each dispatch and allow you to grab whatever parameters you need.

The event passes the controller as data, so you can do this:

function yourEvent( $event ) {
    $controller = $event->getController();
    // your processing here
}

Let me know if that doesn't fit the bill. Hope that helps!

Thanks, Joe

Joseph Mastey
Thanks, I just noticed a few more of these after looking at one of Alan Storm's extensions, not sure how I missed them. I will let you know how it goes
dan.codes
FYI: Search the core modules for the string "Mage::dispatchEvent" to get a full list of all the events Magento supports. Most are descriptively named.
Alan Storm