Skip to main content

Classes overrides

More
3 years 6 months ago #349725 by khashiz
Classes overrides was created by khashiz
-- HikaShop version -- : 4.7.1
-- Joomla version -- : 4.2.8
-- PHP version -- : 8.1

Hi
i copied the file "filter.php" form "administrator/components/com_hikashop/classes" to here "templates/XXX/html/com_hikashop/administrator/classes" to create an override for filters but i get the error which is attached to this message.

what did i mistaked ?

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

More
3 years 6 months ago #349727 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

You need to change the name of the class to add Override at the end.
For reference:
www.hikashop.com/support/documentation/6...ntation.html#classes
The following user(s) said Thank You: khashiz

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

More
3 years 1 month ago - 3 years 1 month ago #354157 by khashiz
Replied by khashiz on topic Classes overrides
I added "Override" at the of class names in filter.override.php file

error is gone now but the system is not reading this file

all I want to do is to add a DIV before be <ul> element on line 2291
Last edit: 3 years 1 month ago by khashiz.

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

More
3 years 1 month ago #354160 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

I suppose what you're saying is false. The system must be reading this file, otherwise, you wouldn't have had the error you reported in your first message in this thread. What I think is probably happening is that the modifications you want to make are in the secondary classes of this filter.override.php file.
Adding the "Override" suffix to the class name will only work for the main class in this file.
For the other classes, where you want to add your div, you also need to modify the methods of that main class which load the other classes.
Search for the line:
Code:
$classType = 'hikashop'.ucfirst($filter->filter_type).'Class';
in your file. You should find three occurrences.
After all of them, add this code:
Code:
if(class_exists($classType.'Override')) $classType .= 'Override';
That way, it will support the Override suffix for the other classes. And you'll see your modifications being taken into account.
The following user(s) said Thank You: khashiz

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

More
3 years 1 month ago #354178 by khashiz
Replied by khashiz on topic Classes overrides
that worked greatttttttt

thank youuuuuu

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

More
3 years 1 month ago #354229 by khashiz
Replied by khashiz on topic Classes overrides
in this same file, there is a function "titlePosition" (on line 1545 in my file)

can you help how can i edit my filter.override.php file to read the function from this file ?

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

More
3 years 1 month ago #354232 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

Well, you should be able to access it by just calling the function.
I'm not sure what problem you have with that function ?
Where are you trying to call it from ?
Please provide more details.
Maybe a copy of the file would help (you can zip it to attach it here).

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

More
3 years 1 month ago #354262 by khashiz
Replied by khashiz on topic Classes overrides
this is the override file
This attachment is hidden for guests.
Please log in or register to see it.
i have created

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

More
3 years 1 month ago #354263 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

I can see that you added a function titlePosition_netparsi which is a modified version of the titlePosition function in the default class.
Why did you change the name ?
If you keep the same name, it will automatically be taken into account.
If you change the name of the function, then you need to find all the places where titlePosition is called in your file and also change the call to titlePosition_netparsi

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

More
3 years 1 month ago #354444 by khashiz
Replied by khashiz on topic Classes overrides
i changed the name because i thought i might work with another name

without changing anyname, this file doesnt shows my div

i attached the correct file again
This attachment is hidden for guests.
Please log in or register to see it.

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

More
3 years 1 month ago #354476 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

That's because you don't use the class where you made the changes.
For example, you have this:
class hikashopListClassOverride extends hikashopFilterTypeClass{
It means that your override class hikashopListClassOverride extends from the default hikashopFilterTypeClass
But you want it to use the override class. So you need to change this line to:
class hikashopListClassOverride extends hikashopFilterTypeClassOverride{

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

More
3 years 1 month ago #354538 by khashiz
Replied by khashiz on topic Classes overrides
I added the word "Override" to the of all class names and extend ... still not working ...

i thing there is a problem here :( :(

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

More
3 years 1 month ago #354539 by nicolas
Replied by nicolas on topic Classes overrides
Hi,

Well, it's not easy overridding all the filter classes, but it's definitely possible. You must still be missing something in your code.

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

Time to create page: 0.218 seconds
Powered by Kunena Forum