Joomla 2.5 Show subcategory image on blog view - image

I am having trouble showing the image of a subcategory on my blogview.
Furthest I've gotten is showing the image of the parent category with this line:
$this->category->getParams()->get('image');
This line shows the title of the subcategory though
$this->escape($this->item->category_title);
So I've tried adding item in that top line but it didn't take. My knowledge of Joomla and php isn't enough to figure out how to change this to show the subcategory image instead.
Any help would be much appreciated.
Edit:
To elaborate, the blog view I am using is a view of all the articles in the category 'Trends'. The category Trends however does not include any articles but all of it's subcategories do.
So the structure is as follows:
-Trends
--Trend1
---Article1
----Article2
---Trend2
---Article1
---Article2
With this blog I want to show the image of the subcategory that the article is related to. In the Joomla parameters I set the option to show the category image, however this only shows the parent category image not the subcategory image.

Solution 1:
There's no need to change the code for that.
When you are seeing "$this->category->getParams()->get('image');" in the code, it means that the template is reading parameters to whether show the image or not.
You can change the global parameters of com_content with Option button in top-right of your administrator interface, or you can change a specific category's parameters in Edit Category mode.
I can see a Category Image parameter there!
Solution 2:
Use print_r to see all the attributes of item, like this: print_r($this->item), then you will see if the item has something like category_image or not. If it contains image, use it!

I made it by creating a new instance of JCategories by catid. And then I took an image from it by getParams().
$options = array();
$categories = JCategories::getInstance('Content', $options);
$category = $categories->get($this->item->catid);
<img src="<?php echo $category->getParams()->get('image'); ?>"/>

Related

adding product listing on magento homepage with description

I need to show my new products on the home page as a list view. I have used a Magento widget, but it is not returning the description of the product. How can I fetch the whole details of the product in the home page as shown in the image below?
First find out(template hint) the file from where your widget is rendering products. It's located in app/design/frontend/<yourpackage>/<yourtheme>/template/catalog/product/widget/new/content/new_grid.phtml/new_list.phtml
Go look in that file, you will see how and what values are the widgets printing. So if you want description within the foreach loop you can get by printing $_product->getShortDescription() or $_product->getData('short_description')
Similarly to get other stuff like in list page, please take reference from template/catalog/product/list.phtml see how the other details are being printed and get those here on widget phtml file.

Display set of user chosen categories on magento home page

I am trying to display categories on magento home page. I know how to do it in a normal way using magento collections. I want to have it like a widget, if you insert a category link widget in static block or cms page, you can see the following:
{{widget type="catalog/category_widget_link" template="catalog/category/widget/link/link_block.phtml" id_path="category/3"}}
Now, here the id_path indicates which category to display. Can we modify it somehow to show a list of specified categories. For example like this: id_path = '3,4,5,6' so it will display all these specified categories. Can anybody guide me a way to do this? I don't know much about widget coding stuff in magento.
You can add as many as widgets inside the static block by selecting the widget as many as times you want.

Filter one specific attribute values from products in magento

I'm new in magento, I'm working on http://www.theartworkgallery24.com/stage/ website. Please check beneath flash banner, there are 4 big images that are links to attributes value from which user can directly go to a product.
I need a page that display on one specific attribute values like in case of artist, it should be Gustav Klimt, Leonardo Da Vinci etc. These should be links to actual product related to the attribute values.
Please tell me how to make your own PHTML or PHP file, which code to use and how, and in last how to call your code in your magento website.
Any ideas will be appreciated, thanks.
You please create an attribute (davinchi) in admin side for these functionality. You can create products attributes from catalog->attributes->menu.After that you can see these attribute value in product creation page.You just assign it to different products
After that you can either create a module for this. Otherwise just create a phtml file in catalog/product/ folder.
then enter the below custom collection code in it.
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
//filter codition
$collection->addFieldToFilter(array(
array('attribute'=>'davinchi','eq'=>1),
));
This will load products having attribute value davinchi=1.

How Do I Show All Products From All Categories Which Have a Certain Attribute = a Certain Value?

So basically my Magento store sells t-shirts (not really) in a bunch of different categories. All t-shirts, regardless of category, have the color attribute = to either red, blue, green, etc.
I want to be able to link to a page for blue products, or red products, etc, and show them all regardless of parent category.
Thoughts? Thanks. I'm really not trying to add them all to another category manually.
Give the Yoast's Landing Pages extension a try. As explained in their blog, you'll be able to create CMS pages that contains products listings filtered by any attribute you have created.
For example, to list all black products, you'd use something like (here the value "black" has id of 24):
{{block type="Yoast_Filter/Result"
name="filter_result"
template="catalog/product/list.phtml"
attribute_name="color"
value="24" }}
And as it is a CMS page, you'll also can customize the url to have something like: http:/www.yourdomain.com/all-black-products.html.
The description in magentoconnect says it's only compatible with 1.4, but I'm using with a 1.5, I can't remember if I had to change the code or not though.
HTH
link them all to specific category and use navigation filters
You can filter products by attribute value.. simply by using addAttributeToFilter
$attributeValue = 'red';
$attributeCode = 'color';
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter($attributeCode, $attributeValue);
Hope this helps. Thanks.

use the category default image as products default image

In magento you can set an image to a category which is shown above products.
Is it possible to use the category image as the default product image instead?
If a product has an image it'll use it but if it doesn't and its first category has an image it will use it.
The simplest way is to override the product block and template and to find the category and image for each product without an image but that will add many queries. For category view I can make one query but for search result I'll have to make one query per product because each product can be from a different category.
Is there a better way to do it?
Maybe with custom category design or overriding indexes?
Thanks
The helper usually used to generate those images (Mage_Catalog_Helper_Image) has a method placeholder($filename) that should set the placeholder image URL. You should be able to set that image before displaying the category products to use the category image as the placeholder image.
Hope that helps!
Thanks,
Joe
To complete Joseph and Pablo answer, on Magento 1.9.1, it is used in the __toString() method of the helper.
Note that when calling $this->helper('catalog/image')->placeholder($placeholder), $placeholder is a relative file path in the skin directory, so it can barely be used for your problem (mine neither, I'll do with your solution :) )

Resources