Forums / Bug Reports / [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

[DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Locked

Started by kuroi on 22 May 2006, 12:24 AM · Views: 3,663

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
22 May 2006, 12:24 AM
#1
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

[DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

It would appear that the content generated by the tpl_shopping_cart.php sidebox file is missing its final </div>. As a result the div for the shopping cart box erroneously wraps around all the sideboxes boxes below it. The solution is to add ```php
$content .= '</div>';

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

22 May 2006, 12:39 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,691
Plugin Contributions:
0

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Kuroi-

is there already a closing </div> one line 61 of that file?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

22 May 2006, 1:10 AM
#3
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Kim:

Kuroi-

is there already a closing </div> one line 61 of that file?

Sorry I didn't make this as clear as I should have. There are two divs needing to be closed. One opened on line 14 and one on line 15. I tend to like to be able to nest them neatly, hence the suggestion that would have led to two identical, adjacent statements, but it would have been clearer (and more efficient) if I'd suggested amending the line to ```php
$content .= '</div></div>';

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

22 May 2006, 1:15 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

I'd hold off on the changes for a few ...

I think you are correct that there is something off ... but ... there are several IFs in there that may also be confusing the issue ... :blink:

Give us a bit to look at what we think we wrote when we thought we wrote it perfectly right the first dozen times ... :eek:

Thanks for the heads up that something might be askew here ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 May 2006, 12:10 PM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Ajeh:

I think you are correct that there is something off ... but ... there are several IFs in there that may also be confusing the issue ...
You're right. The IFs do confuse the issue. More so than I originally thought when I skimmed the code.

As I result, it now appears to me that although there are the right number of opening and closures of divs, the IFs mean that they don't match up in all circumstances.

Specifically, it seems that the Content div is only opened (line 14) if there is something in the cart and only closed (line 61) if the customer is logged on.

This allows two potential problems1. customer puts something in the cart before logging on, opening the div, but not closing it.
2. the customer is logged on but with nothing in the cart, resulting in a superfluous div closing tag

Number 1 is the reported bug and exists. It can be easily reproduced though would not normally be visually obvious. The specific circumstances that highlighted it were the adding of vertically repeating background image to this div that then proceeded to continue downwards to all lower boxes. I could replicate this on a publically visible site if you would find this helpful.

Number 2 I suspect is theoretical rather than actual, as I don't believe that this template is invoked if the cart is empty, and if it were to happen, then it is possible that a parent div would be prematurely closed with very obvious results. However, I'm not certain as I haven't tracked down where it is supressed and this would imply that the first IF/ELSE statement and the code in the ELSE part of it are redundant.

A possible solution, which appears to fix problem 1 with no side effects is to move the opening div to before the IF statement and the closing tag to after the last IF. I attach a zip of the Attachment #80 that I have tested successfully.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

22 May 2006, 5:33 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Solution:

  1. Swap lines 13 and 14
  2. change $content = to $content .= on line 42
  3. swap lines 61 & 62.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 May 2006, 4:59 AM
#7
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Looks like I need to read this forum more often.

Thanks Kuroi and DrByte.

Woody

--

P.S. I dislike line number edit directions. If I have ever customized the file in question I am completely out of luck, unless I remember exactly what I previously customized, or I somehow I can comprehend my own comments of my past edits. Neither is rarely the case. ;-)

26 May 2006, 7:26 AM
#8
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Ok for slow people like me...

Solution.
Edit /sideboxes/tpl_shopping_cart.php

  1. Swap lines 13 and 14.

So should be:

$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
if ($_SESSION['cart']->count_contents() > 0) {

  1. Change $content = to $content .= on line 42

So should be:

$content .= '<div class="sideBoxContent center bold">' . BOX_SHOPPING_CART_EMPTY . '</div>';
  1. Swap lines 61 & 62.

So last four lines of file should be:

}

}
$content .= '</div>';
?>

4 Jun 2006, 7:16 PM
#9
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Until now this has seemed like an amusing little bug that causes some odd cosmetic effects revealed only to those using the background graphic techniques such as used in the future Zen template.

However, here's an example where somebody doing something completely different has their layout completely trashed when a customer puts something in their shopping cart without logging in first. The difference is that this time the shopping cart sidebox is on the left and the layout table has been removed, so the missing </div> has a catastophic effect on the positioning of the central area.

As I suspect we'll see this problem again before the next Zen Cart delivery, I'm posting a zip file >> Attachment #159 << here with the corrected file here as the reference point for any future instances of this bug.

Although this will hopefully be corrected in future deliveries of Zen Cart, I recommend playing safe by placing the corrected version of the file in your ncludes/templates/YOUR_TEMPLATE_NAME/sideboxes/ directory (creating one if you don't already have it).

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

15 Aug 2006, 11:13 AM
#10
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Re: [DONE 1.3.5] Missing </div> in tpl_shopping_cart.php

Thank you for this - I was one of those that it screwed my display up royally :D:D but all sorted, I found the missing div but wasn't totally sure which file to edit

:)