Magento: No navbar - magento

I am new to Magento. I want to create a menu with different pages, but I don't have a navigation bar on top. How do I add a navigationbar?
This is my topmenu.phtml:
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-navbar-before')->toHtml() ?>
<?php echo $_menu ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-navbar-after')->toHtml() ?>
</ul>
</div>
<?php endif ?>
Here is the static block:
Still no navbar. The page.xml has these lines:
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml">
<block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
</block>
</block>
This should be a simple task. Anyone here with ideas?

you can also see the navigation menu bar into the navigation.php file
app\code\core\Mage\Catalog\Block\navigation.php
this file also need to display navigation menubar.
You should override the _getHtml() method in Mage_Page_Block_Html_Topmenu class.
Here are the steps:
create your app/code/local/Mage/Page/Block/Html/Topmenu/Custom.php
put inside class Mage_Page_Block_Html_Topmenu_Custom extends Mage_Page_Block_Html_Topmenu
copy the _getHtml() method from app/code/code/Mage/Page/Block/Html/Topmenu.php and customize it as needed
edit your app/design/frontend/your_theme/default/layout/page.xml and
replace <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/> with <block type="page/html_topmenu_custom" name="catalog.topnav" template="page/html/topmenu.phtml"/>

Related

How do I add the proceed to checkout button outside of the cart page using layout.xml?

I believe this is the code within a phtml file that creates the "Proceed to Checkout" button:
<?php if(!$this->hasError()): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
However when I add it to another phtml file that is a sibling to cart.phtml I get an error saying that an invalid argument is being supplied to the foreach.
I then tried adding the block:
<block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
<label>Payment Methods Before Checkout Button</label>
<block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
</block>
taken from the checkout.xml layout file, to my own block, adfter tht totals block:
<block type="page/html" name="checkout_process" as="checkout_process" template="page/html/checkout_process.phtml">
<block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
</block>
However this did nothing, am I missing something, I thought this would allow me to include the button?
Where did you place that code? Not all blocks are printed automaticly but need to printed with $this->getChildHtml('your_block') (see magento-layouts-blocks-and-templates).
Here is a minimal example for adding this button to right column, I placed it in local.xml layout file:
<layout version="0.1.0">
<default>
<reference name="right">
<block type="checkout/onepage_link" name="my.cart.button" template="checkout/onepage/link.phtml"/>
</reference>
</default>

Magento- add new menu item inside the module

currently I want to add a new menu link on the menu tab, but can it be done without changing other module template, but just add inside my module? The reason I want to do like this is because I hope when I disable my module the menu link also will be gone.
page.xml(other module layout file )
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
</block>
<block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
<label>Page Header</label>
<action method="setElementClass"><value>top-container</value></action>
</block>
</block>
referral.xml(my module)
???
What should I do?
topmenu.phtml
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<?php $active = is_numeric(stripos($_SERVER['REQUEST_URI'], 'aboutus')) ? 'active' : ''; ?>
<li class="level0 nav-2 last level-top <?php echo $active; ?>">
<a class="level-top" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>aboutus">
<span>About Us</span>
</a>
</li>
<?php echo $_menu ?>
<?php $active = is_numeric(stripos($_SERVER['REQUEST_URI'], 'redemption/store')) ? 'active' : ''; ?>
<li class="level0 nav-2 last level-top <?php echo $active; ?>">
<a class="level-top" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>redemption/store">
<span>Redemption Store</span>
</a>
</li>
That looks like a custom navigation to me, there's no way out of the box to add items to the main navigation (none category items anyway).
by default it will only show categories, so yours looks like it's probably hard coded into the template.
Having worked with a lot of modules and themes I would be VERY surprised if it's a custom theme with the added ability to add links through either XML config, or admin options.
can you post some code from your topmenu.phtml file for me and then I can adivse the best action for you.
for this you have to write Navigation class in your custom module that will extends Mage_Catalog_Block_Navigation in that class is a function (renderCategoriesMenuHtml) that you need to override in your local navigation class.
but the problem is, in real time users mostly have different themes and they change classes etc this can conflict in design implementation.

Moving Magento Advanced Search Link From Footer To Beneath Search Bar

