Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Need to override functions_general.php

Need to override functions_general.php

Locked

Views: 3,333

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
22 Feb 2008, 3:58 AM
#1
lbowenc avatar

lbowenc

New Zenner

Join Date:
Jan 2004
Posts:
38
Plugin Contributions:
1

Need to override functions_general.php

I need to make a minor change to includes/functions/functions_general.php. Is there a way proper way to override this file, or to override a function that is in this file?

Thanks ... Lucy

22 Feb 2008, 4:18 AM
#2
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Need to override functions_general.php

What are you trying to do?

22 Feb 2008, 4:28 AM
#3
lbowenc avatar

lbowenc

New Zenner

Join Date:
Jan 2004
Posts:
38
Plugin Contributions:
1

Re: Need to override functions_general.php

I need to modify zen_clean_html ... reasons are complicated ... is there a way to override just that function so that future updates to Zen won't wipe my mods out?

28 Mar 2008, 10:54 AM
#4
jipjip avatar

jipjip

New Zenner

Join Date:
Mar 2008
Posts:
1
Plugin Contributions:
0

Re: Need to override functions_general.php

Hallo,

it is possible to do this by overriding the file 'includes/init_includes/overrides/init_general_funcs.php'. This file does the require-statements for the general functions from 'includes/functions':

require(DIR_WS_FUNCTIONS . 'functions_general.php');
require(DIR_WS_FUNCTIONS . 'html_output.php');
require(DIR_WS_FUNCTIONS . 'functions_email.php');
require(DIR_WS_FUNCTIONS . 'functions_ezpages.php');
include(DIR_WS_MODULES . 'extra_functions.php');

In the override-file, just put something like:

if (file_exists(DIR_WS_FUNCTIONS . $s_overrides . 'functions_general.php')) {
	// if override-file exists, use instead of the original file
	require(DIR_WS_FUNCTIONS . $s_overrides . 'functions_general.php');
} else {
	require(DIR_WS_FUNCTIONS . 'functions_general.php');
}
``` instead of the simple require statement.
(An example 'init_general_funcs.php' is attached, where the name of the override-folder for the functions is choosen to be 'overrides').

Now it is possible to override one of the following files by putting your own version into the 'includes/functions/overrides'-folder:
 - functions_general.php
 - html_output.php
 - functions_email.php
 - functions_ezpages.php

Since the overriding of the files from 'includes/functions' is not complete (not all files are overridable, but just a few of them), I strongly advise to put a readme-file into the new overrides-folder, that explains about this (see example attached: readme.txt).

And remember to merge all files inside the overrides-folders (all of them) after upgrades :wink:

greets

jipjip

edit:
it is possible that you need to override the "includes/modules/payment/paypal/ipn_application_top.php"-file, too. You have to decide for yourself, if this file a) is used at all, b) does need the original version or the overriden version of the general functions. That is because the file does the require on it's own instead of using the init_includes.
28 Mar 2008, 11:18 AM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,693
Plugin Contributions:
56

Re: Need to override functions_general.php

lbowenc:

I need to modify zen_clean_html ... reasons are complicated ... is there a way to override just that function so that future updates to Zen won't wipe my mods out?

When I do something like this, I always rename the file from the distro to "<filename>.orig" - so that way when it's time to upgrade I can just search for "*.orig" files and have a list of things I need to customize after the install.

Good luck,
Scott