This: Cakephp Override HtmlHelper::link asks a very similar question, but there were no complete answers. Perhaps now, with Cake 2 out, there will be.
I want to create a custom helper that is a subclass of Cake's Paginator Helper. I want my new helper to override the 'numbers' method of Cake's Paginator helper, but I want it to inherit all other methods.
Is it possible to extend core helpers in this way? Obviously, I don't want to: modify the Cake Core; put unnecessary code in the AppHelper superclass; or duplicate the entire core Pagination Helper into my new helper.
Adding onto Brelsnok's solution, aliasing is the right way to do it. If you add this code to your AppController.php file, anytime that you use the Paginator, it will use your extended class.
public $helpers = array(
'Paginator' => array('className' => 'PaginatorExt' )
);
Since the PaginatorExtHelper class already extends PaginatorHelper, the only function being overridden is numbers
. Any calls to other Paginator methods will be handled by the core PaginatorHelper class, just as if it was a vanilla Cake install.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With