Magento Select Categories inseide a categorie - magento

I have severall products that belong to multiple categories.
What i need is some kind of layered navigation like this
I have this kind of category tree:
CAT A
*Cat a1
*Cat a2
CAT B
*Cat b1
*Cat b2
CAT A its Brands, and CAT B is type of product.
In catalog when i go to Cat b1, i want to add a filter so it shows all the brands of the products. So the filter as Cat a1 and Cat a2, and if i filter Cat a1 it will only show products from Cat b1 that belong to Cat a1.
What i mean, is a intersection of both categories, and it will allways display like in layered navigation.
Every time i enter a category, it must display the categories that the products inside of it also belongs to.
design/frontend///catalog/layer/view.phtml
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
</div>
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if($this->canShowOptions()): ?>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php $counter=1; foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<span>
<dt id="filter_heading"><?php echo $this->__($_filter->getName()) ?><span class="toggleBtn highlight" id="toggleBtn<?php echo $counter; ?>"></span></dt>
<dd id="filter_content<?php echo $counter; ?>" style="display:block;"><?php echo $_filter->getHtml() ?></dd>
<script type="text/javascript">
jQuery('#toggleBtn<?php echo $counter; ?>').click(function() {
jQuery('#filter_content<?php echo $counter; ?>').slideToggle('slow');
jQuery(this).toggleClass("highlight");
});
</script>
</span>
<?php endif; $counter++; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
Theme catalog.xml
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="catalog.magicat" template="catalog/layer/view.phtml"/>
</reference>
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<!-- <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/su.phtml</template></action> -->
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
<!-- The following code shows how to set your own pager increments -->
<!--
<action method="setDefaultListPerPage"><limit>10</limit></action>
<action method="setDefaultGridPerPage"><limit>8</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
<action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
<action method="addPagerLimit"><mode>grid</mode><limit>8</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>16</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
<action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
-->
</block>
<!--action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action-->
<action method="setColumnCount"><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
</reference>
</catalog_category_layered>
Any help appreciatted.

Related

Magento 1.9 breadcrumbs always empty

I'm working on a magento ecommerce, I'm not the one who configured it or anything, I'm just doing his CSS, however, the site does not display the breadcrumbs.
Inside the "page / html / breadcrumbs.phtml" file I made a var_dump in the $ crumbs variable and it is always empty.
In the XML only in one situation the breadcrumbs is displayed in the frontend, when I enter the code inside the "default" tag if I put this code inside "customer_account_login" nothing will be displayed on the front.
Code of breadcrumbs.phtml:
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Here part of code of "customer.xml"
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<!-- Mage_Customer -->
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</reference>
<!-- HERE BREADCRUMBS DISPLAYS ON ALL PAGES THE SAME CONTENT "HOME / MY ACCOUNT" -->
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>My Account</crumbName>
<crumbInfo><label>My Account</label><title>My Account</title><link>/customer/account/</link></crumbInfo>
</action>
</reference>
</default>
<!-- Load this update on every page when customer is logged in -->
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
</reference>
</customer_logged_in>
<!-- Load this update on every page when customer is logged out -->
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
</reference>
<remove name="reorder"></remove>
</customer_logged_out>
<!-- Layout for customer login page -->
<customer_account_login translate="label">
<label>Customer Account Login Form</label>
<!-- Mage_Customer -->
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml" />
</reference>
</customer_account_login>
If I move the breadcrumbs code from "< default >" to the "< customer_account_login translate="label" >" for example, all screens returns the breadcrumbs as null.
I have no idea what's going on. I just wish all the screens had their breadcrumbs being displayed.
Check that breadcrumbs are actually enabled in the back end admin panel like below.

Magento: No navbar

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"/>

Moving toplinks to another block in Magento

I'm trying to move the toplinks to a static block that I created above the header. Currently, I'm only getting the "Log Out" link instead of all of the top links (My Account, My Wishlist, My Cart, and Checkout). How can I get all these links into the static block?
2columns-right.phtml
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<div><?php echo $this->getChildHtml('newreference') ?></div>
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col2-right-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('global_cookie_notice') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
newReference.phtml
<p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
<div class="quick-access">
<?php echo $this->getChildHtml('topLinks') ?>
</div>
local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="newreference" as="newreference" translate="label">
<label>New Reference</label>
</block>
</reference>
<reference name="newreference">
<block type="core/template" name="newreferenceblock" template="newreference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>
</default>
</layout>
Try this
<reference name="newreference">
<block type="core/template" name="newreferenceblock" template="newreference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>
change this to
<reference name="newreference">
<block type="core/template" name="newreference" template="newReference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>

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>

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') ?>

Resources