hikashop override controllers folders of the frontend

  • Posts: 138
  • Thank you received: 4
1 month 1 day ago #364474

Hello,
as i see on document " www.hikashop.com/support/documentation/6...ntation.html#classes " we can override Admin controllers. well! so how can override Frontend one too?
for example i want override "users.php" controller file on frontend of component!
how can i handle it?


Joomla Developer | am.ebrahimzadeh[at]gmail.com

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
1 month 6 hours ago #364483

Hi,

It's the same principle, but you need to add your override file in your frontend template instead of the backend template.

The following user(s) said Thank You: aminweb

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

  • Posts: 138
  • Thank you received: 4
1 month 5 hours ago #364489

thank you reply,
i want override this file:
SITE/components/com_hikashop/controllers/user.php

So i created override file on template on this path:
SITE/templates/cassiopeia/html/com_hikashop/administrator/controllers/user.override.php
(also i created on "SITE/templates/cassiopeia/html/com_hikashop/controllers/user.override.php" path too for testing.)

by this code:

<?php

class userControllerOverride extends userController
{
    public function form()
    {
        $user = JFactory::getUser();

        // Allow users in group ID 15 to access the form
        $allowedGroupId = 15;
        if ($user->guest || in_array($allowedGroupId, $user->getAuthorisedGroups())) {
            hikaInput::get()->set('layout', 'form');
            return $this->display();
        }
		$app = JFactory::getApplication();
		$config = hikashop_config();
		$url = $config->get('redirect_url_when_registration_form_access_while_already_logged', '');
		if(empty($url)) {
			global $Itemid;
			$url_itemid=(!empty($Itemid)?'&Itemid='.$Itemid:'');
			$url = hikashop_completeLink('user&task=cpanel'.$url_itemid, false, true);
		} else {
			$url = hikashop_cleanURL($url);
		}
		$app->redirect($url);
		return false;
	}
	
}


but not affect!!


Joomla Developer | am.ebrahimzadeh[at]gmail.com

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
1 month 2 hours ago #364494

Hi,

Right, thanks for your feedback.
You did everything correctly. The path SITE/templates/cassiopeia/html/com_hikashop/administrator/controllers/user.override.php is correct.
However, I can see on our end that a piece of code is missing for overrides to work for frontend controllers using template overrides.
So, the solution right now would be to create a system plugin to load the class yourself.
I've made a patch on our end so that it can work as expected.
Download again the install package of the latest version of HikaShop on our website and install it on yours and you'll get the patch. What you have now should then work without further changes.

The following user(s) said Thank You: aminweb

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

  • Posts: 138
  • Thank you received: 4
1 month 1 hour ago #364496

BOM! worked thank you man!

Yes i see on helper now changed to:

$srcPath = HIKASHOP_BACK;
		if($group == 'controller') {
			$className = $class.ucfirst($group);
			if(hikashop_isClient('site'))
				$srcPath = HIKASHOP_FRONT;
		}
$override = str_replace($srcPath, $path, constant(strtoupper('HIKASHOP_'.$group))).$class.'.override.php';

thank you Nicolas!


Joomla Developer | am.ebrahimzadeh[at]gmail.com

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

Time to create page: 0.056 seconds
Powered by Kunena Forum