![]() |
|
warning template-functions.php - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: warning template-functions.php (/thread-12280.html) |
warning template-functions.php - ventesites - 2015-08-25 hello warning template-functions.php - fretzl - 2015-08-25 You're getting that message because a core file has been changed. If you want to change a function, copy and rename the function and put it into a file called EDIT warning template-functions.php - acrylian - 2015-08-25 Or create a plugin. warning template-functions.php - ventesites - 2015-08-25 ok, so i should put the original file back where it belongs and copy the modified functions in functions.php of my theme but should i delete them from the original or leave them without touching anything? warning template-functions.php - acrylian - 2015-08-25 Yes. I think I advised that already on some of your other topics. If you modify core files you have to do it on every Zenphoto update and you may break or change functionality so that we may have problems supporting here since we think of the way it was originally. It is also recommend in the theming tutorial. You also should make a copy of the theme under a new name for the same reason. Of course you can never be kept from some maintenaince if things change over time. warning template-functions.php - fretzl - 2015-08-25 Quote:but should i delete them from the original or leave them without touching anything warning template-functions.php - ventesites - 2015-08-28 sorry i don't get what you say. Copy and RENAME the functions I have changed in MY file functions.php? you mean, i should copy the modified function under another name? but this imply to modify every single file where the function is called ! warning template-functions.php - fretzl - 2015-08-28 Sorry if I wasn't clear.
warning template-functions.php - acrylian - 2015-08-28 I think you really need to learn some coding basics before you start doing these things. You cannot have two functions with the same name so you have to rename your duplicate. You NEVER should modify core functions. That are all functions that belong to Zenphoto and are in the file in /zp-core. You can do that on your own risk of course. First, if you do that and you get problems you are on your own as we alway will refer to the original behaviour. Second, you will have to do this on every Zenphoto update. Similar of course for plugins. So instead you copy the function in question, rename it (so printRandomImage() would be something like printMyRandomImages()), place it in your theme functions.php (or your own custom plugin) and modify it to your liking. Then you use that function on your theme instead the original. And yes of course you need to replace all usages if you want to use your own function. In any case you have to maintain your changes since things can change on updates, too. Edit: Fretz was quicker and shorter ;-) warning template-functions.php - ventesites - 2015-08-28 I am not familiar with your script doesn't mean i am unable to do basic coding.... I work with Prestashop after over 9 years with OScommerce, in Prestashop there is a similar system to overwrite functions/classes etc. BUT there is no need to rename anything. That's why i was suprised. warning template-functions.php - acrylian - 2015-08-28 I am sorry, I naturally don't know your background. The functions we recently talked about on your other topics are from template-functions.php and not part of a class as you can see on the file itself, so if renaming here is necessary if you copy one to customize. You can of course also create your own classes as wrappers or maybe use namespaces in your theme functions.php then you don't need to rename the functions itself. But still you need to separate them from the originals. |