Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Override Files--Should they be different from defaults?

Override Files--Should they be different from defaults?

Locked

Views: 2,601

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
9 Feb 2007, 6:20 AM
#1
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Override Files--Should they be different from defaults?

I'm not sure where to ask about this, but here goes. I have a general question about the template system. Having read this:

You should only copy files over to your custom template directory that you make modifications to. If you do not make modifications, then by default, the shop will call the default file from the template_default directory.

I was under the impression that there should be no files in my CUSTOM template folder which are identical in content to their corresponding files in template_default. However, I did some comparing of the files in a template I purchased, and found some of them to be identical.

One of the identical files is templates\CUSTOM\common\html_header.php. Since the content was identical, I assumed that I could delete the file from the CUSTOM template folder and Zen Cart would automatically use the file in template_default. However, when I deleted the file in my custom folder, I get this message:

Warning: main(includes/templates/CUSTOM/common/html_header.php): failed to open stream: No such file or directory in C:\Server\ZenCart\index.php on line 43

Fatal error: main(): Failed opening required 'includes/templates/CUSTOM/common/html_header.php' (include_path='.;c:\php4\pear') in C:\Server\ZenCart\index.php on line 43

Is my understanding incorrect, or is there something else wrong? I am working with a template I purchased--perhaps it is buggy?

9 Feb 2007, 1:56 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Override Files--Should they be different from defaults?

Is my understanding incorrect, or is there something else wrong? I am working with a template I purchased--perhaps it is buggy?
Your understanding is correct for a template that is compliant to Zen Cart functionality. Sounds like a TM -template and they are known for not adhering to the basics

9 Feb 2007, 5:13 PM
#3
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

Thanks a bunch. It is good to know that I was getting it. My template isn't from TM, but apparently its author didn't do it right either :censored:

Any suggestions about how to find the problem? It looks like almost all of the differences between my template and template_default are in stylesheet.css and tpl_header.php. With only those to files to look through, I am hoping that I can find and correct the problem fairly quickly.

9 Feb 2007, 5:22 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Override Files--Should they be different from defaults?

One of the identical files is templates\CUSTOM\common\html_header.php. Since the content was identical, I assumed that I could delete the file from the CUSTOM template folder and Zen Cart would automatically use the file in template_default. However, when I deleted the file in my custom folder, I get this message:
From this I would just not delete this file.... If you replace it is there still an issue that you have not yet defined? Unless I missed it

9 Feb 2007, 5:54 PM
#5
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

Sorry, I should have been more clear. I just want to fix the template so that it conforms to the standard. My thinking is that upgrades will be easier if I don't have to sort through a bunch of files that actually don't need to be in the template anyway. My shop is not live yet (it exists only on my local test server), so I don't have to worry about taking it down or anything. I am just trying to get everything right before I start to prevent unnecessary problems when it is live.

So, I was asking for suggestions on how to find the problem with my template which causes it to need an html_header.php in the CUSTOM folder rather than just using html_header in template_default.

9 Feb 2007, 7:09 PM
#6
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

I just discovered something. I actually didn't delete html_header.php from the CUSTOM directory, I just changed the name (to zhtml_header.php--so that it would be easy to undo). I assumed that changing the name was as good as deleting the file, but I was apparently wrong about that. When I actually deleted the file, then I had no problem.

I did a little more playing, and found out that if I change the name altogether (for example, change it to LeaveThisFileOut.php, rather than zhtml_header.php), then there is no problem.

Perhaps someone can explain why this is so. Are there any other pitfalls which I should be aware of with regard to this?

9 Feb 2007, 7:15 PM
#7
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Override Files--Should they be different from defaults?

No explanation but as you and I know this is the action noted.

Better to rename the extention so as not to be parsed like:

html_header.old

9 Feb 2007, 8:38 PM
#8
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Override Files--Should they be different from defaults?

As with the "CSS" files, any "php" extension will be picked up by the cart no matter what. So, as Kobra pointed out, better to rename the extension to "old" or delete the file on the server.

9 Feb 2007, 9:10 PM
#9
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

Thanks Clyde. I'll be sure to clear out all the unnecessary files.

I'm not thrilled with my template creator right now. Out of 25 php files I have found only 3 that were actually necesasry. All of the others are just copies of the files in template_default. A person who charges money for their templates ought to do a better job.

9 Feb 2007, 10:43 PM
#10
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Override Files--Should they be different from defaults?

Out of 25 php files I have found only 3 that were actually necesasry.
I hope that you are using a diff tool for this over a visual comparison??

9 Feb 2007, 11:13 PM
#11
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

Yes. I used PSPad, though I normally use WinMerge. I removed all 22 of the files that I had found to be identical, and I see no difference in the looks or function of the template.

The vast majority of the template is controlled from the stylesheet (which the template author also messed up--he called it stylesheet2.css even though it has all the same selectors as the original). There are a few changes in templates\CUSTOM\common\tpl_header.php and languages\english\CUSTOM\header.php. It will be a good template when I am done with it, but I had really expected it to be good the moment I shelled out for it.

So, I spent 50 bucks on a template that is really not that good :shocking:
I thought I was saving myself some work, but it looks like that may not be the case. Oh well, at least I have nice header and logo images to work with!

On the upside, I am becoming much more familiar with ZenCart this way. Whenever problems arise later on, I will be in a better position to tackle them!

Thanks for your help folks.

9 Feb 2007, 11:17 PM
#12
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Override Files--Should they be different from defaults?

OFelixCulpa:

Perhaps someone can explain why this is so. Are there any other pitfalls which I should be aware of with regard to this?

The reason why is the way the cart searches for a template file (governed by functions in includes/classes/template_func.php)
It looks in various places to find a match for the filename, and this particular problem is caused by the preg_match function finding the pattern it was looking for in your modified file name (because you simply added a z at the front, the remainder of the name was a match for the pattern html_header.php).

If you had changed the name in any way other than adding letters at the front or after .php, there would not have been a match.

9 Feb 2007, 11:46 PM
#13
ofelixculpa avatar

ofelixculpa

New Zenner

Join Date:
Jul 2006
Posts:
43
Plugin Contributions:
0

Re: Override Files--Should they be different from defaults?

That makes perfect sense. I'll know better next time. I was initially worried that there was some other problem which was causing it to refuse to use the default file. I'm glad that wasn't the case.

Thanks for the explanation.