Classes overrides

  • Posts: 197
  • Thank you received: 13
1 year 1 month ago #349725

-- 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 ?

Attachments:

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
1 year 1 month ago #349727

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.

  • Posts: 197
  • Thank you received: 13
8 months 2 weeks ago #354157

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: 8 months 2 weeks ago by khashiz.

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 months 2 weeks ago #354160

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:

$classType = 'hikashop'.ucfirst($filter->filter_type).'Class';
in your file. You should find three occurrences.
After all of them, add this 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.

  • Posts: 197
  • Thank you received: 13
8 months 2 weeks ago #354178

that worked greatttttttt

thank youuuuuu

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

  • Posts: 197
  • Thank you received: 13
8 months 2 weeks ago #354229

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.

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 months 2 weeks ago #354232

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.

  • Posts: 197
  • Thank you received: 13
8 months 2 weeks ago #354262

this is the override file

File Attachment:

File Name: filter.override.zip
File Size:20 KB
i have created

Attachments:

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 months 2 weeks ago #354263

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.

  • Posts: 197
  • Thank you received: 13
8 months 1 week ago #354444

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

File Attachment:

File Name: filter.ove...8-17.zip
File Size:20 KB

Attachments:

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 months 1 week ago #354476

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.

  • Posts: 197
  • Thank you received: 13
8 months 4 days ago #354538

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.

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 months 4 days ago #354539

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.084 seconds
Powered by Kunena Forum