Post by ann0314 » Sun Jun 19, 2011 4:16 pm

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 Sun Sep 25, 2011 6:18 am, edited 1 time in total.

User avatar
Newbie

Posts

Joined
Tue Jun 14, 2011 10:31 pm

Post by SXGuy » Sun Jun 19, 2011 7:44 pm

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>

Newbie

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ann0314 » Mon Jun 20, 2011 8:52 am

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
Newbie

Posts

Joined
Tue Jun 14, 2011 10:31 pm

Post by dpfavand » Tue Jul 12, 2011 10:36 am

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.

Newbie

Posts

Joined
Tue Jul 12, 2011 10:28 am

Post by ann0314 » Tue Jul 12, 2011 11:09 am

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
Newbie

Posts

Joined
Tue Jun 14, 2011 10:31 pm

Post by ann0314 » Tue Jul 12, 2011 11:24 am

Yep that worked so TY TY TY :) ;D

User avatar
Newbie

Posts

Joined
Tue Jun 14, 2011 10:31 pm

Post by mwd » Mon Aug 29, 2011 6:10 am

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


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
Newbie

Posts

Joined
Sat Jan 08, 2011 11:40 pm

Post by onlinemarketer » Wed Sep 14, 2011 3:40 am

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.


Posts

Joined
Sat May 14, 2011 8:21 pm

Post by emilygraham » Fri Oct 21, 2011 10:16 pm

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 !

Newbie

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by Goffer » Mon Oct 24, 2011 4:08 pm

Thanks!
Been trying to fix the sorter issue for awhile now :D

Newbie

Posts

Joined
Sun Jun 19, 2011 3:28 pm

Post by tobychin » Thu Dec 01, 2011 4:36 am

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


- Toby
"The only way to get to the top is to get off your bottom." - Fortune Cookie


Newbie

Posts

Joined
Tue Jul 12, 2011 12:03 am
Location - Warsaw, Indiana

Post by slingeraap » Wed Dec 21, 2011 1:26 am

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'...

Newbie

Posts

Joined
Sun Dec 05, 2010 7:02 pm

Post by rocket » Mon Dec 26, 2011 6:52 pm

Finally a fix for my banners on 1.5.1.3
Thanks tobychin

User avatar
Newbie

Posts

Joined
Sat Oct 22, 2011 12:09 am

Post by swazemarket » Tue Dec 27, 2011 9:53 pm

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;
   }
}
?>

Newbie

Posts

Joined
Sat Oct 01, 2011 2:22 am
Location - Mbabane

Post by plexusdesign » Wed Jan 04, 2012 12: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

Newbie

Posts

Joined
Tue Jun 14, 2011 1:52 am

Post by dizarter » Wed Jan 25, 2012 1:47 am

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");

Newbie

Posts

Joined
Tue Oct 11, 2011 7:33 am

Post by plexusdesign » Wed Jan 25, 2012 4:53 am

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.

Newbie

Posts

Joined
Tue Jun 14, 2011 1:52 am

Post by Web Studio West » Thu Feb 09, 2012 3:17 am

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

Posts

Joined
Fri Sep 09, 2011 12:12 am
Location - Scottsdale AZ USA

Post by nudylady » Thu Mar 01, 2012 11:02 pm

ORDER BY title ASC
worked great by this one line of code.

Newbie

Posts

Joined
Sun Feb 19, 2012 12:14 am

Post by thrashin » Fri Mar 30, 2012 6:12 am

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

http://www.ozedesign.com.au

Newbie

Posts

Joined
Mon Nov 07, 2011 10:22 am
Who is online

Users browsing this forum: Google [Bot] and 7 guests