Display attribute image instead of text - magento

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.

Related

Magento 1.9.3 Display alternative image on hover on category page

I want to display an alternative image on hover on category page by assigning it in Product Information -> Images. I have created an attribute hover_image with the parameters Scope-Global, Catalog Input Type-Media Image, Apply to All Product Types. Added the attribute to the set. What should I do next? Thank you
To show the alternative hover image on category page. You need to make changes in Product Listing template in your current theme template/catalog/product/list.phtml.
As you have already created the media type attribute 'hover_image'. So you need to fetch hover_image type image like below:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'hover_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'hover_image'), null, true) ?>" />
Now you need to use javascript to apply hover effect on product images to hide the original image and show hover image.

Magento add custom text in prices

I'm trying to write the word "+IVA" in all the product prices. Where can I change that so I can have something like the following screenshot?:
Another option is using CSS property :after
.class:after {
content:"+IVA";
color:red;
font-size:12px;
}
You can style it however you want.
If the text never changes, I'd just hard code it to the template, maybe in template/catalog/product/list.phtml after the getPriceHtml() line.
In theme's product listing file (template/catalog/product/list.phtml) after <?php echo $this->getPriceHtml($_product, true) ?> you can write '+IVA'. But you need to write it twice as there are list and grid view separate. So search for it and after that code write down '+IVA' text

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.

Can you control pinterest's "find image" results?

Rather than add Pin It buttons through our site, I would like to simply control what images show up in Pinterest's "Find Image" results if a user decides to pin one of our URLs.
As of now, "Find Images" allows the user to scroll through the images it finds on the page so they can select which image to pin. The "found" images start with the first jpg in the html file, I'm assuming (could that be a bad assumption??). On our site, this forces a user to scroll through about 15 navigation and promotion images before arriving at the featured product image. Is there any way to specify this image to show first in those results? Maybe through a meta tag, or by adding a class or id to the element?
Without a public Pinterest API, this seems like just guesswork, but I wanted to see if anyone else has run into this, or solved this. Thanks.
A lot of search results including the Pinterest Help Center talk about using nopin in HTML elements, which is invalid HTML. What they don't document is a data attribute to the same (well formed) effect.
<img src="foobar" data-pin-nopin="true" />
Adding the nopin attribute will exclude the image from appearing on Pinterest:
<img src="..." nopin>
I solved this by simply loading the image before all others in the page. In this case, I gave it width="0" and height="0" (you could also give it style="position: absolute; left: -9999px; top: 0;" just to be sure).
This won't break the page layout, but will force Pinterest to find this image first. The only downside is that the browser will load the page a few milliseconds slower, but if you're reusing this image later in the page anyway, you should make up for lost time then.
Pinterest will find any images from <img> tags (it will ignore CSS background images) that are at least 80px x 80px.
The order the images show up on in the Pinterest list is determined by the order they are specified in the HTML.
As you have discovered, you can alter the CSS of an image to "hide it" without actually hiding it by either moving it off the page with absolute positioning or 0 height and width. Any images that are set to display: none will not be picked up by Pinterest.
You can instruct the share preview to only grab specific images from the page by using the “image_include” configuration option. First, set image_include to your desired class name (id selectors are not allowed, only class selectors), then add that same class name to each of the images on the page that should be grabbed. For image_include, don’t add the ‘.’ selector. Here’s an example:
<script type="text/javascript">
var addthis_config = {
image_include: "at_include"
}
</script>
Once image_include has been defined with a class, add that class to the desired images on the page. In this example, the only images on the page that will be grabbed, will be the images with the at_include class (img1.jpg and img3.jpg).
<img src="http://www.example.com/img1.jpg" class="at_include" />
<img src="http://www.example.com/img2.jpg" />
<img src="http://www.example.com/img3.jpg" class="at_include" />
I was reading this blog which suggests the following:
Use the global no pin flag to prevent pinning on the whole site
Manually add the Pin It widget to those images you want to make pin-able.
Given Pinterest's webmaster tools appear to only have a blacklist, rather than a whitelist option (that you are seeking), this could be a possible solution. Another stated benefit of this is you can also supply suggested pin text through the Pin It widget.
Only downside to this I guess is that it may break the user's own Pin tools. Pinterest does allow you to supply a custom "denied" message, so I guess you can say "please use our site's pin buttons directly".
I've tried this, and it works. It seems like a decent approach, at least until Pinterest sees fit to add some better tools, such as an image whitelist option. The main drawback is needing to add Pin-it buttons on every image you want to enable for your users & your users may be annoyed that they can't pin anything.
Unfortunately, there is no way to mark several images on your page as preferred, but you can mark one image to stay at the top of your images when someone pin it. Specify this meta-tag in <head>:
<meta property="og:image" content="http://YOUR-DOMAIN.com/IMAGE.jpg"/>
I have not found official confirmation for this feature, but it works great with addthis sharing plugin.
Add this script before the actual call to pinterest. And set images that you do not want to show with a class called 'nopin'
<script type="text/javascript">
var addthis_config =
{
image_exclude:'nopin'
}
</script>
<div id="toolbox" class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_tumblr"></a>
<a class="addthis_button_pinterest"></a>
</div>
</div>
If anyone is using AddThis, please check this thread: http://support.addthis.com/customer/portal/questions/1570789
AddThis has some, uh, unique functionality that affects the image picker presented. As in, when there is only one image on the page, it ignores the defined og:image.
If you set that lone image to be excluded, then the image picker won't show any images for selection.

Joomla show subcategory image on category page?

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.

Resources