Magento: What is the best way to extend Magento to add a class that gets called on every page load
I want to create new functionality for Magento. I'm going to look at the url and grab the parameter. The problem is, it can be on any page. So I can't just extend the catalog or validation module.
I was thinking about extending the session classes, but I wasn't sure if it actually fits. Basically, I want to grab the parameter from the url and add some functionality from there if it's set or not. I don't think the class will be loaded automatically unless it was instantiated somewhere else with a getModel method, am I wrong?
How do I add a module that doesn't have a URL for the controller and what doesn't, but is not suitable for extending one of the core modules?
I was looking for a generic event but didn't really see one like before_page_load or something
a source to share
Take a look at the event controller_action_predispatch
in app/code/core/Mage/Core/Controller/Varien/Action.php
. This event should fire on every dispatch and allow you to capture 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 this is not in line with the bill. Hope it helps!
Thanks Joe
a source to share