Community Forums

Banner Slideshow Image Order Issue [SOLVED]

Support for Modules & Sideboxes

Banner Slideshow Image Order Issue [SOLVED]

Postby ann0314 » Sun Jun 19, 2011 3:16 am

I've been having image order issues with any place where you upload the images on the back-end (IE Product pages, Banner Slideshow etc)

I resolved the issue for the Product Pages (or atleast I think so haven't gotten to try the new code change yet) (found the answer here - just in case someone needs it) but I can't find anything on how to fix the same issue with the Banner Slideshows and I need the images in a certain order.

Also is there a way to make it so when someone clicks a banner that leads to an outside site that it will open in a new window instead of taking them off my site and on to the other?

Any help with either issue would be greatly appreciated! Thanks so much! :)
Last edited by ann0314 on Sat Sep 24, 2011 5:18 pm, edited 1 time in total.
User avatar
ann0314
 
Posts: 28
Joined: Tue Jun 14, 2011 9:31 am

Re: Banner Slideshow Image Order Issue

Postby SXGuy » Sun Jun 19, 2011 6:44 am

for images to be in a certain order, you should add the last image first and work your way backwards. i found this problem also.

for opening an external link when you click the image, yes you can do this. there should be an area where you can add an external link under the banner image settings, im sure i remember seing it.

To make it open a new window. edit catalog/view/theme/yourtheme/template/module/banner.tpl

find

Code: Select all
<div><a href="<?php echo $banner['link']; ?>"><img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" title="<?php echo $banner['title']; ?>" /></a></div>


replace with

Code: Select all
<div><a href="<?php echo $banner['link']; ?>" target="_blank"><img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" title="<?php echo $banner['title']; ?>" /></a></div>
SXGuy
 
Posts: 1798
Joined: Sat Nov 07, 2009 1:07 pm

Re: Banner Slideshow Image Order Issue

Postby ann0314 » Sun Jun 19, 2011 7:52 pm

