Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Overrides not overriding

Overrides not overriding

Views: 1,133

Results 1 to 13 of 13
28 Jan 2011, 12:56 AM
#1
joeyrocket avatar

joeyrocket

New Zenner

Join Date:
Jan 2011
Posts:
16
Plugin Contributions:
0

Overrides not overriding

I did a search for this but couldn't find any answers. I apologize if this is redundant.

In includes/modules/sideboxes, I have an override folder (includes/modules/sideboxes/my_theme). In that folder resides the override file, information.php. The problem is that my site is defaulting to the original file, includes/modules/sideboxes/information.php, and ignoring my override.

The issue is not in the code of my override, because if I trade the files, my changes show up. And if I delete the original, and JUST have my override, the changes show up.

Does anyone know what I am doing wrong?

28 Jan 2011, 1:40 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

And if I delete the original, and JUST have my override, the changes show up.

This part is weird. The first situation (switching files) would be a natural consequence of an overlooked error in folder naming, but if the folder name were wrong, it could never be found when the original file was removed.
Can we see the site? Maybe that will give some clues.

28 Jan 2011, 1:53 AM
#3
joeyrocket avatar

joeyrocket

New Zenner

Join Date:
Jan 2011
Posts:
16
Plugin Contributions:
0

Re: Overrides not overriding

It is a local test site, so I can't show this live, unfortunately.

I've done so much testing today that I'm starting to loose track of my loose ends.

I will start again tomorrow and let you know if I notice anything unusual.

Thanks for replying, by the way.

28 Jan 2011, 4:00 AM
#4
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Overrides not overriding

The question is "What changes are you wanting to make?"

To do a proper Sidebox override requires three New files, not one. Then, within Tools > Layout Boxes Controller, you would turn OFF the default Information Sidebox and turn ON yours.

Download the Blank Sidebox module for a better understanding. Yes, it hasn't been updated in awhile but should still work just fine with any newer version of Zen Cart.

28 Jan 2011, 5:04 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

To do a proper Sidebox override requires three New files, not one.

That's not an override but a replacement. In many cases, one changed file will be sufficient to modify the function or appearance of an existing sidebox. If you want to make a completely new sidebox to take the place of the information sidebox, then you would need three new files.

28 Jan 2011, 8:52 AM
#6
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Overrides not overriding

Not sure of your point? An override "is" a replacement otherwise you are just changing core files; which we know can cause problems if not done right.

28 Jan 2011, 9:24 AM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

I guess my point is that you don't necessarily have to have new or override versions of all three of a sidebox's files to change its function or output, and suggesting that all three are necessary is misleading.
An overridden sidebox results in the original function being changed to the new version; a replacement sidebox (as you described) leaves the original still available if it was wanted for something.

28 Jan 2011, 4:24 PM
#8
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Overrides not overriding

I agree with what you are saying but it applies to changing a core file as opposed to using overrides. The title of this post is "Overrides not overriding" and there is a difference between, overrides and changing a core file.

That is why, the first thing I asked was; "The question is "What changes are you wanting to make?"

Until we hear back from the original poster we won't know which they are trying to do.

28 Jan 2011, 4:41 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

changing a core file as opposed to using overrides?? What core file? Did you think I was talking about editing say
/includes/modules/sideboxes/information.php as opposed to
/includes/modules/sideboxes/your_template/information.php?

Making a whole new sidebox is not an override, it's an addition, whether the files go in /your_template/ folders or the base locations (where they will be safe from upgrades because there is no corresponding core file to overwrite them).

Anyway, yes we need to get more info from the OP before being able to advise further.

28 Jan 2011, 6:30 PM
#10
joeyrocket avatar

joeyrocket

New Zenner

Join Date:
Jan 2011
Posts:
16
Plugin Contributions:
0

Re: Overrides not overriding

Wow! I didn't intend to spark this kind of debate, but I am pleased with the level of responsiveness on these boards.

What I am attempting to achieve: only show information sidebox to logged-in customers.

As it turns out it is somehow now working, and I have no idea what got it working. Perhaps it was just clearing cache or something stupid like that, but (to end the debate) all that needed to be overridden was the single file: includes/modules/sideboxes/information.php.

By the way, the tutorial in the FAQ which deals with sideboxes for logged in customers does not describe with any clarity how to do this for the information sidebox, which doesn't use any code resembling the sample code:

$show_featured= true;

What I did was replaced:

  require($template->get_template_dir('tpl_information.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_information.php');
 



  $title =  BOX_HEADING_INFORMATION;

  $title_link = false;



  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

with:

if (!$_SESSION['customer_id']) {
 
} else {
	
  require($template->get_template_dir('tpl_information.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_information.php');



  $title =  BOX_HEADING_INFORMATION;

  $title_link = false;



  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}

I don't even pretend to know from PHP, so if this is a weak or potentially disastrous solution, please let me know the better way to do it. Either way, I think other users should have access to a fix for this

28 Jan 2011, 6:45 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

That would be an effective solution, but it leaves the whole file to be processed before testing whether it is to be displayed. True, it's probably only a millisecond or so, but those add up...

The more efficient way would be to move the test to enclose the whole body of the file. Add your test above
unset($information);
and the
}
below the require as you have it.
You can simplify the test to just execute if logged in - no need in this case to provide an alternate execute path for not logged in.```php
if ($_SESSION['customer_id']) {

unset($information);

28 Jan 2011, 8:03 PM
#12
joeyrocket avatar

joeyrocket

New Zenner

Join Date:
Jan 2011
Posts:
16
Plugin Contributions:
0

Re: Overrides not overriding

Thank you. I mean that.

28 Jan 2011, 11:58 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Overrides not overriding

Glad to help.
And for anyone else reading this, if a sidebox does not have the

$show_xxxx = true;
if ($show_xxxx) {
//code
}
etc.

you can copy and adapt the code from a sidebox that does have it.