Jump to content

[SOLVED] Display a different image than the default one


Recommended Posts

Hi everyone,

I tried to find the solution on this forum but I couldn't find anything that would suit to my issue.

I'm trying to display in the 'In the same category' module a different image than the default one.
I have actually 4 images

1. Default for the category page
2 & 3. For the product page
4. For the 'In the same category' module.

So my objective is to find a piece of code that would help my display the image number 4 in this module and not the default (number 1) one.

Here is how I integrate my image

getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}" style="background:url({$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'samecat')})">
link text



Thanks a lot for your time and help

J

EDIT: Weird, but the [ code ] part is not displaying properly. My link starts with a href of course

Link to comment
Share on other sites

By default it is 'medium' size image in productcategory module code and you want to change it to 'samecat' ?

And do you have samecat defined in Back Office >> Preferences >> Image and in img/p/ folder images with same in file-name ?

Or maybe I didn't understand question ?

Link to comment
Share on other sites

Hi razaro,

Thanks for your answer.
What I'm trying to to do is to display in the "samecategory" module the fourth image that I have uploaded for the products. (see the screenshoot i uploaded)

I already changed to property in the img to make it display in the "samecat" size but I can't suceed in getting this image number 4 and not the number 1 (default one).

I hope you'll understand what I mean...

Thanks for your help

J

26579_P1Uw4oqt8mhHn57Ntuqt_t

Link to comment
Share on other sites

Yes i was thinking that but wasn't sure :-)
In attachment you have productscategory.php and productscategory.tpl.
In php file I added array that contains pair imageID and 4th product image ex 1-37 and 40.
(This could be done better i think)

        foreach ($categoryProducts as $key => $categoryProduct)
           {
           $image4[$categoryProduct['id_image']]=intval(substr($categoryProduct['id_image'],-2))+3;

           }


Also added this line

$smarty->assign('image4', $image4);



In tpl few variables are added

            {assign var=key value=$categoryProduct.id_image}
           {assign var=i value=$image4.$key}
           {assign var=imageIds value=`$categoryProduct.id_product`-$i}



and then call for image src

<img src="{$link->getImageLink($categoryProduct.link_rewrite, $imageIds, 'medium')}" 
alt="{$categoryProduct.name|htmlspecialchars}" />



There is maybe a better way to do all this but this is working for me.

image4.zip

Link to comment
Share on other sites

Thanks very much razaro, it works perfectly. I just had to upload the images again because some of them were not named right after each other but after that it worked perfectly.

Thanks for your help, your time and your excellent tips!

J

Case [sOLVED] ;-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...