I am using OpenCart v 2.1.1.
In the admin area, the settings area indicates that the theme is set to Default.
On the server, I navigated to catalog -> view -> theme -> default -> template -> common
and opened up the header.tpl file for editing.
Inside the header.tpl file, I located line 115 which appears to be the last item
<li><?php echo $category['name']; ?></li>
Then on the next line I added in:
<li>Contact Us<li>
I Saved Changes, refreshed web page, and the Contact Us link does not appear in the blue menubar.
What have I done wrong..
you need to delete the cache of the template engine, else it won't update the cached template.
seems you add this line to the not correct place. you should add it before the last </ul> tag. this is 114 line in OC2.1 version.
<li>Contact Us<li>
</ul>
The last part of the header.tpl:
<?php if ($categories) { ?>
<div class="container">
<nav id="menu" class="navbar">
<div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<?php foreach ($categories as $category) { ?>
<?php if ($category['children']) { ?>
<li class="dropdown"><?php echo $category['name']; ?>
<div class="dropdown-menu">
<div class="dropdown-inner">
<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
<ul class="list-unstyled">
<?php foreach ($children as $child) { ?>
<li><?php echo $child['name']; ?></li>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php echo $text_all; ?> <?php echo $category['name']; ?> </div>
</li>
<?php } else { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
<?php } ?>
<li>Contact Us<li>
</ul>
</div>
</nav>
</div>
<?php } ?>
I have checked it works with default. Of course do not forget clear cache of your browser.
Related
I'm wondering if anyone can help, I have categories displaying on the left sidebar however it shows all the categories and subcategories. Is there any way to only display the subcategories of the active parent category and hide all the rest?
For instance, If I go to laptops / computers I only want it to show all those subcategories and not all the other categories like cameras etc...
I've tried looking for an extension but am unable to find anything, any advice would be appreciated!
Thanks
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<div class="box-category">
<ul>
<?php foreach ($categories as $category) { ?>
<li>
<?php if ($category['category_id'] == $category_id) { ?>
<?php echo $category['name']; ?><span>-</span>
<?php } else { ?>
<?php echo $category['name']; ?><span>+</span>
<?php } ?>
<?php if ($category['children']) { ?>
<ul>
<?php foreach ($category['children'] as $child) { ?>
<li>
<?php if ($child['category_id'] == $child_id) { ?>
- <?php echo $child['name']; ?>
<?php } else { ?>
- <?php echo $child['name']; ?>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
<script type="text/javascript"><!--
$(function(){
$('.box-category a > span').each(function(){
if (!$('+ ul', $(this).parent()).length) {
$(this).hide();
}
});
$('.box-category a > span').click(function(e){
e.preventDefault();
$('+ ul', $(this).parent()).slideToggle();
$(this).parent().toggleClass('active');
$(this).html($(this).parent().hasClass('active') ? "-" : "+");
return false;
});
$('.filter-active span').click();
});
//--></script>
Try to use alternative category module like CR2 SubCategory
I created a extra tab and custom design for related products in products page. I want to get product name,price and to add to cart,image in a loop. In related product tab check this url I am working on that http://efurnish.co.uk/index.php?route=product/product&path=86&product_id=58
<div class="product-related box">
<div class="box-heading"><span><?php echo $tab_related; ?> (<?php echo count($products); ?>)</span></div>
<div class="box-content products-block">
<?php foreach ($pr
oducts as $i => $product) { $i=$i+1; ?>
<?php if( $i%$cols == 1 && $cols > 1 ) { ?>
<div class="row product-related row-product">
<?php } ?>
<div class="col-lg-<?php echo $span;?>">
<div class="product-block">
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>"
title="<?php echo $product['name']; ?>"
alt="<?php echo $product['name']; ?>"/></a>
</div>
<?php } ?>
<div class="name"><?php echo $product['name']; ?></div>
<div class="group-item">
<?php if ($product['rating']) { ?>
<div class="rating"><img
src="catalog/view/theme/<?php echo $this->config->get('config_template');?>/image/stars-<?php echo $product['rating']; ?>.png"
alt="<?php echo $product['reviews']; ?>"/></div>
<?php } ?>
<div class="price-cart">
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span
class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
<div class="cart">
<input type="button" value="<?php echo $button_cart; ?>"
onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"/>
</div>
</div>
</div>
<span class="wishlist"><a class="icon-heart" onclick="addToWishList('<?php echo $product_id; ?>');" data-placement="top" data-toggle="tooltip" data-original-title="<?php echo $button_wishlist; ?>"><span><?php echo $button_wishlist; ?></a></span></span>
<span class="compare"><a class="icon-retweet" onclick="addToCompare('<?php echo $product_id; ?>');" data-placement="top" data-toggle="tooltip" data-original-title="<?php echo $button_compare; ?>"><span><?php echo $button_compare; ?></a></span></span>
</div>
</div>
<?php if( $cols > 1 && ($i%$cols == 0 || $i==count($products)) ) { ?>
</div>
<?php } ?>
I am using this design http://bootsnipp.com/snippets/featured/store-product-layout
There is an option for related products in the product form in the admin panel. You can add related product there to show in the product tab.
To Add Related Products to a product:
In OpenCart admin panel navigate to Catalog -> Products
Search for the product you would like to add related products. Click
Edit link to edit it.
Choose Link tab and scroll down until you see the "Related Products" field.
Start typing a product name in that field and OpenCart will drop
down a list of products that start with whatever letters you have
typed in.
Click on the product you want to add as a related product. You will
see it added to the box below.
Repeat step 4-5 for others product you want to add.
Click on save button
Related products will be added to your product page.
How do I add a link to the home page - "Home" - to the left hand side of the menu bar in OpenCart?
Thanks
edit catalog/view/theme/<YOUR_THEME>/template/common/header.tpl
Find:
<div id="menu">
<ul>
Add right below:
<li><?php echo $text_home; ?></li>
Even you can add your custom menus too in the top navigation bar
edit catalog/view/theme//template/common/header.tpl
Find:
<div id="menu">
<ul>
Then
<li>Menu_Text</li>
And also you can add the Pre-defined menu like Information, Customer Service etc..
Information menu
<?php foreach ($informations as $information) { ?>
<li>
<a href="<?php echo $information['href']; ?>">
<?php echo $information['title']; ?></a>
</li>
<?php } ?>
Service Menu
<li><?php echo $text_service; ?>
<ul>
<li><?php echo $text_contact; ?></li>
<li><?php echo $text_return; ?></li>
<li><?php echo $text_sitemap; ?></li>
</ul>
</li>
Extra Menu
<li><?php echo $text_extra; ?>
<ul>
<li><?php echo $text_manufacturer; ?></li>
<li><?php echo $text_voucher; ?></li>
<li><?php echo $text_affiliate; ?></li>
<li><?php echo $text_special; ?></li>
</ul>
</li>
Account Menu
<li><?php echo $text_account; ?>
<ul>
<li><?php echo $text_account; ?></li>
<li><?php echo $text_order; ?></li>
<li><?php echo $text_wishlist; ?></li>
<li><?php echo $text_newsletter; ?></li>
</ul>
</li>
The Above mentioned Pre-defined menus are working only in the footer area, to add this in top navigation you have to do some changes in header.php
Follow this Link
how to add Information Links in Navigation Menu in opencart?
Open Cart
Version 2.0.3.1
edit catalog/view/theme//template/common/header.tpl
Find
<ul class="nav navbar-nav">
And then under the above put
<li><?php echo $text_home; ?></li>
works a traet.
How do I insert only the pager in the bottom of product list?
At the top of the product list I want: "Sort by relevance/bestselers/etc" and the "Sort item by: Table/list", this I was able to do.
At the bottom of the product list I only want the pager, I've tried to insert the following code in list.phtml
<?php echo $this->getPagerHtml() ?>
but this php code doesn't work directly on the product list.
How can I make the pager work on the product list and appear at the bottom?
Hello you create new toolbar-bottom.phtml file with following code
i.e app/design/frontend/(base or default)/(default or yourtheme)/template/catalog/product/list/toolbar-bottom.phtml
<?php if ($this->getCollection()->getSize()): ?>
<div class="toolbar">
<div class="pager">
<p class="amount">
<?php if ($this->getLastPageNum() > 1): ?>
<?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
<?php else: ?>
<strong>
<?php echo $this->__('%s Item(s)', $this->getTotalNum()) ?>
</strong>
<?php endif; ?> </p>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($this->getAvailableLimit() as $_key => $_limit): ?>
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if ($this->isLimitCurrent($_key)): ?> selected="selected"
<?php endif ?>
<?php echo $_limit ?>
</option>
<?php endforeach; ?>
</select>
<?php echo $this->__('per page') ?> </div> <?php
echo
$this->getPagerHtml()
?>
</div>
</div>
<?php endif ?>
call into bottom of line in app/design/frontend/(base or default)/(default or yourtheme)/template/catalog/product/list.phtml
getToolbarBlock()->setTemplate('catalog/product/list/toolbar-bottom.phtml')->toHtml();
You can do this one of two ways.
1) Using CSS
<div class="category-products">
<div class='top-toolbar'><?php echo $this->getToolbarHtml() ?></div>
...
<div class='bottom-toolbar'><?php echo $this->getToolbarHtml() ?></div>
</div>
In css
.bottom-toolbar .xyz{
display:none;
}
2) Using a Custom module to overwrite getToolbarHtml and
$this->getToolbarHtml('top-toolbar');
$this->getToolbarHtml('bottom-toolbar');
public function getToolbarHtml($toolbar_position)
{
$this->toolbar_position = $toolbar_position;
return $this->getChildHtml('toolbar');
}
Then try to pass $this->toolbar_position to each block to show the section you need
I think this is what you want.
$toolbar = $this->getToolbarBlock();
$toolbar->setCollection($_productCollection);
if($toolbar->getCollection()->getSize() > 0):
echo $toolbar->getPagerHtml(); //Pager
echo $toolbar-> __('Items %s to %s of %s total', $toolbar->getFirstNum(), $toolbar->getLastNum(),
$toolbar ->getTotalNum());
endif;
font:
http://mayankpatel104.blogspot.com.br/2012/07/magento-pagination-without-toolbar.html
I'm trying to create a teaser node template to display all Blog teasers.
For the page tpl I have page-blogs.tpl.php
For the Blog node tpl I have node-blog.tpl.php (This one is looping to display all the blog teasers)
Now how do I create a node template to surround the node teasers?
My URL for the page with all the blog teasers is: /blogs/eric
My URL for the page with an example blog entry is: /blogs/eric/test-blog-1
I need a node template that I can use for all the Blog pages.
I tried using node-blogs-teaser.tpl.php for the individual teaser nodes and node-blog.tpl.php for the outer blog node template, but that didn't work.
Here is what I have in my node-blog.tpl.php file:
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<div class="item">
<ul>
<?php print $picture ?>
<?php if ($page == 0): ?>
<?php endif; ?>
<div class="content clear-block">
<li class="title"><h4><?php print $title ?></h4></li>
<li class="photo"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></li>
<li class="desc"><?php print $node->content['body']['#value']; ?></li>
<li class="link">
<?php if ($teaser): ?>
Read more | Audio/Video |
<?php endif; ?>
<?php print $submitted; ?>
</li>
<div class="clear"></div>
</div>
<div class="clear-block">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
</div>
</ul>
</div>
</div>
thanks
UPDATE: I added a page preprocessor function in template.php :
/**
* Override or insert PHPTemplate variables into the templates.
* These are the main outer templates such as page.tpl.php
*/
function phptemplate_preprocess_page(&$vars) {
// add template hints using path alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$vars['template_files'][] = $template_filename;
}
}
//----
}
Assuming your content type is called "blog", then node-blog.tpl.php will be used whenever a blog post needs to be displayed. The $teaser variable will be set to TRUE in node-blog.tpl.php if Drupal is wanting the teaser display, and the $page variable will be set to TRUE if the node is being shown in full page view (they will both be FALSE if the full node is being shown in a list of nodes). So you need to set up your node-blog.tpl.php to check for what type of display is being requested and return the HTML appropriate to the given type. The general setup of your node-blog.tpl.php should be along these lines:
if($teaser){
//return teaser html
}
else{
//return full node HTML
}
It's a little unclear to me from your question, but it sounds like you might have some sort of looping code in node-blog.tpl.php to iterate over the nodes on your site. You do NOT want to do this. Drupal does not work like Wordpress.
You don't mention how your list of teasers is being generated at /blogs/eric but I'd recommend using the Views module. If you use Views to generate the list of teasers then you'll be able to easily theme the list using Views' theming.
Edited since you added your example code
To stick arbitrary HTML at the top of ONLY the full node display of a blog page you could edit your node-blog.tpl.php to look something like this:
<?php if ($page): ?>
My arbitrary HTML here which will not show up in teasers and only at the top of full blog pages
<?php endif; ?>
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<div class="item">
<ul>
<?php print $picture ?>
<?php if ($page == 0): ?>
<?php endif; ?>
<div class="content clear-block">
<li class="title"><h4><?php print $title ?></h4></li>
<li class="photo"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></li>
<li class="desc"><?php print $node->content['body']['#value']; ?></li>
<li class="link">
<?php if ($teaser): ?>
Read more | Audio/Video |
<?php endif; ?>
<?php print $submitted; ?>
</li>
<div class="clear"></div>
</div>
<div class="clear-block">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
</div>
</ul>
</div>
</div>
Edited since finding out you're using the Blog module
To display arbitrary HTML at the top of the listing of blog teasers just stick it at the top of page-blog.tpl.php