Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Different image for Thumbnail and Product page

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 09-10-2014, 10:38 AM
 
JannieB JannieB is offline
 

Senior Member
  
Join Date: Sep 2004
Posts: 117
 

Default Different image for Thumbnail and Product page

Trying to work out how to use different images for the thumbnail on the category page, and the initial main image on the product detail page.

Out of the box, both use the first image in the sequence.

Have considered the following solution:

Use image 0 for thumbnail, but try and use the last image for the product page. Basically do reverse the sequence of the image array ...... except I can't work out where/how to do this.

Any help appreciated.

Jan
__________________
Jan Beesley
(Currently Xcart 5
Previously XCart Gold from 3.5....)
Reply With Quote
  #2  
Old 09-10-2014, 12:55 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Different image for Thumbnail and Product page

In my templates I use things like:
Code:
{if:!product.countImages()gt1} Some code {end:}

Flexy, doesn't allow for the same "flexibility" (pun intended) as Smarty. There is good reason for this, it forces you to put the logic where it belongs, in PHP rather than the templates. There is no cool "array_reverse" that I know of.

You will have to determine the class that displays the thumbnail. Extend the class, assigning your own value for thumbnail. Then {getMyThumbSrc()}.

It's a pain for someone with a design oriented background. But hardcore devs will appreciate that this a better way. XC5 has truly separated design from logic, but in doing so made the two camps depend on each other more than ever before. I think as a whole this is a very good thing. For your individual one-man (or woman) project it can be a real hassle.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 09-11-2014, 01:25 AM
 
JannieB JannieB is offline
 

Senior Member
  
Join Date: Sep 2004
Posts: 117
 

Default Re: Different image for Thumbnail and Product page

Thanks Mike, I fear you are right. I know this is a better way to go, but as you say, old habits die hard!

I have a feeling that once I've got my head around all this, it will be a lot easier to extend than the old system......
... will let you know how I get on!

Jan
__________________
Jan Beesley
(Currently Xcart 5
Previously XCart Gold from 3.5....)
Reply With Quote
  #4  
Old 09-11-2014, 03:41 AM
 
JannieB JannieB is offline
 

Senior Member
  
Join Date: Sep 2004
Posts: 117
 

Default Re: Different image for Thumbnail and Product page

Managed to do it!

For the benefit of anyone else trying to do this, this is what I did:

Created a new class in CustomSkin\Model which extends the \XLite\Model\Product class and added a function as follows:

Code:
public function getThumb() { if (count($this->getImages()) > 1) { return $this->getImages()->get(1); } else { return $this->getImages()->get(0); } }

Then created a version of the tpl common.product-thumbnail.tpl in items_list\product\parts, which calls my new getThumb function instead of getImage.

This retrieves the second image as the thumbnail.

Sorted!

There'll be no stopping me now .... (perhaps!)

Jan
__________________
Jan Beesley
(Currently Xcart 5
Previously XCart Gold from 3.5....)
Reply With Quote

The following 3 users thank JannieB for this useful post:
qualiteam (09-12-2014), SignTorch (11-19-2014), totaltec (09-11-2014)
  #5  
Old 09-11-2014, 03:56 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Different image for Thumbnail and Product page

Quote:
Originally Posted by JannieB

There'll be no stopping me now .... (perhaps!)

Agreed! You rock! Thanks for sharing your solution.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #6  
Old 11-19-2014, 02:39 PM
 
SignTorch SignTorch is offline
 

Advanced Member
  
Join Date: Jun 2010
Posts: 30
 

Default Re: Different image for Thumbnail and Product page

very helpful, great to watermark product images but not thumbnails
__________________
SignTorch Vector Graphics
dropping xc4.6.x, tested xc5 (FAIL)
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:55 PM.

   

 
X-Cart forums © 2001-2020