Thanks for the code! That solves one issue :) As for the other, I did notice ordering them backwards will work but then if you have to change one and hit save again on the back end it scatters them all around and you basically have to delete them all and put them all back in again or you cant get your order back :( I was hoping maybe there was some cool coding way to do it. I tried to take the code for the product pages that I linked to above and use that but it brought up an error so I'm thinking that the coding would need to be a bit different just not sure how :(
User avatar
ann0314
 
Posts: 28
Joined: Tue Jun 14, 2011 9:31 am

Re: Banner Slideshow Image Order Issue

Postby dpfavand » Mon Jul 11, 2011 9:36 pm

Had the problem with not being able to order the slideshow images. So I did a little digging. This works on ver 1.5.0 - this solution is working on my site, http://www.prairiepassions.net , where I am able to keep the welcome banner the first banner the customer sees.

in

/catalog/model/design/banner.php

Code: Select all
<?php
class ModelDesignBanner extends Model {   
   public function getBanner($banner_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id  = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY image ASC");
      
      return $query->rows;
   }
}
?>

I added the ORDER BY image ASC at the end of the long line.

I suspect that this will get overwritten with each system upgrade?
The way I order my images is to start by tens... 10_img.jpg, 20_img.jpg, 30_img.jpg etc. Then if I want I can add a file in the middle, say 15_img.jpg, without having to rename all the files.

I suspect this could also be made to sort by the banner description that is in the backend, allowing for easier control of the slideshow, but I find this easy and logical enough.
dpfavand
 
Posts: 1
Joined: Mon Jul 11, 2011 9:28 pm

Re: Banner Slideshow Image Order Issue

Postby ann0314 » Mon Jul 11, 2011 10:09 pm

I'll have to give this a try! Thanks so much for sharing. I fiddled some with it but couldn't seem to sort anything out on my own :( I'll let you know how it fairs for me. I'm hopeful it works though cuz that sure is annoying lol.

As for your question, looking at which file you modified here, yes you would need to keep track and redo this addition in other releases if this file changes since it isn't in the templates folders where it is semi protected :)
User avatar
ann0314
 
Posts: 28
Joined: Tue Jun 14, 2011 9:31 am

Re: Banner Slideshow Image Order Issue

Postby ann0314 » Mon Jul 11, 2011 10:24 pm

Yep that worked so TY TY TY :) ;D
User avatar
ann0314
 
Posts: 28
Joined: Tue Jun 14, 2011 9:31 am

Re: Banner Slideshow Image Order Issue

Postby mwd » Sun Aug 28, 2011 5:10 pm

This worked for me to.
Thanks for the code dpfavand!

I made it into a vqmod so that you don't have to change the code again after an upgrade.
Attachments
order_slideshow_images_by_name_vqmod.xml
(647 Bytes) Downloaded 1234 times
Use it? Like it? Want to support it but don't know how? Send a donation to show your appreciation.
Daniel's PayPal address - donate@opencart.com
Qphoria's Paypal address - qphoria@gmail.com
mwd
 
Posts: 124
Joined: Sat Jan 08, 2011 10:40 am

Re: Banner Slideshow Image Order Issue

Postby onlinemarketer » Tue Sep 13, 2011 2:40 pm

Brilliant stuff guys!

It would be good if this was added to the core or ideally some form of ordering which can be specified from the slideshow/banner module.
onlinemarketer
 
Posts: 84
Joined: Sat May 14, 2011 7:21 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby emilygraham » Fri Oct 21, 2011 9:16 am

Hi Guys,

With regards to opening a link from the banner in a new window - is it possible to apply this to only one banner image and all the others open in the same window?

Thanks !
emilygraham
 
Posts: 47
Joined: Wed Sep 14, 2011 6:26 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby Goffer » Mon Oct 24, 2011 3:08 am

Thanks!
Been trying to fix the sorter issue for awhile now :D
Goffer
 
Posts: 18
Joined: Sun Jun 19, 2011 2:28 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby tobychin » Wed Nov 30, 2011 3:36 pm

Don't know about anyone else, but sorting by "Title" was going to work out better for me. Changed "image" to "title" and now I don't have to rename images, just edit the title for re-arranging.
Attachments
order_slideshow_images_by_name_vqmod.xml
(647 Bytes) Downloaded 813 times
- Toby
"The only way to get to the top is to get off your bottom." - Fortune Cookie
tobychin
 
Posts: 28
Joined: Mon Jul 11, 2011 11:03 am
Location: Warsaw, Indiana

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby slingeraap » Tue Dec 20, 2011 12:26 pm

I sort on image title by putting this in banner.php: ORDER BY title ASC

Then you don't have to name your images, just fill in titles just like '01 first picture' and '02 next picture'...
slingeraap
 
Posts: 53
Joined: Sun Dec 05, 2010 6:02 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby rocket » Mon Dec 26, 2011 5:52 am

Finally a fix for my banners on 1.5.1.3
Thanks tobychin
User avatar
rocket
 
Posts: 24
Joined: Fri Oct 21, 2011 11:09 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby swazemarket » Tue Dec 27, 2011 8:53 am

Thanks Guys,

Also sorted my slideshow order problem by using the ASC in:

Code: Select all
<?php
class ModelDesignBanner extends Model {   
   public function getBanner($banner_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id  = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY image ASC");
     
      return $query->rows;
   }
}
?>
swazemarket
 
Posts: 13
Joined: Fri Sep 30, 2011 1:22 pm
Location: Mbabane

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby plexusdesign » Tue Jan 03, 2012 11:26 am

I just called the banner Titles, the first column, banner1, banner2, banner3, etc and they came up in the correct order as dictated by the Title column.. not sure why that works but it does.

Hope that helps
plexusdesign
 
Posts: 7
Joined: Mon Jun 13, 2011 12:52 pm

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby dizarter » Tue Jan 24, 2012 12:47 pm

To sort banner images by title on the admin screen as well, do the following

open admin/model/design/banner.php

find public function getBannerImages

Last line of that function should be

return $banner_image_data;

Just before that line add this

Code: Select all
function sort_images_by_name($a, $b) {
  return $a['banner_image_description'][1]['title'] > $b['banner_image_description'][1]['title'] ? 1 : -1;
}
usort($banner_image_data, "sort_images_by_name");
dizarter
 
Posts: 60
Joined: Mon Oct 10, 2011 6:33 pm

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby plexusdesign » Tue Jan 24, 2012 3:53 pm

one other thing I noticed that may help is if you change a picture when you go back the sort order is reverse, if you just open the menu with the list of banners in it again, and its listed in the reverse order just click save again and it straightens it all out. At least on the cart I am currently working on.
plexusdesign
 
Posts: 7
Joined: Mon Jun 13, 2011 12:52 pm

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby Web Studio West » Wed Feb 08, 2012 2:17 pm

To sort by banner title, I modified the code above posted by swazemarket by changing "ORDER BY image ASC" to "ORDER BY title ASC". I also noticed if banner titles are only numeric they don't sort properly. I solved this by naming banner titles: AD1, AD2, AD3, etc. and it works like a charm. Titles that were just numbers (like: 10, 20, 30) didn't work.

Code: Select all
<?php
class ModelDesignBanner extends Model {   
   public function getBanner($banner_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id  = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY title ASC");
     
      return $query->rows;
   }
}
?>
Web Studio West
Phoenix Website Design
User avatar
Web Studio West
 
Posts: 15
Joined: Thu Sep 08, 2011 11:12 am
Location: Scottsdale AZ USA

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby nudylady » Thu Mar 01, 2012 10:02 am

ORDER BY title ASC
worked great by this one line of code.
nudylady
 
Posts: 17
Joined: Sat Feb 18, 2012 11:14 am

Re: Banner Slideshow Image Order Issue [SOLVED]

Postby thrashin » Thu Mar 29, 2012 5:12 pm

Awesome, simple fix! Loved the vqmod too - thanks heaps!

http://www.ozedesign.com.au
thrashin
 
Posts: 8
Joined: Sun Nov 06, 2011 9:22 pm

Next

Return to Modules

Who is online

Users browsing this forum: No registered users and 8 guests

Hosted by Arvixe Web Hosting