You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
I'm trying to add a line break (<br/>) tag after each option in the shopping cart. I want each option selected to appear on its own line.
I found the code that I need to change, but I'm not having any luck getting it to recognize the tag.
The code that I found is under Home > ClickCartPro > Displays: Skins, Menus, XHTML Includes and Messages > Manage XHTML Includes > Shopping Cart/Wish List Display. The line that I'm trying to change is located in this section:
$xodisp = '';
foreach ($cartdata['optdisp'] as $oname => $ovalue) {
if (!(empty($ovalue))) {
$xodisp .= $oname . ': ' . $ovalue . '; ';
I want to add a <br/> tag to this line:
$xodisp .= $oname . ': ' . $ovalue . '; ';
so that it puts a line break after the option, like this:
$xodisp .= $oname . ': ' . $ovalue . '<br/> ';
but it converts the <br/> tag in the HTML code into this "& #60;br/& #62;" (without the space after the &) and it prints <br/> on the page.
How do I put a line break in?
Thank you for your help!
Offline
I have found the XHTML doesn't work with the paragraph tags xxxxxx<p>xxxxxx</p> will be xxxxxxxxxxxx. But if you use two line breaks xxxxxx<br><br>xxxxxx will give
xxxxxx
xxxxxx
I don't know why, but I have question. Why do you use <br/> instead of <br>?
Offline
<br/> is "self closing". XHTML requires it that way, at least for it to be valid XHTML.
Offline
Now certain validators issue warnings for this <br/> They want a space like this <br /> Supposed to be more backward compatible or something.
Offline
Yes, I've seen the <br... tag both ways. I normally use <br /> (with the space after the "r"), but I've seen so many people leave the space out recently that I thought maybe I was behind the times. Nonetheless, I'm not able to create a line break with either <br/> or <br />. I also tried adding an "end of line" ($eol) global at the end, but that just created line breaks when viewing the HTML code. It didn't create line breaks visually on the page. It was worth a try though.
Any ideas on how to make the <br /> tag work there would be greatly appreciated. ![]()
Offline
laura wrote:
Yes, I've seen the <br... tag both ways. I normally use <br /> (with the space after the "r"), but I've seen so many people leave the space out recently that I thought maybe I was behind the times. Nonetheless, I'm not able to create a line break with either <br/> or <br />. I also tried adding an "end of line" ($eol) global at the end, but that just created line breaks when viewing the HTML code. It didn't create line breaks visually on the page. It was worth a try though.
Any ideas on how to make the <br /> tag work there would be greatly appreciated.
That'll probably have to be inserted into the php script that handles that include. I don't have time to look for it right now, but I'm sure someone will be able to tell you. I know Nick will when he has a chance to catch his breath.
The space is a more relaxed xhtml which is supposed to allow it to be OK as xhtml or as html.
I don't know why I was questioning you above. I must have been sitting at this PC to long. ![]()
Last edited by grcauto (01-20-2007 17:22:05)
Offline
Valid XHTML is <br /> with the space, not <br/>. Not sure why - that's just the way the W3C wrote the spec.
Concerning the include editing above, you'll want to modify the code like this:
foreach ($cartdata['optdisp'] as $oname => $ovalue) {
if (!(empty($ovalue))) {
$xodisp .= $oname . ': ' . $ovalue . '; ';
} // End of if statement.
} // End of foreach statement.
if (preg_match('/\; $/',$xodisp)) {$xodisp = rtrim($xodisp,'; ');}
if (!(empty($xodisp))) {
$proddisp .= '<p>';
$proddisp .= $this->xhtml_encode($xodisp);
$proddisp .= '</p>';
} // End of if statement.Should become:
foreach ($cartdata['optdisp'] as $oname => $ovalue) {
if (!(empty($ovalue))) {
$xodisp .= $this->xhtml_encode($oname) . ': ' . $this->xhtml_encode($ovalue) . '<br /> ';
} // End of if statement.
} // End of foreach statement.
if (preg_match('/\<br \/\> $/',$xodisp)) {$xodisp = rtrim($xodisp,'<br /> ');}
if (!(empty($xodisp))) {
$proddisp .= '<p>';
$proddisp .= $xodisp;
$proddisp .= '</p>';
} // End of if statement.Offline
nick,
can this be made default or have the ability to turn it off or on??
james
Offline
Thank you Nick. The mod works great!
Now I'd love to be able to put styles in there too so that I can visually separate the Option's description from the customer's choice. Here's a few examples of requests that people have asked me about:
1.6 Ghz Intel Pentium 4
80 Gigabyte SCSI
or
1.6 Ghz Intel Pentium 4
80 Gigabyte SCSI
or
Is this possible?
Thank you!
Offline
Yes, that is possible. Just style this line:
$xodisp .= $this->xhtml_encode($oname) . ': ' . $this->xhtml_encode($ovalue) . '<br /> ';
Perhaps like this:
$xodisp .= '<strong>' . $this->xhtml_encode($oname) . '</strong>: ' . $this->xhtml_encode($ovalue) . '<br /> ';
Offline
Any ideas how to add the line breaks for product options shown on an invoice. The mod above only works with cart.
Offline
Hi Nick, thanks for the reply. I found the file but I can't see which exact section to mod, it doesn't have the same line as the one mentioned above. Any chance you could point to the exact section of the code. That would be really helpful, as I'm almost finished changing the site over to CCP6! Thanks!
Offline
Actually it is different. Sorry about that. Replace:
if (!(empty($item['itemopts']))) {
print '<p>' . $this->xhtml_encode($item['itemopts']) . '</p>';
} // End of if statement.With:
if (!(empty($item['itemopts']))) {
$item['itemopts'] = $this->xhtml_encode($item['itemopts']);
$item['itemopts'] = preg_replace('/\; /','<br />',$item['itemopts']);
print '<p>' . $item['itemopts'] . '</p>';
} // End of if statement.Offline
Thanks very much Nick, just what I needed, spent hours trying to mod it myself!
Offline
could anyone update this to have option line-breaks in the cart for the latest release? The code seems to have changed slightly.
Billy
Offline
actually..... it looks like it has been implemented! But it's still pretty messy due to have a small cart display width of 400px. How can I remove the text "Add to my reservation" shown on the same line of each option?
billy
Offline