I've been driving myself crazy trying to display thumbnail images for a list of sub categories I'm attempting to display in a footer. I've tried the solution found here: http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/ but no luck!
Here is the code I am using at the moment. Everything works fine apart from the img src renders empty:
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan):
?>
<li>
<img src="<?= $artisan->getThumbnailUrl() ?>" />
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
Any help would be greatly appreciated! Thanks in advance.
SOLUTION (thanks Lucasmus!):
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan): ?>
<li>
<img src="<?= Mage::getBaseUrl('media').'catalog/category/'.$artisan->load($artisan->getId())->getThumbnail() ?>" width="96" height="96" />
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
There is a good chance that there is not enough information loaded from the childcategory. It could help if you added $artisan->load($artisan->getId()); before getting the actual variables from the $artisan.
If you try $artisan->getThumbnail() instead of $artisan->getThumbnailUrl()? I think that is the correct attribute name.
yeah but the $artisan->getThumbnailUrl() calls $artisan->getThumbnail()
so why dont you in you script first set a thumbnail value you know exists for the getthumbnail() to call.
then you'll know it's a db naming problem
Related
On our Magento 1.6.2 website we have enabled Google Sitemaps and added some manually with updates through cron.
What happens now is that the page Catalog > Google Sitemap in it's filters tells us that 4 records were found.
But it doesn't show anything below the filters.
Through looking at the source code I've found that the div with class sitemapGrid only has a total height of 33px and the div with class grid that should display the sitemaps only has a total height of 7px, 6 of which are padding.
The sitemapGrid_table is 0px high, with a 1px border.
But no tr nor td.
After some more digging I've found that the file in which it all happens is design > adminhtml > default > default > template > widget > grid.phtml
The page runs till the end of the first foreach after "grid" and then stops.
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
<?php foreach ($this->getColumns() as $_column): ?>
<col <?php echo $_column->getHtmlProperty() ?> />
<?php endforeach; ?> <!-- Runs to here and then stops executing, but who knows why? -->
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
<thead>
<?php if ($this->getHeadersVisibility()): ?>
<tr class="headings">
<?php foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
<?php endforeach; ?>
</tr>
<?php endif; ?>
<?php if ($this->getFilterVisibility()): ?>
<tr class="filter">
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
<?php endforeach; ?>
</tr>
<?php endif ?>
</thead>
If I comment out the first foreach, the code keeps running till it ends the first foreach in "headings". And so on (comment out one, runs till end of next one, ...)
Anyone have any idea on where the problem really lies and/or a solution?
So,
Long story short:
exception.log wasn't being filled so once that was solved I got to see that Magento couldn't find a certain blocktype.
Solved an error in config.xml and it all works just fine.
I am not a programmer by any means. I purchased the script and have spent two weeks and many variations trying to get the code to do what I need. It is 'almost' there.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
</div>
</a>
<?php endforeach; ?>
<?php else: ?>
<h2><?php echo Yii::t('yii', 'No relevant found!') ?></h2>
<?php endif ?>
</div>
It returns the images from a site. It only lets me select the first image. Even though all images are displayed. Only one is actually clickable. If I hover over each of the images I see the javascript href. I understand that to be some sort of place holder. that just makes the browser show the hand.
I just need the script to allow each item to be a choice for reaction.
http://silenceisnotawkward.com/Sinapin/Script/# is the live code.
I have made a test user
Test=user
Password =password in case anyone wants to see what the site does.
http://www.ew.com/ew/ is a good link to pin from website and see the behavior.
I didn't look at your site, but looks like you are confusing your nesting of HTML tags, because you introduced a end-of-dev tag in your link.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
<!-- I removed the < / div > from here -->
</a>
:
<?php endforeach; ?>
</div
>
HINT: I indented the code to make it more readable, Try doing the same with your code you posted and see where it leads you.
I figured out how to display my custom multiselection attributie as a list but havent been able to figure out how to add an ID or class to every list item. This would allow me to display an image using CSS instead of text.
Hope you guys can help me. By the way, this is the code I use to display my custom attribute "rating" as a list:
<?php if($_product->getResource()->getAttribute('rating')->getFrontend()->getValue($_product)): ?>
<ul><li><?php
$_comma = ",";
$_list = "</li><li>";
echo str_replace($_comma,$_list,$_product->getResource()->getAttribute('rating')->getFrontend()->getValue($_product)) ?>
</li></ul>
<?php endif; ?>
</div>
Without knowing the exact format of the return of your function, I can't be 100% sure, but I think this would do the trick:
<div>
<?php if($_product->getResource()->getAttribute('rating')->getFrontend()->getValue($_product)):?>
<ul>
<?php $i=0?>
<?php foreach(explode(',', $_product->getResource()->getAttribute('rating')->getFrontend()->getValue($_product)) as $value) : ?>
<li id="value_<?php echo $i?>"><?php echo $value ?></li>
<?php $i++ ?>
<?php endforeach ?>
</ul>
<?php endif; ?>
</div>
It would probably be a little easier to just modify your return to give you back an array, but if the return is a comma separated list and not easy to change, then explode should do the trick.
Sorry I'm only self taught but having trouble with something.
I currently have a custom attribute that I'd like to echo a price only if the attribute has no value. This is what I have right now but it calls both at the moment. This is for the product list.phtml page. Have been experimenting for the past 3 hours and can't figure how to do it.
<div class="product-pricerange" id="product-pricerange">
<?php echo $_product->getResource()->getAttribute('pricerange')->getFrontend()->getValue($_product) ?>
</div>
<?php echo $this->getPriceHtml($_product, true) ?>
Thanks in advance as any help is much appreciated.
You should be able to achieve this by wrapping it up in an IF statement a bit like so:
<div class="product-pricerange" id="product-pricerange">
<?php if(!$_product->getData("your_attrubute")):?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php endif;?>
</div>
HTH
You could also use hasData() functionnality
<div class="product-pricerange" id="product-pricerange">
<?php if($_product->hasPricerange()):?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php endif;?>
</div>
I have the following requirement;
I want to show a products configured related products on the category listing page (list.phtml).
I figured I could make some call on the list.phtml inbetween the for each loop for each product using the [b]$_product[/b] variable but I can't seem to populate the relatedProductCollection
sorry new to all this is it even possible.
<?php foreach ($_productCollection as[b] $_product[/b]):?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?>last<?php endif; ?>" >
<div class="product-shop">
<div class="f-fix">
<?php $product->getRelatedProductCollection(); ?>
</li>
<?php endforeach; ?>
$product has been used to call the getRelatedProductCollection function.
but,
In that foreach loop you have taken it as $_product.
Can you see the difference ??
Underscore is missing. This is taken from your code. Make the variable same in both the places and try.