Override administrator controller/controller.php

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
7 years 6 months ago - 7 years 6 months ago #89617 by James Riley
I'm trying to override a function using the new override method. I've been able to override front-end controllers, but I'm having trouble with a back-end override.

I'm attempting to implement support for a backend custom.css file, and it works in the core controller.php file just fine.
Here's the code that I have placed in /administrator/components/com_eventbooking/controller/override/controller.php with my additions annotated between the BEGIN-and END JAMES ADD tags:
Code:
<?php class EventbookingControllerOverride extends EventbookingController { public function display($cachable = false, array $urlparams = array()) { JFactory::getDocument()->addStyleSheet(JUri::base(true) . '/components/com_eventbooking/assets/css/style.css'); /* ********** BEGIN JAMES ADD 11/03/2016 ******************** */ if (file_exists(JPATH_ROOT . '/administrator/components/com_eventbooking/assets/css/custom.css') && filesize(JPATH_ROOT . '/administrator/components/com_eventbooking/assets/css/custom.css') > 0 ) { JFactory::getDocument()->addStyleSheet(JUri::base(true) . '/components/com_eventbooking/assets/css/custom.css'); } /* ********** END JAMES ADD 11/03/2016 ******************** */ parent::display($cachable, $urlparams); if ($this->input->getCmd('format', 'html') != 'raw') { EventbookingHelper::displayCopyRight(); } } } ?>

Can I not override this function? Am I doing something wrong? Or are overrides not implemented for the back-end component yet?

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.
Last edit: 7 years 6 months ago by James Riley.

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago #89640 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Override administrator controller/controller.php
Hi James

The class name is not correct. It should be EventbookingControllerOverrideController

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
7 years 6 months ago #89757 by James Riley
Replied by James Riley on topic Override administrator controller/controller.php
Ahhh... It works now :) Thanks, Tuan.

So, with overrides, if you are overriding the a "root" EventbookingController or a EventbookingHelper, etc., class, you need to add "OverrideController" or "OverrideHelper" to the end of the new override class, and not insert "Override" as you would in the case other classes.

Example:
  • EventbookingController -> EventbookingControllerOverrideController
  • EventbookingControllerRegister -> EventbookingControllerOverrideRegister
Could you update the documentation to reflect this? There is one example under Helper that shows this in use, but the instructions for helper / controller / view / model just say to insert "Override" without mentioning this exception.

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago #89785 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Override administrator controller/controller.php
OK James. I will update documentation when I have some free time. Right now, still too busy

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc