Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › can't override a few functions in sf-header (no function_exists call)
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › can't override a few functions in sf-header (no function_exists call)
- This topic has 16 replies, 4 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Neighborhood
-
March 16, 2014 at 10:43 am #57841
A few functions in sf-header.php aren’t overrideable, specifically:
- sf_aux_links
- sf_woo_links
- sf_get_cart
- sf_get_wishlist
Because these methods all contain html output, any tweaking to header widths (whether by child theme or just in functions.php) to the header display has to go through them. sf_top_bar, sf_header, sf_logo etc all contain the if (!function_exists()) check before declaration, allowing them to be overriden.
Can these 4 functions also have if_exists checks? This way a function can be tweaked without overriding the whole file, and it’s 4 lines of additional code with no compatibility-breaking issues.Thanks!
March 16, 2014 at 6:22 pm #57888Hi,
Please create a file functions.php at neighborhood child theme and here you can override all functions with any check easily .Thanks ๐
With Best Regards
Swift IdeasMarch 17, 2014 at 12:06 am #57906Hi Mohammad,
Well, I have a functions.php in child theme, as mentioned. You cannot override any functions except those that will conditionally check to see if they already exist. The ones I listed don’t do this. If I take your advice, I’ll get a fatal error due to redeclaring an existing function (because the swift framework will try to make the function again when that code runs, as the functions.php runs first).
The addition of these function_exists checks in the swift framework sf-header.php would allow them to be overridden. Can you pass this along to one of the developers?
Also, is there an easier method for developer-related requests, or swift-framework-specific tickets, or is this the best method?
I appreciate the help!
March 17, 2014 at 1:32 am #57918Hi,
As you mentioned that need to put if (!function_exists()) check so you can put functions exist check at sf-header.php for sf_aux_links , sf_woo_links , sf_get_cart and sf_get_wishlist . So here how can i help you to put this check ? There is also a one method , just copy this file and paste at child theme so here you can modify easily any functions of sf-header.php .Thanks ๐
With Best Regards
Swift IdeasMarch 17, 2014 at 7:33 am #57934Hey Mohammad,
You’re right, I can add those checks to sf-header.php. But if I do so, I’ve now overridden the whole sf-header file, and have to be careful when upgrading not to overwrite it. I want to change as little as possible any time I’m overriding swift framework / neighborhood functionality. If I just want to override one file for its html output, that’s very different from having to keep up to date on the whole sf-header file, does that make sense? It’s all about changing as few things as possible to your core framework and theme while still supporting our needs in the child theme.
What I’m asking for is for you to add the function_exists check to the file in your code and release it with the next version of swift framework / neighborhood. This way I add these changes locally (to sf-header.php) and know my code won’t break when I update to your next version, because it will contain the function_exists check.
Then other developers can use this in the future, and it has no negative implications on backwards compatibility or anything–the function_exists checks also already being done in the same file for other functions, so I’m hoping it can go in the next version.
Thanks again for your time (:
March 17, 2014 at 8:30 am #57937Hi,
Thank you for your suggestion . I will forward this to the developer .
Thanks ๐
With Best Regards
Swift IdeasMarch 17, 2014 at 3:12 pm #58148I will add these override options for the next update ๐
Thanks,
– Ed
March 18, 2014 at 1:25 pm #58610Awesome, you’re the best!
March 18, 2014 at 1:37 pm #58613Thanks ๐
With Best Regards
Swift IdeasMarch 25, 2014 at 8:01 am #60546Ed, can you do the same for sf_mini_header and sf_mobile_search functions in the same file (sf-header.php line 424)?
They also output html, but currently don’t have function_exists calls. Hugely appreciated!March 25, 2014 at 8:35 am #60553Thank you for your suggestion .
March 25, 2014 at 1:09 pm #60778Added for the next update, thanks.
– Ed
May 30, 2014 at 7:00 pm #79157Hello there,
I wonder if overrides mentioned here #58148 are already in place. I need to modify the output of sf_main_menu, sf_aux_links , sf_woo_links , sf_get_cart… etc (For Dante)
May 31, 2014 at 2:50 am #79179Hi,
You can modify these functions output through child theme so please copy all of these functions from sf-header.php and paste at functions.php in child theme. Here you can easily edit these functions.Thanks ๐
With Best Regards
Swift IdeasMay 31, 2014 at 2:50 am #79180Hi,
@iquarius – You can modify these functions output through child theme so please copy all of these functions from sf-header.php and paste at functions.php in child theme. Here you can easily edit these functions.Thanks ๐
With Best Regards
Swift Ideas -
Posted in: Neighborhood
You must be logged in to reply to this topic.