Re: Featured / Special Offer / Latest Products
Posted: Mon Aug 18, 2008 8:59 pm
I wouldn't be the expert intermediate developer I am today without those 2 tools.
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Thanks for your sharing Bruce, i have been follow the code you provide. below is my home.php code,bruce wrote: I recently installed this contribution as follows and it works perfectly.
After following the installation instructions, I put the following (some surrounding code shown for positioning) into catalog\controller\home.php
and modified catalog\template\default\layout.tpl as followsCode: Select all
$template->set('content', $view->fetch('content/home.tpl')); $template->set($module->fetch()); $template->set('show_latest', true); $template->set('show_specials', true); $template->set('show_featured', true); $response->set($template->fetch('layout.tpl'));
So for example, $latest is set if the module is enabled and you only have to set $show_latest in the template of the controller(s) where you want to display the latest products.Code: Select all
<div id="content"> <?php if (isset($content)) echo $content; if (isset($latest) & isset($show_latest)) echo $latest; if (isset($featured) & isset($show_featured)) echo $featured; if (isset($specials) & isset($show_specials)) echo $specials; ?> </div>
Please note
- the code snippet as shown, would display them all on in the home page.
- the isset check on $content that was around the content div is moved inside the content div
- putting everything including $content inside the content div maintains a continuous line on the left side for the default template
Code: Select all
$view->set('products', $product_data);
$template->set('content', $view->fetch('content/home.tpl'));
$template->set($module->fetch());
$template->set('show_specials', true);
$template->set('show_featured', true);
$response->set($template->fetch('layout.tpl'));
}
}
?>
Code: Select all
<div id="column">
<?php if (isset($cart)) { ?>
<?php echo $cart; ?>
<?php } ?>
<?php if (isset($category)) { ?>
<?php echo $category; ?>
<?php } ?>
<?php if (isset($review)) { ?>
<?php echo $review; ?>
<?php } ?>
<?php if (isset($information)) { ?>
<?php echo $information; ?>
<?php } ?>
</div>
<div id="content">
<?php
if (isset($content)) echo $content;
if (isset($featured) & isset($show_featured)) echo $featured;
if (isset($specials) & isset($show_specials)) echo $specials;
?>
</div>
<?php if (isset($footer)) { ?>
<div id="footer"><?php echo $footer; ?></div>
<?php } ?>
</div>
<?php if (isset($time)) { ?>
<div id="time"><?php echo $time; ?></div>
<?php } ?>
</body>
</html>
Hi, Dave, i`m still not understand. Can you show me where should i fix it? Thank you.david.gilbert wrote: Looks to me like your missing the CSS to style it correctly.
-Dave
Hi, Dave & Bruce. I have been solve it myself, below is the code i modify. Really thanks to all of you, especially Bruce. I will try my best to help other member to solve the problem.david.gilbert wrote: Looks to me like your missing the CSS to style it correctly.
-Dave
Code: Select all
<p class="heading"><?php echo $heading_title; ?></p>
<?php if ($products) { ?>
<table style="width:100%;">
<?php foreach ($products as $product) { ?>
<tr class="products">
<td style="width:33.3%;"><a href="<?php echo $product['href']; ?>">
<img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>"
alt="<?php echo $product['name']; ?>" /></a></td>
<td><b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b> - <?php echo $product['desc']; ?></td>
<td><?php echo $product['price']; ?></td>
</tr>
<?php } ?>
</table>
<?php } else { ?>
<p><?php echo $text_notfound; ?></p>
<?php } ?>
Code: Select all
<p class="heading"><?php echo $heading_title; ?></p>
<?php if (isset($products)) { ?>
<?php foreach ($products as $product) { ?>
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a><br />
<b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b><br />
<?php echo $product['price']; ?></div>
<?php } ?>
<?php } else { ?>
<p><?php echo $text_notfound; ?></p>
<?php } ?>
Code: Select all
<!-- Initialize Counter -->
<?php $monkeycount = 0; ?>
<!-- Heading -->
<p class="heading"><?php echo $heading_title; ?></p>
<!-- Main containment table -->
<table style="width: 100%; text-align: center; padding: 0px">
<tr>
<td style="width: 50%">
<!-- Product table -->
<table style="width: 100%; text-align: center; padding: 0px">
<tr>
<?php if ($products) { ?>
<?php foreach ($products as $product) { ?>
<td style="width: 25%" valign="top">
<div class="products2">
<a href="<?php echo $product['href']; ?>">
<img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>">
</a><br />
<b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b><br />
<?php echo $product['price']; ?>
</div>
</td>
<!-- New row if statement -->
<?php $monkeycount = $monkeycount + 1; ?>
<?php if($monkeycount > 1) { ?>
</tr><tr>
<?php $monkeycount = 0; ?>
<?php } ?>
<?php } ?>
<?php } else { ?>
<p><?php echo $text_notfound; ?></p>
<?php } ?>
</tr>
</table>
</td>
<!-- Picture column -->
<td style="width: 75%; border-left: 1px solid #000000" valign="top">
<div style="text-align: center; width: 100%">
<img class="bigimage" src="/replace_imgagePATH/" width="90%" height="90%" alt=""/>
</div>
<br />
<div style="text-align: center; width: 100%">
<img class="bigimage" src="/replace_imgagePATH/" width="90%" height="90%" alt=""/>
</div>
</td>
</tr>
</table>
ptal wrote: Wow,
I got it working. It wasn't 'white-space:nowrap;' after all. It seemed that Firefox took the width as 33.3% from the .products in the default.css .
I added a new .featured in the default.css and changed the width to 100%; pointed the class ="featured" in the featured.php and firefox leaped with joy. This should probably be an update because it will affect any shopper who uses firefox for every store.
It now works like a charm.
Phil
Code: Select all
.products, .images, .categories {
float: left;
width: 33.3%;
text-align: center;
cursor: pointer;
font-size: 10px;
height: 140px;
}
.featured {
float: left;
width: 100%;
text-align: center;
cursor: pointer;
font-size: 10px;
height: 140px;
}
Code: Select all
.products, .images, .categories (line 220)
{
float: left;
width: 33.3%;
text-align: center;
cursor: pointer;
font-size: 10px;
height: 140px;
}
You may post links then because i couldn't find the answer browsing the forum...bruce wrote:
The answer to your second question has been answered many times on the forums. You only need to search.
It's located in file /catalog/language/english/extension/module/footer.phpI have found the footer.tpl but i would like to know where is located the "$text_powered_by" and being able to modify it. Thanks.