I've just installed OpenCart for the first time, deleted all the dummy products and categories it comes with and added my own. However, now nothing appears in my menu - no product categories. I can't seem to fine where to add items to menus.
Can anyone point me in the right direction? Thanks
UPDATE:
THis is the php in my header tpl file:
?php if ($categories) { ?>
<div id="menu">
<ul>
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?>
<?php if ($category['children']) { ?>
<div>
<?php for ($i = 0; $i < count($category['children']);) { ?>
<ul>
<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($category['children'][$i])) { ?>
<li><?php echo $category['children'][$i]['name']; ?></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
I have not acutally changed any of it from the original
Create a new parent category and sub categories in Catalog->Category->insert then add the new product Catalog->product->insert. Product should be appear in frond end. for more details see this video tutorials : http://www.opencart.com/index.php?route=documentation/screencast
Related
I want to Show Multilevel Dropdown menu in opencart 2.0 category module
Menu>submenu>submenu1>submenulevel2>level3>
Can you please explain if you want this in the Admin area or the customer front end?
In which case in category.tpl just modify or write something like this:
<?php if ($categories) { ?>
<?php if (count($categories) <= 5) { ?>
<div class="col-sm-3 nosidepadding">
<ul>
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
</ul>
</div>
<?php } else { ?>
<?php foreach (array_chunk($categories, ceil(count($categories) / 4)) as $categories) { ?>
<div class="col-sm-3 nosidepadding">
<ul>
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
I am trying to figure out how can I show subcategories for selected parent category in search.php. I have code which shows subcategories of all categories, but how can I modify this code to show subcategories for only selected category?
this is my code:
<?php while(osc_has_categories()) { ?>
<?php if(osc_count_subcategories() > 0) { ?>
<ul>
<?php while(osc_has_subcategories()) { ?>
<li>
<strong><?php echo osc_category_name(); ?></strong></label>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
thank you
When in a loop while(osc_has_categories()), it allows you to use osc_category_* helpers.
You could do something like:
<?php while(osc_has_categories()) { ?>
<?php if(osc_category_id() === 98): ?>
<?php if(osc_count_subcategories() > 0) { ?>
<ul>
<?php while(osc_has_subcategories()) { ?>
<li>
<strong><?php echo osc_category_name(); ?></strong>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php endif; ?>
<?php } ?>
The code
<div class="box">
<?php foreach ($categories as $category) { ?>
<li>
<?php if ($category['category_id'] == $category_id) { ?>
<?php echo $category['name']; ?>
<?php } else { ?>
<?php echo $category['name']; ?>
<?php } ?>
<?php if ($category['children']) { ?>
I need to change the way how a concrete menu item is rendered, let's say for a category with ID 73. How can I do this in the above template?
I'm using OpenCart and I'm trying to achieve rendering out the meta_description (used to identify the comic publisher) and use it to make a drop-down list with sub-categories, or to give the illusion of it. Here is my code now, it's an adopted version of the current OpenCart code. ['class'] is how I grab the child categories meta_description.
Basically, the second for statement doesn't work - it only does the first one. I would appreciated any kind of support on this.
<div class="menu">
<div id="top"></div>
<span>
<ul id="nav">
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?>
<?php if ($category['children']) { ?>
<div class="subs">
<div>
<?php for ($i = 0; $i < count($category['children']);) { ?>
<ul>
<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
<h3>DC Comics</h3>
<?php for (; $i < $j; $i++) { ?>
<?php if($category['children'][$i]['class'] == "DC Comics"){ ?>
<li>
<ul>
<?php if (isset($category['children'][$i])) { ?>
<li><?php echo $category['children'][$i]['name']; ?></li>
<?php } ?>
</ul>
</li>
<?php } ?>
<?php } ?>
<h3>Marvel</h3>
<?php for (; $i < $j; $i++) { ?>
<?php if($category['children'][$i]['class'] == "Marvel"){ ?>
<li>
<ul>
<?php if (isset($category['children'][$i])) { ?>
<li><?php echo $category['children'][$i]['name']; ?></li>
<?php } ?>
</ul>
</li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
</div>
</div>
<?php } ?>
</li>
<?php } ?>
</ul>
</span>
</div>
Use different variables in loops, in you code $i is used in main loop and incremented in inner loops you can use foreach loop like ,
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?>
<?php if (is_array($category['children']) and isset($category['children'])) { ?>
<div class="subs">
<div>
<ul>
<?php
$li1='<li><h3>DC Comics</h3><ul>';
$li2='<li><h3>Marvel</h3><ul>';
foreach($category['children'] as $child)
{
if($child['class'] == "DC Comics")
{
$li1.='<li>'.$child['name'].'</li>';
}
if($child['class'] == "Marvel")
{
$li2.='<li>'.$child['name'].'</li>';
}
}
$li1.='</ul></li>';
$li2.='</ul></li>';
echo $li1;
echo $li2;
?>
</ul>
</div>
</div>
<?php } ?>
</li>
<?php } ?>
I am beginner in open-cart.I currently working in web2print extension in open-cart.I need to create categories and sub categories in left side.I already display categories menu in left side via admin panel,but i need to create display categories and sub-categories in left side bar with similar manner.
<div class="box clsLeft_menu">
<div class="box-heading">Some of our specialties:</div>
<div class="box-content">
<ul class="box-category">
<?php foreach ($categories as $category) { ?>
<li>
<?php if ($category['category_id'] == $category_id) { ?>
<?php echo $category['name']; ?>
<?php } else { ?>
<?php echo $category['name']; ?>
<?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>
I want to display categories and sub-categories in opencart.
example:
--main categories
--sub 1
--sub 2
--sub 3
--main categories
--sub 1
--sub 2
how to solve it ?Please guide me...
Search for vertical accordion menu. There are plenty of plugins available, though not directly for opencart, can be easily added.
Couple of example:
http://visionwidget.com/jquery-accordion-slider-menu.html
http://www.designchemical.com/blog/index.php/jquery/jquery-tutorial-create-a-jquery-menu-slider/