Results 1 to 9 of 9

Thread: Featured Content Slider, Can I Make My Own Buttons?

  1. #1
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Featured Content Slider, Can I Make My Own Buttons?

    1) Script Title: Featured Content Slider

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tentslider.htm

    3) If I wanted to create my own buttons that would display associated content in the Featured Content Slider after being clicked, what function from within its javascript would I use as my buttons' "onClick". Basically, what function gets called each time you click one of the pagination links? Or maybe I'm mistaken, is that how you would even go about having your own specially designed pagination buttons? Note: The buttons I'm creating are each different in appearance, so it's not going to be the same looking button repeated. If anyone can figure this one out I feel it'd make for a really cool addition to this script

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It depends. Do you want your images to appear in place of the text links or along with them?

    Here is the typical generated code for a link:

    HTML Code:
    <a class="" href="#" onclick="ContentSlider.turnpage('slider2', 1); return false">2</a>
    It switches to the second content in the slider with the id slider2. If you were to just put something like that on your page somewhere with an image:

    HTML Code:
    <a href="#" onclick="ContentSlider.turnpage('slider2', 1); return false"><img src="thumb_2.gif" border="0"></a>
    It would probably work to load up the 2nd content but, unless the generated text links were also present, there would probably be an error. Their visibility could be set to hidden in a stylesheet though (for slider with id slider2):

    Code:
    #paginate-slider2 {
    visibility:hidden;
    }
    If you wanted to hack the script to put in images in place of the text, here is where and how that might be done, the red lines generate text links:

    Code:
    ContentSlider.buildpagination=function(sliderid){
    var paginatediv=document.getElementById("paginate-"+sliderid) //reference corresponding pagination DIV for slider
    var pcontent=""
    for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link
    pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(i+1)+'</a> '
    pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">Next</a>'
    paginatediv.innerHTML=pcontent
    paginatediv.onclick=function(){ //cancel auto run sequence (if defined) when user clicks on pagination DIV
    if (typeof window[sliderid+"timer"]!="undefined")
    clearTimeout(window[sliderid+"timer"])
    }
    }
    Here they are alone with the parts that generate the actual text highlighted:

    Code:
    pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(i+1)+'</a> '
    pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">Next</a>'
    Now let's zoom in on these parts and offer alternatives for images:

    Code:
    '+(i+1)+'
    could be replaced with this code:

    Code:
    <img src=thumb_'+(i+1)+'.gif border=0>
    For that to work, you would need images with these names:

    thumb_1.gif
    thumb_2.gif
    thumb_3.gif

    and so on, available for however many content items you have. This part:

    Code:
    Next
    is easier. You could just replace it in the code with an image tag:

    Code:
    <img src=next.gif border=0>
    Note: if you want to use the proper (for HTML) quoting:

    Code:
    <img src=\"thumb_'+(i+1)+'.gif\" border=\"0\">
    and:

    Code:
    <img src=\"next.gif\" border=\"0\">
    escape it as shown just to be on the safe side.
    Last edited by jscheuer1; 11-11-2006 at 05:20 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John As usual, your advice worked beautifully! I hope other javascript novices read this post because what it enables you to do with the Featured Content Slider is absolutely awesome.

    - Josh

  4. #4
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Can I make my buttons chrome? As like gradient?

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by johnhu_2005 View Post
    Can I make my buttons chrome? As like gradient?
    Easiest way would be to just follow the instructions as laid out in this thread. The only difference would be to use gradient images.

    If you want to get fancy, now that you see where to edit the code, if you would be happy with just the defaults as text on the buttons, you could create a single gradient image as the background image for the buttons.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Nov 2006
    Location
    IA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation I have text problems

    I tryed changing the text name from '+(i+1)+' to the text I want by inserting
    Code:
    for (var i=N)
    with N being the page I want the choice of name applyed. Is this way actually possible. i get a syntax error and i don't know why? If not in what way can I give paginations a name of my choice other than text images?

    I originally had post at: http://www.dynamicdrive.com/forums/s...ad.php?t=17824

    ddadmin obviously sent me here.

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Lets make it more straightforward for you Open up the .js file, and add to it at the very top this line:
    Code:
    var contentpagelinks=["dogs", "cats", "babies", "bunnies"] //Change links text to your own, one for each page
    Then, find the line:

    Code:
    pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(i+1)+'</a> '
    and change that to:
    Code:
    pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+contentpagelinks[i]+'</a> '
    That's it. Change "dogs", "cats", "babies" to your own link text of course. I've attached the modified .js file as well.

  8. #8
    Join Date
    Nov 2006
    Location
    IA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, I got it fixed up and running. Sorry for the hastle. Javascript is different from most programming languages.

  9. #9
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question transitions effect

    thanks jscheuer1 for the detailed instructions. Any ideas how to make a transitions effect like fade .

    thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •