Magento how to show menus in top menu - magento

I am really newbie to Magento. I have this piece of code to show top menus.
<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<div class="nav-container">
<ul id="nav">
<li class="level0 first homelink"><span><?php echo $this->__('Home') ?></span></li>
<?php if($_menu): ?>
<?php echo $_menu ?>
<?php endif ?>
<?php $additionalLink = themeOptions('additionalLink'); ?>
<?php $additionalLinkUrl = themeOptions('additionalLinkUrl'); ?>
<?php if($additionalLinkUrl && $additionalLink): ?>
<li class="level0 clearence"><span><?php echo $additionalLink ?></span></li>
<?php endif ?>
</ul>
</div>
Now this is showing only Home as menu. I want to show other menus like about us,contacts,
and there will be also some categories with sub categories. I want my menu should look like this
http://8theme.com/demo/decostore/ . So can someone kindly tell me how to do this? Any help and suggestions will be really appreciable. Thanks

Here you have use the Top Menu (already created) in theme Folder /template/page/html/topMenu.phtml file
here includes the Categories and also the Custome url set using with blocks

Related

Left sidebar category navigation disappearing on last level category pages in Magento

On the lowest category levels, my sidebar is disappearing in Magento. Anchor is set to no for all my categories. Ultimately I want to display all main categories on sidebar (obviously on every product page) and the sub categories when inside a main category.
Not sure what the issue is. Pretty much base magento code with some style changes. Any help is much appreciated!
<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<aside id="sidebar">
<div class="sidebar-nav">
<h2><?php echo $this->__('Products') ?></h2>
<ul>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)
</li>
<?php endif; ?>
<?php endforeach ?>
</ul>
</div>
<div class="sidebar-nav">
<h2 class="red">Holiday</h2>
<ul>
<li>Christmas</li>
<li>Halloween</li>
<li>Thanksgiving</li>
<li>Easter</li>
<li>4th of July</li>
<li>Valentine's Day</li>
</ul>
</div>
<div class="sidebar-nav">
<h2>About Us</h2>
<ul>
<li>About Mary</li>
<li>Press</li>
<li>Licensing</li>
<li>Shows</li>
<li>Custom Work</li>
<li>Contact Us</li>
<li>Privacy Policy</li>
<li>Terms & Conditions</li>
</ul>
</div>
<script type="text/javascript">decorateDataList('narrow-by-list2')</script>
<?php endif; ?>
</aside>
They are disappearing on your lowest categories because your code is using:
<?php $_categories = $this->getCurrentChildCategories() ?>
If your current category (the category are you currently viewing) has no child categories, the block will not display any categories (because getCurrentChildCategories() returns the child categories of the current category).
The left categories will behave differently depending on whether the Is Anchor is set to Yes or No.
Category is set to Is Anchor: Yes
-The left categories will function as a filter, instead of a direct navigation link. When you click on a category on the left, you will remain in the same category you were viewing, however the results on the page will be filtered to the selected category.
Category is set to Is Anchor: No
-The left categories will function as a menu. When a category is selected, the user will be taken to that actual category page. If the category page they navigate to has no subcategories, no categories will appear on the left.
So in your case, you can set your upper level categories to Is Anchor: Yes and the lowest categories will act as filters instead of menu links.
If you want people to navigate to the lowest level subcategories, you will have to modify the functions the template uses to pull the categories from the parent category. There are several articles on StackOverflow already detailing how to do this.

Magento get categories and list in navigation in .phtml file

Ok so I've copied and pasted like 10 inserts already for php code to list the main categories or the sub categories under the Default root category.
None of them are displaying my categories and I have all my categories as root categories AND sub-categories under the Default root category to see if both scenarios will work..
Here is my php code I have in my theme .phtml file (1-column so far)
<?php $_categories = Mage::helper('catalog/category')->getStoreCategories(); ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
I know I have them setup right in the admin panel because I have them both as root and subcategories which shouldn't be necessary of course. I'm just trying everything to get them to display and nothing seems to be working..
Anyone know?
EDIT
Ok I found it in topmenu.phtml in the html directory under the template directory in the page directory:
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
Where is the getHtml('level-top') code at so I can alter the markup of the li elements?
For change markup, you need rewrite protected _getHtml method in Mage_Page_Block_Html_Topmenu class

Magento list of brand names on cms page

This should be simple to achieve but since I'm a mage noob ((( I cant seem to get this to work.
I basically have category with all brands and what I'd like to do is to display brand names and links (without images) on the separate CMS page (brands).
Thanks.
Assuming the category you created has sub categories that are the brands, replace x with the id of your shop by brand category.
<?php
$brands = Mage::getModel('catalog/category')->load(x)->getChildrenCategories();
?>
<?php foreach($brands as $brand): ?>
<ul>
<li>
<a href="<?php echo $brand->getUrl() ?>">
<?php echo htmlspecialchars($brand->getName()) ?>
</a>
</li>
</ul>
<?php endforeach ?>

magento show tab if content exists

i'm using the tab.phtml from the modern theme to create product tabs, however i've switched this to using jquery and jquery-ui as i needed to link to a tab directly.
So in a nut shell the code is pretty much the same as the one found in the modern theme.
<div id="tabs">
<ul>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])): ?>
<li class="<?php echo !$_index?' active first':(($_index==count($this->getTabs())-1)?' last':'')?>"><?php echo $_tab['title']?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clearer"></div>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])): ?>
<div class="product-tabs-content" id="<?php echo $_tab['alias'] ?>"><?php echo $this->getChildHtml($_tab['alias']) ?></div>
<?php endif; ?>
<?php endforeach; ?>
</div>
and i'm adding the custom tabs using the same method under catalog.xml:
<action method="addTab" translate="title" module="catalog"><alias>how-to-use</alias><title>How to Use</title><block>catalog/product_view</block><template>catalog/product/view/how-to-use.phtml</template></action>
however i've noticed that the tab 'upsells' only appears when there are upsell products assigned. I'm wanting to use this same functionality to display a custom product attribute if there is content to display.
So what i'm asking is how does the upsell detect that there are no products assigned so no tab is displayed so i can do this for my custom tab. my custom tab phtml file looks like this:
<?php $_howtouse = $this->getProduct()->getHowToUse(); ?>
<?php if ($_howtouse): ?>
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_howtouse, 'howtouse') ?>
</div>
any help greaty received thanks :)
The first line of code in upsell.phtml controls the appearance:
<?php if(count($this->getItemCollection()->getItems())): ?>
I am speculating your code is simply evaluating to true and always showing that section. What is your output from $this->getProduct()->getHowToUse() ?
It turned out i had 1 line above my:
<?php $_howtouse = $this->getProduct()->getHowToUse(); ?>
which meant it registered as there being some content all be it white space.
got rid of the whitespace it now works.

Magento Add url link to open a specific product tab

Magento 1.7.0.0
ok i'm using the product tabs that are available in the modern theme. I've added a custom tab to add reviews as a tab [sucess].
Now where it says:
'Be the first to review this product'
i want this link to go to the tab on that page and not go off to the reviews page.
i realise i need to some javascript but it's just i can't work out how to call a tab.
any ideas?
thanks.
Andy.
if you already using jQuery... you could just simply "hack" it out like this
jQuery(document).ready(function($){
$("#addreview").attr("href", "#review-form");
$("#addreview").click(function(){
$(".product-tabs").children("li").removeClass("active");
$("#product_tabs_reviews").addClass("active");
$(".product-tabs-content").css("display", "none");
$("#product_tabs_reviews_contents").css("display", "block");
});
});
be aware to change the selector according to your own markup
My code looks like this in tabs.phtml:
<div id="tabs">
<ul>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])): ?>
<li class="<?php echo !$_index?' active first':(($_index==count($this->getTabs())-1)?' last':'')?>"><?php echo $_tab['title']?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clearer"></div>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
<?php if($this->getChildHtml($_tab['alias'])): ?>
<div class="product-tabs-content" id="<?php echo $_tab['alias'] ?>"><?php echo $this->getChildHtml($_tab['alias']) ?></div>
<?php endif; ?>
<?php endforeach; ?>
</div>
and then adding:
jquery-ui-tabs.js and the relevant .css

Resources