• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Image rotation question
PostPosted: Wed Aug 08, 2012 4:24 pm 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 860
Location: London
I have a query which I am trying to see if anyone has an idea (better / different to mine) for rotating the display of an image.

1. Specific folder contains a number of images i.e. 1.jpg, 2.jpg, 3.jpg etc etc
2. The client wants the site to show the first image for say 5 days and after which show the second image etc etc
3. If all the images have been shown in order the loops starts again from the beginning.
4. The client also wants to be able to change the rotation frequency via the admin such as a global content block.
5. Can't use cookies.


My idea
1. Store the rotation frequency period in a GCB.
2. Write a UDT which check the modified date of the GCB against the number entered for the frequency.
3. If the modified date is greater than the number of days of the rotation then read from the folder the filenames against which to check whether or not the next image exists and if not start again.
4. The UDT would have to write to / update another GCB the number of the last image used and check against that.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Wed Aug 08, 2012 6:36 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11812
Location: Arizona
Make a {content block='rotateimage' label='For rotating images only'} then they can come back every 5 days, or whenever they want, and change the image... ;)

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Wed Aug 08, 2012 9:44 pm 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 860
Location: London
Sure but they want it automated...


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Wed Aug 08, 2012 10:58 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6576
Location: Fernie British Columbia, Canada
I would do a udt something like this (untested)

Code:
  $config = cmsms()->GetConfig();
  $files = glob($config['uploads_path'].'/images/foo/img*.jpg');
  $n_images = count(files);
  $week = date('W');
  echo $config['uploads_url'].'/images/foo/img'.($weeknumber % $num_images).'.jpg';


Make sure the images to be rotated are in their own subdirectory... this code should rotate the images every 7 days.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Wed Aug 08, 2012 11:45 pm 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 860
Location: London
Thanks Robert but that would make it random so will probably suggest that they just upload 52 images even if they have to repeat after a certain number and use something like

Code:
$week = date('W');
echo 'uploads/images/foo/img'.$week.'.jpg';


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Wed Aug 08, 2012 11:48 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6576
Location: Fernie British Columbia, Canada
actually, don't think so.. it'd rotate sequentially through all of the images... changing once per week.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Thu Aug 09, 2012 12:25 am 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 860
Location: London
Re: ($weeknumber % $num_images)

I thought the % sign is the modulus operator
i.e. 9 / 2 remainder 1


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Thu Aug 09, 2012 12:41 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6576
Location: Fernie British Columbia, Canada
okay... but if you had say 8 images:

week 9 % 8 = 1
week 10 % 8 = 2
week 11 % 8 = 3
week 12 % 8 = 4
week 13 % 8 = 5
week 14 % 8 = 6
week 15 % 8 = 7
week 16 % 8 = 0

get it.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: Image rotation question
PostPosted: Thu Aug 09, 2012 12:14 pm 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 860
Location: London
Yes sequential not random, thanks for clarifying.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting