Results 1 to 3 of 3

Thread: Featured Content Slider: Linktext array in columns?

  1. #1
    Join Date
    Aug 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Featured Content Slider: Linktext array in columns?

    Hello DD forum:
    i am using the Featured Content Slider http://www.dynamicdrive.com/dynamici...tentslider.htm
    i would like to have the list of links arranged in columns, because my list is long. Please see the attached imgs, the first one showing how i would like the list to look, the second one showing how it currently looks.

    any help is appreciated!!

    rv

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

    Default

    Basically it comes down to hacking contentslider.js, specifically, the output of the pagination links (variable pcontent) so instead of just a string of <a> tags, additional HTML is thrown in to organize them into columns. I spent a little time, and here's what I came up with. Inside contentslider.js, replace the following 3 lines:

    Code:
    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\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a> '
    	pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.nextText || "Next")+'</a>'
    	paginatediv.innerHTML=pcontent
    With the below instead:

    Code:
    var linkspercolumn=3
    	for (var i=0; i<slidernodes[sliderid].length; i++){ //For each DIV within slider, generate a pagination link
    		pcontent+=(i==0)? '<div class="column">' : (i>=linkspercolumn && i%linkspercolumn==0 && i<=slidernodes[sliderid].length-1)? '</div>\n<div class="column">' : ""
    		pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a>\n '
    	}
    	pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.nextText || "Next")+'</a></div><br style="clear: left" />'
    	alert(pcontent)
    And inside contentslider.css, add the below new rules to the end:

    Code:
    .column{
    float: left;
    }
    
    .column a{
    display: block;
    }
    Take a look at the line in red- change "3" to the desired number of links to show per column. I also threw in an alert() statement within the code to show you what the current output for the pagination links is- when you're satisfied, remove that statement.

    Here's what a value of 3 causes the pagination links to look like. I've also attached the modified contentslider.js.
    Last edited by ddadmin; 08-28-2007 at 03:26 AM.

  3. #3
    Join Date
    Aug 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks! this works great!!

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
  •