Skip to main content

hikashop override controllers folders of the frontend

1 year 11 months ago #364474 by aminweb
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.

1 year 11 months ago #364483 by nicolas
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.

1 year 11 months ago #364489 by aminweb
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:
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.

1 year 11 months ago #364494 by nicolas
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.

1 year 11 months ago #364496 by aminweb
BOM! worked thank you man!

Yes i see on helper now changed to:
Code:
$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.047 seconds
Powered by Kunena Forum