I'm trying to move magentos advanced search link from the footer links right beneath the search bar.
I know that the origins of the link are in layout/catalogsearch.xml under
reference name="footer_links" and appear in the footer because of getChildHtml('footer_links') in footer.phtml
And i know that the search bar originates from template/catalogsearch/form.mini.phtml and appears though catalogsearch.xml under reference name="top.menu"
Any ideas on how to proceed here?
thank you for the quick answer!
But it is not exactly what I was looking for as it would display the entire footer links block beneath the searchbar.
Nevertheless thank you for showing me the method you used for that!
Anyways, I figured out a solution on my own:
I modified catalogsearch.xml:
<default>
<reference name="top.menu">
<block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
</reference>
<!-- add a new reference to top.search including my new adv.search block -->
<reference name="top.search">
<block type="page/template_links" name="adv.search" as="adv.search" >
<action method="addLink" translate="label title" module="catalogsearch">
<label>Advanced Search</label>
<url helper="catalogsearch/getAdvancedSearchUrl" />
<title>Advanced Search</title>
</action>
</block>
</reference>
<!-- the reference to the footer i commented out as its not longer needed; it includes advanced search and popular search terms-->
</default>
In form.mini.phtml I added a new div that calls adv.search:
</script>
<div class="adv-search"> <?php echo $this->getChildHtml('adv.search') ?> </div>
</div>
And last, in styles.css, I added some code to controll the looks of that div:
.adv-search {width:100px; height:15px; margin-top:24px; margin-left: 120px;}
.adv-search a { color:#fff; font-weight:bold; }
any additional advice is more than welcome
Cheers!
In order for this to work, you must:
1) Update your app/design/frontend/[yourtheme]/default/layout/local.xml file
2) Call the new blocks in app/design/frontend/[yourtheme]/default/template/page/html/header.phtml - this is needed because header.phtml is not a "core/text_list" block type which automatically renders its nested blocks. So we must explicitly tell Magento to render those child blocks
Your app/design/frontend/[yourtheme]/default/layout/local.xml should contain this:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="header">
<!-- Insert cms links. No need to use <action method="insert"> as this block is not used elsewhere in layout -->
<block type="cms/block" name="top_links_cms" as="top_links_cms" before="top_links_other">
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
<!-- Insert former footer links. -->
<action method="insert">
<!-- We must keep block name "footer_links" as it is used as a reference for adding links by other modules -->
<blockName>footer_links</blockName>
<!-- Name of the block we want to have as sibling (in order to get its position and place our block after it. See next node <after> -->
<siblingName>topSearch</siblingName>
<!-- $after param from Mage_Core_Block_Abstract::insert() is a boolean type, so its value in the XML node is [empty], 0 or 1 -->
<after>1</after>
<alias>top_links_other</alias>
</action>
</reference>
<reference name="footer">
<action method="unsetChild"><name>footer_links</name></action>
<action method="unsetChild"><name>cms_footer_links</name></action>
</reference>
</default>
</layout>
This is an updated header.phtml you can get inspiration from for your app/design/frontend/[yourtheme]/default/template/page/html/header.phtml file:
<div class="header-container">
<div class="header">
<?php if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></h1>
<?php else:?>
<strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" />
<?php endif?>
<div class="quick-access">
<?php echo $this->getChildHtml('topSearch') ?>
<?php
/**
* Add other top links (footer and cms links)
*/
?>
<?php echo $this->getChildHtml('top_links_cms') ?>
<?php echo $this->getChildHtml('top_links_other') ?>
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
</div>
<?php echo $this->getChildHtml('topContainer'); ?>
</div>
</div>
<?php echo $this->getChildHtml('topMenu') ?>

Magento: Move product filters

As default, the available product filters are displayed in the left sidebar. But I'd like to display them above the product list instead.
I simply tried to just copy the following code from /template/catalog/layer/view.phtml to /template/catalog/product/list.phtml:
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
But apparently it doesn't work that way. How should I do?
Thank you in advance!
You need to make the block (a php class) which uses the filters template a child of the class where you wish to include those filters. This is done in layout XML.
In a local.xml file in your theme's layout folder, do the following:
<?xml version="1.0" ?>
<layout>
<catalog_category_layered>
<!-- remove from left block -->
<reference name="left">
<action method="unsetChild">
<child>catalog.leftnav</child>
</action>
</reference>
<!-- add as child to product list block -->
<reference name="product_list">
<action method="insert">
<child>catalog.leftnav</child>
</action>
</reference>
</catalog_category_layered>
</layout>
using the above, you can simply call <?php echo $this->getChildHtml('catalog.leftnav') ?> inside your custom list template for it to show. You can either style it using CSS, or you can change its template by adding this inside the catalog_category_layered node above:
<reference name="catalog.leftnav">
<action method="setTemplate">
<child>path/to/template.phtml</child>
</action>
</reference>

Exact Placement of childHtml Block (unexpected result)

I am trying to place a new phtml block at a specific place within another phtml page and I am not getting the results I expected - any advice would be much appreciated.
Specifically, I created a new childHtml block for the cart page in my module's xml layout file:
<layout version="0.1.0">
<checkout_cart_index>
<reference name="head">
<action method="addJs"><script>varien/product.js</script></action>
<action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
</reference>
<reference name="content">
<block type="delivery/frontend_checkout_cart_delivery" name="delivery.container" as="delivery" template="unleaded/delivery/checkout/cart/shipping/delivery.phtml"/>
<block type="core/html_calendar" name="delivery_html_calendar" as="delivery_html_calendar" template="page/js/calendar.phtml"/>
</reference>
</checkout_cart_index>
</layout>
Next I made a call to $this->getChildHtml('delivery') in my modified checkout/cart/shipping.phtml template where I wanted it placed:
....
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
....
<?php foreach ($_rates as $_rate): ?>
....
<li>
<?php if ($_rate->getCode() == 'delivery'): ?>
<?php echo $this->getChildHtml('delivery'); ?>
<?php endif; ?>
</li>
....
<?php endforeach; ?>
....
<?php endforeach; ?>
....
What I wanted / expected was to see my block output where I inserted it, but instead it is being output at the very bottom of the page (see screenshot). I am almost certain my mistake is an xml / layout based mistake, but I don't know what?
You call getChildHtml() from within the checkout.cart.shipping block, but add your new block to content. Instead of,
<reference name="content">
...you simply need to say which block your new one will be the child of.
<reference name="checkout.cart.shipping">

Resources