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!
how to overwrite a core function
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: how to overwrite a core function
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.
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.
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: how to overwrite a core function
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)?
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)?
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: how to overwrite a core function
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!
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!
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: how to overwrite a core function
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: how to overwrite a core function
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)
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: how to overwrite a core function
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.
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.