Joomla show subcategory image on category page? - joomla

Is there a way, beside creating yet another MYSQL connection, to retrieve subcategory image while browsing parent category page?
For example:
Main category (set as category as blog)
Subcategory 1 (image set in Basic options image field)
Subcategory 2 (image set in Basic options image field)
Subcategory 3 (image set in Basic options image field)
....
Now, when i browse 'Main category', it display categories title and description of subcategories, but I cant find any 'normal' way to retrieve image that i set in basic option.
The only way that I can make to work is to create another MYSQL call and retrieve image from database, but I would like to know if there is another more effective way.
Im using Joomla 2.5.
Thanks!

I suggest you override the output of the content so that you can add some code to output your images.
Copy:
joomla/components/com_content/views/category/tmpl/blog_children.php
To:
joomla/templates/yourtemplate/html/com_content/category/blog_children.php
Then edit your new override file, just below:
<span class="item-title"><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
<?php echo $this->escape($child->title); ?></a>
</span>
Add:
<div class="item-image">
<?php echo '<img src="'.json_decode($child->params)->image . '" />'; ?>
</div>
See Joomla docs for Component Output Types and Layout Overrides.

Related

display module only on the front page of virtuemart joomla 2.5

hi i want to display module only on the front page of virtuemart and dont want that module on inner pages. i have search about this, but did not get anything.
I tried to used this code but it does not effect.
<?php if (JRequest::getVar('view')=='productdetails') { ?>
<div id="productmod"><jdoc:include type="modules" name="productdetails" /></div>
<?php } ?>
Can anyone help me to figureout this problem
Thanks In advance..
take a look on the answer, and var_dump the $menuList to get all the menus, then just get the specific menu and apply your condition..
// Get default menu - JMenu object, look at JMenu api docs
$menu = JFactory::getApplication()->getMenu();
// Get menu items - array with menu items
$menuList = $menu->getMenu();
// Look through the menu structure, once you understand it
// do a loop and find the link that you need.
var_dump($menuList);
take a look on the give link how to determine the front or default page

Disable link functionality for certain products in Category View? (Magento)

Disable link functionality for certain products in Category View?
I only want some product to be visible in category, not clickable!
See example: http://i.imgur.com/m3ZHp1G.jpg I want only product in stock to be clickable.
How to do that? Step by step will be nice. Thanks.
Navigate to
app/design/frontend/<package_name>/<theme_name>/template/catalog/product/list.phtml
else copy this file from base/default theme to your theme
Goto this line
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></h2>
Add your condition before it

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*

Display attribute image instead of text

I figure out how to show attribute in category of product list, what I need is to display an image instead of text.
Eg. I have an attribute text ASUS and a image located in media/brands/ named asus.gif or instead of Western-Digital display image located in media/brands/western-digital.gif.
I hope you understand
What you want to do is
<img src="<?php echo $this->getMediaUrl(); ?>brands/<?php echo strtolower($_product->getManufacturer()); ?>.png" />
getManufacturer may be the attribte, change it, if needed.
I found the solution:
<?php $brand=$_product->getAttributeText('manufacturer');
echo '<img style="float: right; margin: 2px;" src="/media/catalog/brands/'.str_replace(' ', '_',$brand).'.gif" alt="'.$brand.'">' ?>
If your attribute is a dropdown one you could add a new column in the table eav_attribute_option_value and in the "manage options/labels" tab of the manage attribute page in the admin panel. For each option values, next to each store traduction, you could store the name of your image and retrieve it in your templates.. it require some development but it's doable and easy to administrate.
Or the quick and dirty way : use the admin label string, lowercase it and clean to retrieve an image related filename
In the Magento 1.7.0.2 you can accomplish this in a very easy way...
All you do is create a new attribute, and select 'media image' from the 'catalog input type..' dropdown.

How to retrieve Categories name and children ? Magento

I would like to retrieve the categories of my website in order to build me own Category menu.
but I don't understand how to get all the categories from the class/model. So I've created a file called top.phtml that I've put in template/catalog/navigation ,
First, do I MUST put that name to the file into that folder if I want to create a top Menu ? Can t I decide where to put it with the name I want like TopMenu.phtml ? Because in evry tut I red, they are doing the same way ..
Second : What i the function I must call ? I've been here : http://www.magentix.fr/ergonomie-web/agencer-page-accueil-site-magento.html but the way the do that doesn t work for me .. I add that code to my file top.phtml properly called in the page.xml :
<div class="category-list" style="background-color:white;">
<h2>Nos produits</h2>
<?php
foreach ($this->getStoreCategories() as $_category):
if($_category->getIsActive()):
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer')->setCurrentCategory($_category);
?>
<div class="category-list-view">
<a href="<?php echo $this->getCategoryUrl($_category)?>" title="<?php echo $_category->getName()?>">
<img src="<?php echo $this->getCurrentCategory()->getImageUrl(); ?>" alt="<?php echo $_category->getName() ?>" />
</a>
<h3><?php echo $_category->getName()?></h3>
</div>
<?php
endif;
endforeach;
?>
</div>
Last : where could I find a clear user guide like there is for CodeIgniter ? I found that, but I never found any answer on it : http://www.magentocommerce.com/wiki/doc/webservices-api/api#magento_core_api
Thanks for your answers, I m a web dev used to work with CodeIgniter or without any template, and I can t clearly see the logic behind Magento way of programming.
EDIT: Is there anything to do with the categories ? Becaue I tried to create a sub category under the Default Category and it do work, but if I create a new Root Category,It simply didnt recognize it .. why
First, do I MUST put that name to the file into that folder if I want to create a top Menu ? Can t I decide where to put it with the name I want like TopMenu.phtml ? Because in evry tut I red, they are doing the same way ..
You can name your template file whatever you like. However, it's best to follow the nomenclature and established conventions. The template filename is contingent on your layout XML. It should have the template attribute, something like <block name="x" type="x/y" template="catalog/navigation/topmenu.phtml" /> (for example).
Second : What i the function I must call ? I've been here : http://www.magentix.fr/ergonomie-web/agencer-page-accueil-site-magento.html but the way the do that doesn t work for me
The functions available to your template (topmenu.phtml file) depend on the block's type. In your layout XML, you should specify the block type that corresponds to the functionality you need. In your case, you're probably looking for the block type to be catalog/navigation. If you look in ./app/code/core/Mage/Catalog/Block/Navigation.php, you can see what public methods are available to your template. Several of the methods here facilitate generating (nested) category listing. This is where your getStoreCategories() method comes from. Remember that these blocks inherit from several parenting classes, so you have a lot more methods available than you may at first think.
where could I find a clear user guide like there is for CodeIgniter ? I found that, but I never found any answer on it : http://www.magentocommerce.com/wiki/doc/webservices-api/api#magento_core_api
That's a link to the Magento API. What you need is a tutorial on Magento layout XML and the design layer therein. The Magento wiki has some good info, but Google around and you'll find a ton of really helpful resources on understanding Magento's design system.
Is there anything to do with the categories ? Becaue I tried to create a sub category under the Default Category and it do work, but if I create a new Root Category,It simply didnt recognize it .. why
A root category is what you'll use to identify the basis of the catalog for the selected store(s). You will never see the root category appear on the frontend (and you shouldn't). Each subcategory within the root category is the top-level category; sub-categories beneath those subcategories (tertiary categories) would appear as your "second-level" categories on the Magento frontend. You might want to look into Magento's GWS ("global, website, store") scope system, and how it manages catalog data in a multi-store setup to better understand why root categories function this way.
Hope this helps!

Resources