Page 1 of 1

how to overwrite a core function

Posted: Tue Mar 30, 2021 9:32 am
by loop
Hi
sorry to ask again, but i whant to do it right and secure for updates...
if i want to change for example a hook tooltip.php
i want to add there:
$('[data-toggle="tooltip"]').tooltip({
sanitize: false,
});
of course i could overwrite tooltip.php but on the next update it's gone, how should be this done?

same question which i have in a couple of hours if i want to change a corefunction like tep_href_link what would be the best approach?
thank you!

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 9:59 am
by ecartz
There is currently no way to do this for admin hooks other than stuffing them in includes/system/override (under catalog, since hooks are always loaded from catalog). The file name might get weird, since I think the file and class name would have to match. Which would be different from the original file name. Something like hook_admin_site_wide_tooltip.php for class hook_admin_siteWide_tooltip.

In catalog in 1.0.8.0, you can change tep_href_link by deleting the database hook that loads it and adding a replacement hook that loads your function. In 1.0.8.1, you could override the Href class instead.

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 10:14 am
by loop
i don't really get why the name of the file has to be "site_wide" but it worked :)

as i use 1.0.8.1 how i can override a single function (which is normali in a functionfile with many functions in it)?

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 3:08 pm
by loop
Hi Again, to override categories.php (to make a own categories.php)
i tried to put a copy in /template/ovveride/admin/categories.php but it won't take the copy, is it not possible to overwrite there a admin file?

because it seems i have to make to much changes to categories.php that i could do it with hooks :(
for example on
$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($products_image->parse() && $products_image->save()) {
$sql_data['products_image'] = Text::prepare($products_image->filename);
}

i need that the destination directory (as i have alot products) needs to be subfolders, so i have in the images directory /images/1/2/3/test.jpg for example so i need to change there the code...i think thats not possible with a hook...

thank you so much for the help!

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 3:13 pm
by raiwa

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 3:16 pm
by loop
hi Rainer, thank you, i already seen this, but i need to automaticly upload the image according the products_id, i don't like to set different folder, it should upload the 10005 product_id in the folder images/1/0/0/1005.jpg for example, so i have in every folder (in this example maximum 100 images)

Re: how to overwrite a core function

Posted: Tue Mar 30, 2021 5:05 pm
by ecartz
1. It would probably be easier to modify an already hooked App than the categories.php page.
2. If you still feel that you need to override the page, just copy the whole thing to admin/my_categories.php and add a new menu entry for it. Then delete the other one -- the menu entry is just one file and even if it comes back, it doesn't do much harm.