Results 1 to 5 of 5

Thread: content slider - remove previous and next links when only 1 page

  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default content slider - remove previous and next links when only 1 page

    1) Script Title: content slider v.2.4

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

    3) Describe problem: Is there a way to have the previous and next links not show when there is only one page?

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Try to add highlighted on contentslider.js to comment the building of next and previous link:
    Code:
    buildpaginate:function(setting){
    	this.buildcontentdivs(setting)
    	var sliderdiv=document.getElementById(setting.id)
    	var pdiv=document.getElementById("paginate-"+setting.id)
    	var phtml=""
    	var toc=setting.toc
    	var nextprev=setting.nextprev
    	if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){
    		for (var i=1; i<=setting.contentdivs.length; i++){
    			phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a> '
    		}
    		//phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')
    		pdiv.innerHTML=phtml
    	}
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Commenting that line out does remove the previous and next links. The problem is that my content slider uses ajax to pull in a php page for the "contentsource". So, I'd want the previous and next links to display when there is more than one page. I just don't want them to display when there is only one page.

    I see in the js where it sets the previous and next links but I'm not sure how to set display:none if there's only one page.

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Now I understand what you mean, try to add highlighted instead:
    Code:
    	if(document.getElementById(setting.id).getElementsByTagName("div").length>1)		
    phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')
    		pdiv.innerHTML=phtml
    See if it helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks I got it working. getElementsByTagName("div").length was giving me 11 even though there was only 1 content div. But, I used setting.contentdivs.length to get the number of pages and it worked:

    Code:
    		if(setting.contentdivs.length>1)
    		{
    		phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')
    		pdiv.innerHTML=phtml
    		}
    Thanks for pointing me in the right direction.

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
  •