Maybe, but that is the best, but I'm just beginning to learn and have no idea how to adjust that.JAY6390 wrote:eek avoid <br/> 's all you can. Use a div instead around it. That should work
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
Code: Select all
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span>
<?php } else { ?>
<span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
<?php } ?>
Code: Select all
<?php if ($display_price) { ?>
<div style="display: block;">
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span>
<?php } else { ?>
<span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
My code was slightly different but I managed to get the div's in the right postition and now it looks OK.fido-x wrote:OK, here's an alternative. Instead of using the "<br />" as previously suggested, do this instead.
Last question; I want the Special Price on the Product page below the striked out "normal" price.
This because it looks better.
I've played around with the code but cannot get it below each other so I'm hoping on a last bit of help
Code: Select all
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td style="text-align: center; width: 250px; vertical-align: top;"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="thickbox" rel="gallery"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" style="margin-bottom: 3px;" /></a><br />
<span style="font-size: 11px;"><?php echo $text_enlarge; ?></span></td>
<td style="padding-left: 15px; width: 296px; vertical-align: top;"><table width="100%">
<?php if ($display_price) { ?>
<tr>
<td><b><?php echo $text_price; ?></b></td>
<td><?php if (!$special) { ?>
<div class="price"><?php echo $price; ?></div>
<?php } else { ?>
<div class="price"><span class="ifspecial"><?php echo $price; ?></span> <span class="special"><?php echo $special; ?></span></div>
<?php } ?></td>
</tr>
<?php } ?>
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><?php echo $stock; ?></td>
</tr>
<tr>
<td><b><?php echo $text_model; ?></b></td>
<td><?php echo $model; ?></td>
</tr>
<?php if ($manufacturer) { ?>
<tr>
<td><b><?php echo $text_manufacturer; ?></b></td>
<td><a href="<?php echo str_replace('&', '&', $manufacturers); ?>"><?php echo $manufacturer; ?></a></td>
</tr>
<?php } ?>
<?php if ($review_status) { ?>
<tr>
<td><b><?php echo $text_average; ?></b></td>
<td><?php if ($average) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $average . '.png'; ?>" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" />
<?php } else { ?>
<?php echo $text_no_rating; ?>
<?php } ?></td>
</tr>
<?php } ?>
</table>
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
I used the <div> in the wrong way, here's the correct code:
Code: Select all
<?php if ($display_price) { ?>
<tr>
<td><b><?php echo $text_price; ?></b></td>
<td><?php if (!$special) { ?>
<div class="price"><?php echo $price; ?></div>
<?php } else { ?>
<div class="price"><span class="ifspecial"><?php echo $price; ?></span></div> <div class="price"><span class="special"><?php echo $special; ?></span></div>
<?php } ?></td>
</tr>
<?php } ?>
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
campaign with images of stars, change products, free shipping, delivery, etc. immediately. Add pictures and comments as a way to use the system to cancel I think ..
Sample issues;
http://forum.opencart.com/viewtopic.php?f=21&t=18694
Hi, this works beautifully for me. I've added short descriptions to my related products on the product page. However, some of them the description just shows up as "..." without any description and some of them are showing up properly. Any idea why that might be?
Here is my array from my controller file.
Code: Select all
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'name' => $result['name'],
'description' => preg_replace('/[\r\n\s]+/', ' ', strip_tags(substr(html_entity_decode($result['description']),0,80)))."...",
'model' => $result['model'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'price' => $price,
'options' => $options,
'special' => $special,
'image' => $this->model_tool_image->resize($image, 38, 38),
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')),
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']),
'add' => $add
);
Code: Select all
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<?php if (isset($products[$j])) { ?>
<div class="product_related">
<a href="<?php echo str_replace('&', '&', $products[$j]['href']); ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" class="trigger" alt="<?php echo $products[$j]['name']; ?>" /></a>
<div class="popup">
<h4><?php echo $products[$j]['name']; ?></h4>
<?php echo $products[$j]['description']; ?>
</div>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
I have my descriptions set to popup with a little jquery and css. All of it works, minus random products not showing any description and just the "..." I've tried adjusting the product description in my admin panel so that there isn't any extra spaces or random code from the WYSIWYG editor. Thanks if anyone can provide any insight to this.
I had an exactly same problem. My PHP isn't maybe very good but I will try to explain how to make it work. I guess this happens because in your code:
Code: Select all
'description' => preg_replace('/[\r\n\s]+/', ' ', strip_tags(substr(html_entity_decode($result['description']),0,80)))."...",
1. full description is read from database
2. all the html tags are changed into their safe equivalents e.g.
Code: Select all
<p>
Code: Select all
<p>
3. this whole mess is than shortened to 80 elements
4. Eventually All the tags that remained in these 80 elements are thrown away
In some cases it may happen than you will end up having nothing left since tags took all these 80 elements.
My code looks like that:
Code: Select all
'description' => substr(strip_tags(html_entity_decode($result['description'])),0,180)."...",
I hope it will work for you
Go visit me at http://ChrisPlaneta.com
If you are a temaplate developer you might be interested in my nude Opencart theme - Cornerstone. It is available for download from this site http://chrisplaneta.com/freebies/corner ... art-theme/
1. Add this line to your category.php after $this->data['products'][] = array(
Code: Select all
'description' => $this->shortDesc($result['description']),
Code: Select all
private function shortDesc($string){
if(strpos($string,'<!--desc-->')!=false){
$descEnd = strpos($string,'<!--desc-->');
$shortDesc = html_entity_decode(substr($string, 0, $descEnd));
return $shortDesc;
}else{
return 'No description';
}
}
1. Go to your product page in the admin panel
2. Switch to HTML (code) view in the text editor
3. Insert this piece of code where you would like your description to end <!--desc-->
4. Save changes
Now short explanation what my code does.
1. The first line grabs the whole description and runs a function shortDesc() on it
2. This function looks in your whole text for <!--desc--> which is an equivalent of <!--desc-->
3. Now it assigns to $shortDesc value everything in your code until <!--desc--> and changes entities like > into html applicable
4. It returns the $shortDesc to the first function that in turn saves it as one of the values of a given product.
I hope you get it.
Feel free to improve my code.
Go visit me at http://ChrisPlaneta.com
If you are a temaplate developer you might be interested in my nude Opencart theme - Cornerstone. It is available for download from this site http://chrisplaneta.com/freebies/corner ... art-theme/
What file are your referring to?chrisplaneta wrote:
2. Paste the code below before line "private function getCategories($parent_id, $level = 0) {"Code: Select all
private function shortDesc($string){ if(strpos($string,'<!--desc-->')!=false){ $descEnd = strpos($string,'<!--desc-->'); $shortDesc = html_entity_decode(substr($string, 0, $descEnd)); return $shortDesc; }else{ return 'No description'; } }
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
I've tried everything. thanks
How to do the excerpt (cut the text string) without cutting words?
Here is my code, I hope It can help you!:
file affected:
yoursite/catalog/view/theme/default/template/product/category.tpl
Aproximate line: 80.
Search for: $product['description']; and delete it or comment it (//$product['description']
In the same line copy and paste this code:
Code: Select all
$thetext= substr($description,0,strrpos(substr($description,0,300)," "));
echo strip_tags($thetext);
I admire the valuable information you offered in your article. Excellent submission very good post.Keep posting thumbs up.
I know this is an ancient thread but I wanted to do this on a new site using v1.5.6
So I made a vqmod that you can download for free here:
http://the1path.com/opencart-themes-mod ... escription
Hope you find it useful!
OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods
If you have a description echo like this....
Code: Select all
<?php echo $product['description']; ?>
Code: Select all
<?php echo substr ($product['description'],0,100); ?>
Users browsing this forum: No registered users and 21 guests