Closed (fixed)
Project:
Green-n-Black
Version:
5.x-1.2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Mar 2008 at 14:58 UTC
Updated:
3 Aug 2009 at 08:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
derjochenmeyer commentedHi drupalfool,
it should be easy to implement. But the problem i see is that many people will not need or want this feature...
i am still thinking about the right implementation for the coor switcher... ;-)
Comment #2
drupalferret commentedCan you tell me how to implement the image switcher code and I will customise the template then write a tutorial for others to follow so if they want it they can implement it.
Secondly, if it will help I can supply a copy of our Joomla template which uses different css stylesheets and javascript to keep the new styles set once chosen. This should give you an idea how others have approached and resolved this albeit on a different cms platform
Comment #3
derjochenmeyer commentedi would recommend this script here... it uses jquery...
http://medienfreunde.com/lab/innerfade/
im sorry, i dont have much time these days... otherwise i would try to explain how you can implement it ... but if you look at the source code it should explain itself.. you need a div container that has a certain name (id)... then just include the javascript at the head of the page.tpl.php and it will do its magic ;-)
Comment #4
drupalferret commentedI have downloaded the image rotator script as you suggested and uploaded jsquery.innerfade.js to the misc folder of the drupal installation.
have placed the following call to the script in template.php within the fourseasons adminwidget function call:
I am not sure which part of the template holds the header images so I do not know where to place the following code:
Comment #5
derjochenmeyer commentedas a general tip. Downlaod Firefox. Then download the Firebug Plugin.
It will help you a lot in figuring out what is going on in your template and where. Rcightclick on any element on a website and select "Inspect Element" from the firebug menu. It will show you the html source for any given element and it will show you which css information exists in all the different css files (and which is used).
The code of the innerfade script should all be put into the page.tpl.php ... but i didnt have the time to try it myself... Use Firebug, it will help you...
Comment #6
drupalferret commentedHi - I am already using the firefox web developer plugin and I have located the various div elements for the containers. But the part I cannot get to work is adding the javascript to the head section of the page. I tried various methods, including placing the following code into template.php to import the javascript at page-load time:
This loaded the javascript into the body of the page not the header. I then tried to add the javascript into the head section of page.tpl.php but this threw errors and broke the template. For info jquery.header-img.js looks like this: $(document).ready( function(){ $('#header-img').innerfade({ speed: 1000, timeout: 3000, type: 'sequence', containerheight: '200px' }); });the div tag for #header-img inside page.tpl.php looks like this:
Unfortunatly this script needs to be loaded directly into the head section and so far I have only managed to get it into the body section. Can you suggest anything?
Comment #7
derjochenmeyer commentedFirst: dont place the js code in the drupal/misc folder ;-) put all the custom template stuff in the theme folder
it should be something like sites/all/themes/fourseasons/innerfade/jquery.innerfade.js
then add somehting like this to your template.php
Comment #8
drupalferret commentedI tried pasting your code above directly into template.php at the end of all the existing functions and I got an error message: Parse error: syntax error, unexpected '<' in .....
In other words it is stopping at the opening
<phptag.Am I supposed to put this into template.php inside an existing function or do I create a new function?
Sorry - I am not a programmer. Thanks for your help so far :)
Comment #9
derjochenmeyer commentedi was a bit fast, try this without the php delimiters:
if i had more time i would really try to help you out, but im doing this while my customers are writing angry mails ;-)
Comment #10
zilla commentedif it helps, the marinelli theme for d6 has rotating banners - perhaps you could look over his code?
http://drupal.org/project/marinelli
Comment #11
drupalferret commentedThanks for all the help on this - I finally managed to get it to work. For anyone else who wants to get a rotating header image here is what to do:
1) Download this script which works nicely with jquery http://medienfreunde.com/lab/innerfade/
2) Create a folder called innerfade in your fourseasons theme directory.
3) Upload the file jquery.innerfade.js to your innerfade folder
4) Open template.php and paste this code at the bottom
Please note: the above code must be before the ?> at the end.
5) Open page.tpl.php and find the header-image div tag then place your image references inside it like this: (note I have put in two variables which tells drupal to put the full path to the template folder)
Remember to put in the rest of your images - as many as you need. You can also have them linking to somewhere else if required and can play with the timers within the template.php code.
Note: The tag for header image 1 id different from the first one. Image 1 has a style next to the img tag to hide the image. Image0 does not have this inline style because we want it to display first. This is important to stop all images being loaded at once to the screen. So for each extra image you add after image0 needs to use the second tag. e.g.:
6) Upload template.php and page.tpl.php and make sure the images are in the correct folder when you upload them. (in this case img/header)
Refresh your website and the header should start displaying a rotating banner.
Note: By changing the code in template.php you can have the images in sequence or random order.
Hope this helps someone to make this superb template a little more personal for their site.
Drupafool (Jim)
Comment #12
tdh commentedIs this on a live site? I would like to see it in action with the four seasons theme. Thanks.
Comment #13
derjochenmeyer commentedhey drupalfool, thanks for the great step by step tutorial. Happy you managed to get it working...
Comment #14
drupalferret commented** Bugfix to Image Rotator **
There was a problem with the images flashing before the page loaded the javascript. The following fixes this problem: (Thanks derjochenmeyer)
1) Open page.tpl.php and add the following code next to the img tag for each image except the first one:
so the image tag should now look like this:
Next open template.php and change add this to the code:
so the template.php code for our image rotator should now look like this:
For the sake of completeness I have edited the tutorial above with the new code
Comment #15
derjochenmeyer commentedComment #16
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #17
Vially commentedHi drupalfool, and thanks for sharing your work with us first of all. I have followed your step by step tutorial and it works beautifully.
However, there is something weird going on with this js. Yesterday someone said that the images were switching too fast and indeed, it seemed right to me. I opened the small javascript file and modified the time between slides from 2000 to 10000, but to my surprise, nothing changed, or at least the duration between the slides is not 10 secs but more close to 4 secs. Could you please check your implementation and see if you can change the slide duration ?
Thanks a lot.
Later edit: Yes, I have cleared the cache :)
Comment #18
drupalferret commentedHi Vially
Have you got a url where I can see the problem in action?
Thanks
Comment #19
drupalferret commentedTry first changing the time in template.php. Look for this code and change the speed to 3000 and the timeout to 20000 then see what happens:
drupal_add_js(path_to_theme('fourseasons') . '/innerfade/jquery.innerfade.js');
drupal_add_js('
$(document).ready(function(){
$("#header-image img").show();
$("#header-image").innerfade({
speed: 3000,
timeout: 20000,
type: "sequence",
containerheight: "200px"
});
});
', inline);
==========
NOTES:
==========
Transition Time
The setting: speed: 3000 sets the transition speed between the pictures. In this case the transition time is 3 seconds between pictures. Increasing this to 5000 will make the transition time 5 seconds between pictures.
Display Time
The setting: timeout: 20000 sets the picture display time. In this case the picture is displayed for 20 seconds then the next one for 20 seconds. Increasing this value will increase the time for which the picture is displayed.
Comment #20
drupalferret commentedI received a really nice email from Todd Hoegner (drupal username tdh) who told me how pleased he was with the Image Rotator tutorial. He had been playing around with it and managed to get it working by placing the images inside a block. Naturally this gives you a lot of control over where it can be placed and brings up a whole host of potential uses. Todd kindly documented how he did it and his tutorial is below:
====================================================
How to get the image rotator working using blocks
====================================================
Tutorial originally created for header images by drupalfool and adapted by tdh to work inside blocks.
1) Download this script which works nicely with jquery http://medienfreunde.com/lab/innerfade/
2) Create a folder off of your main drupal installation for /images/rotate
3) Upload the file jquery.innerfade.js to this folder
4) Open template.php and paste this code at the bottom:
Please note: the above code must be before the
?>at the end.5) Create a new block and paste the following code in the block (be sure to use full html for the block):
You can add as many images as you like, the first image must use the code like:
The remaining images must use the code like:
Also, with the block, the images must not have any character returns between them, they must
all be on the same line (text wrapping within the block is ok, just not a new line). If the images are not all on the same line, blank spots will be added in between the images and the following images after the first one will "jump" up a bit.
6) Upload template.php and make sure the images are in the correct folder when you upload them (in
this case images/rotate)
7) Visit the blocks administration and activate the newly created block to where you would like it to display.
Refresh your website and the header should start displaying a rotating banner.
Note: By changing the code in template.php you can have the images in sequence or random order.
Transition Time
The setting: speed: 1000 sets the transition speed between the pictures. In this case the transition
time is 1 seconds between pictures. Increasing this to 5000 will make the transition time 5 seconds
between pictures.
Display Time
The setting: timeout: 8000 sets the picture display time. In this case the picture is displayed for
8 seconds then the next one for 8 seconds. Increasing this value will increase the time for which the
picture is displayed.
Comment #21
frednwright commentedDrupalfool,
First of all - thanks so much for taking the time to make this tutorial! If we all do what you have done for the various problems that we solve, this site will become an even more effective resource and more attractive to newcomers.
I am trying to implement Innerfade on a theme called Ad Agency. I can't get it to work! I am attaching the page.tpl.php file and template.php. The pertinent div ID is "homepic". I am trying to get the big central banner to rotate. I realize you don't have time to do this for every single theme, but any ideas or help you can give me would be GREATLY appreciated!
Fred
Comment #22
drupalferret commentedHi frednwright
The following code seems to be missing from your template.php:
Comment #23
Etje commentedThanks for the really nice work guys. I am trying to have this working on my own site. The given code implements a fixed list of images. I would like to let my users upload photo's to a certain folder (eg files\images\header) through a header-node with a cck image-field. Does anyone know a solution to have innerfade collect the images from this folder automatically (as in: without me adding img-statements manually)?
Etje
Comment #24
jlatham06 commentedI am having a small issue with the image rotator. The rotator works fine, but I cannot seem to center it on the block without it messing up. It will center, but then displays all of the images it is supposed to rotate, instead of just rotating in new images in the same spot. Please help.
Comment #25
shittii commentedI'm trying to get Image Rotator working inside a block. I'm loosing my mind here! I'm using the Ubiquity theme and just like in Four Season theme, I cannot find the ?> at the end of theme's template.php! So I'm truly clueless where to paste this snippet:
Here's the template.php attached. I have followed drupalfool's (and tdh's) guides carefully. I assume I don't need to modify my page.tlp.php?
Comment #26
derjochenmeyer commentedHi shittii, just put it at the end... there is not always a ?> at the end of the template file...
then you need to modify your tpl.php file!
this jquery looks for a div with an id called "rotate-image"
so in your tpl.php file there should be something like:
make sure the images are in your themes folder under /img/header/
EDIT: sorry forgot you wanted to use that in a block... you have to create a block template file for this block and put the code above ... or the easier way is: create a block on the blocks administration screen... set the input filter to PHP and then paste the code above ...
Comment #27
workbench commentedI've tried to make this work in drupal 6.2 but with no luck...
It only slides the alt text "header image 0" etc...
This is how the page.tpl.php looks like;
And template.php;
Don't know if I have to edit style.css, but it look like this;
The script doesn't want to slide images - only the text.
It should look easy to fix, but I've tried everything.
Images are stored at themes/fourseasons/img/header/ and named as I've wrote page.tpl.php
Help please?
Comment #28
spcomputing commentedI'm having the exact same problem as workbench. Has anybody been able to get this to work on Drupal 6.2? Can we re-open this issue?
Comment #29
derjochenmeyer commentedFor everybody, looking for an Image rotator, there is anohter solution that i used in a site that im working on right now for D6. Wait 6 seconds on the frontpage ;-)
DEMO: http://www.arco-mountainexperts.com/
I use the jquery cycle plug-in, which offers a lot of effects: http://malsup.com/jquery/cycle/
In my page.tpl.php i use the following code:
then (simplyfied for this example) i use the following code in the template.php (make sure you download and copy the plug-in from the project page http://malsup.com/jquery/cycle/):
* this approach adds the additional images (hidden) after the page has loaded, using jquerys append().
* then initiallizes the cycle plugin
* check the plugin homepage for instructions, how to use all the cool effects: http://malsup.com/jquery/cycle/
Comment #30
spcomputing commentedderjochenmeyer,
Excellent post, thank you!
For some reason the path to the images that you specified in your template.php code didn't work for me. I had to change it to this:
$("#headerimages").append("<img src="PathToImg/header2.jpg\" style=\"display:none;\" width=765Again, thank you for a very helpful post.
Comment #31
orange peel commented**edit** nevermind on the JQuery Cycle Lite, got it to work, thanks for the code, I love it!! I just wish IE 7 faded/transistioned cleaner like Firefox does for png files. IE outlines the images in black when it fades, Firefox just fades away clean and clear.
-Scott
Comment #32
drupalferret commentedTo make the original code work in Drupal 6.X you need to remove the extra / in the line of PHP then follow the original instructions. I have to admit - I never noticed the coding error myself until someone else pointed it out.
The error is as follows (notice the extra / between php statements)
It should actually look like this:
Sorry - I have not had time to try the newer version and write a tutorial yet - been really busy since I got back and trying to catch up again.
Comment #33
scottrigbyThanks drupalfool – #14 works for my 5.9 site. Cheers! Scott
Comment #34
sangu commentedHi,
I tried image rotator using blocks as given by drupalfool - March 30, 2008 - 20:26 (#20), and it was a success until i checked it in Internet Explorer 6.0. It works all right in Firefox.
In I.E., i can see only the first image (no fading, nothing).
Here is how i used it:
Did anyone come across this problem in I.E.? Help would be appreciated.
Thanks.
Comment #35
khan2ims commentedHi,
This is working like a charm on my site ..
I have a problem though .. Right now its left aligned .. I want to right align it and put content on the left, like we do for riight aligned images .. But when I am trying to right align by
i am using a custom theme
Anybody, plz guide me !!!
Comment #36
khan2ims commentedHi,
I was also wondering if its possible to stop playing of image rotator after first play .. If we would give a kind of stop/ play button?
Comment #37
fletchgqc commentedThere's a module called "slideshow_creator" that does a lot of this for you. But it's got a few wierd features like it crops pictures. Anyway the code in #29 is excellent - but it's better to install the jquery_plugins module and change one of the add_js lines to:
Comment #38
khan2ims commentedEarlier I was using script mentioned by derjochenmeyer. But today I saw that the rotating images are no more working. I tried making changes for Drupal 6 but without result. Then I went through these steps for block mentioned by drupalfool and successfully pulled it off for our home page @ http://www.newearthmarketing.com
Great!! Thanks.
Imran Khan
Project Manager
New Earth Marketing