Magento 1.7: add active home button in menu - magento

Im trying to add a home button in the navigation of my magento store. A lot has been written and I found this code that does the job.
<li class="home <?php echo !$_anyActive ? 'active' : '' ?>"><span><?php echo $this->__('Home') ?></span></li>
The only drawback is that it stays active while clicking on other categories. So it isn't behaving like the rest of the menu.
Any help?
Many thanks in advance!
Update:
Solved with the answer given below.

This should do the trick for you...
<li class="home <?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"><span><?php echo $this->__('Home') ?></span></li>
As you can see it checks to see if the url matches the home url. If so it then sets the class active.

Related

How to remove data from header menu and add new content to it in Magento

I am working with magento.
I have been trying to remove the content from header-menu and add fresh content like
**HOME ABOUTUS SITES CONTACT**
Here is the current situation,
Update
Above is the screen shot that follows after the top-menu
Please guide me to achieve this..
Thank you.
I assume the above menutimes that you've shown in the image are categories. So if you don't need it on the top menu then go to each of the categories (under Catalog -> Manage Categories) in the backend / admin panel and choose "NO" as an value to the option "Include in Navigation Menu". This will remove them from the navigation top menu.
And to bring these menu items
HOME ABOUTUS SITES
Let me describe it for one of the items above. Lets take About Us
At first create the respective CMS static block for "About Us"
Create a category called "About Us"
Go to display settings of the About Us category and choose the display mode as "static block only" and then select the static block "about us"
Save the category and reload your page on the frontend/website
you can find the "about us" category on the top menu and opening it will show the content from the static block.
Repeat the same for the other menu items.
If this helps mark it as answer. Thanks.
I think you didn't want categories in top menu. In place of it you want Custom links like "Home", "About us" etc.
For this open topmenu.phtml file in template->page->html.
In this commented the below line :-
<?php echo $_menu ?>
and in place of it call a static block of name "custom_top_nav" :-
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('custom_top_nav')->toHtml() ?>
In this block you can make your custom menu.
We you want both custom links plus categories then you can replace code with this:-
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<li class="home"> HOME </li>
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
Magento hide categories in the header menu - This can be done from your Admin Panel under Manage Categories > To do this is easy if you don't want your categories in top menu of your web site - When you add a new Category Select no for > Include in Navigation Menu * Its under Meta Description at the bottom of the page where you add the the Category name in General Information Tab*

create link in Joomla

Hi everyone I have a component in joomla 2.5 that show a list of element.
Now I want to view a particular item, how to create a link to past the id of this element and see the whole description
I have this
<a href="<?php echo JRoute::_('index.php?option=com_productos&view=especialidad8780&Itemid=1'); ?>" >este</>
but dont show me the Itemid=1
the browser take this router
index.php?option=com_productos&view=especialidad8780&lang=es
this the correct form to do a link in joomla?
thanks
David is right. The "itemId" is a reserved variable for menu item (to set the 'active' class on a clicked menu element). Try to switch to id, productid, ...
And you also have a little mistake in your link (closure a was missing):
<a href="<?php echo JRoute::_('index.php?option=com_productos&view=especialidad8780&Itemid=1'); ?>" >este</a>
If you are trying to link to a particular item, you commonly use &id=1. Itemid is reserved for linking to menu items and would be added automatically as necessary by the JRoute call.

Magento extra add review button

I'm using Magento and what i want is the following:
Under the product reviews on the product page i want to add an extra "add review" button. What I did is add the following link on template\review\product\view\list.html
<a href="<?php echo $this->getReviewsUrl() ?>#review-form"><span><?php echo $this->__('Write review') ?>
The link shows up at the bottom of the product reviews so that goes well but when i click the button nothing happened.
Somebody knows how to fix it?
Thanks in advance!
Try this:
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>

Add AW Blog link to Magento top menu

Using the Magento 1.4 blog plug-in "AW Blog", how is it possible to get the "News" link it creates to appear in Magento's top menu (as opposed to the top links menu which it does by default)?
After changing AW Blog 'Route to Blog' configuration from 'news' to 'blog', add this to top.phtml :
<div class="nav-container">
<ul id="nav">
<?php echo $_menu ?>
<li><?php echo $this->__('Blog') ?></li>
</ul>
Probably no the most elegant solution as I didn't want Blog at the end of the menu, so if there's a better solution out there...
I haven't tried it but this extension seems to allow adding an arbitrary link to the menu.
http://www.magentocommerce.com/extension/657/navigation-bar-administrator

Magento - showing review links & add-to-compare links on custom pages

I have a custom page as my magento homepage. It's content is hardcoded on the default CMS page (which shows if a CMS homepage isn't enabled in the CMS pages section of the admin).
I have a list of products showing there (pulled from best-selling/highest rated etc). However, the review links and the add-to-compare links don't show on this page. The list of products is displayed using the same code as the default template/catalog/product/list.phtml, and everything else works except for these 2 things.
It seems that both the following code snippets have no effect on pages other than the default category listing page:
<?php $_compareUrl=$this->getAddToCompareUrl($_product); ?>
&
<?php echo $this->getReviewsUrl() ?>
I'm guessing that there's something else that needs to be called in order for these to work, but can't figure out what it is. Everything else from the product collection is available.
I load my product collection using the following code:
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', $visibility)
$_productCollection->load();
Any ideas?
OK, so after a while digging around, I found that you can use the following to get the compare url working:
<?php $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ?>
<span class="addto">
<?php echo $this->__('Add to Compare') ?>
</span>
Still not sure about the review urls, but I've made an acceptable workaround for that so I'm gonna mark this as answered.
If anyone comes up with an answer though please do still post it!
I'm guessing it's because the Block that is serving up your product list may not be correct. I believe it should be Mage_Catalog_Block_Catalog_Product_List. How exactly are you loading in the list of products?

Resources