PDA

View Full Version : content slider - remove previous and next links when only 1 page



cold drink
09-09-2008, 02:46 PM
1) Script Title: content slider v.2.4

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/featuredcontentslider.htm

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

rangana
09-09-2008, 03:47 PM
Try to add highlighted on contentslider.js to comment the building of next and previous link:


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
}

cold drink
09-09-2008, 04:34 PM
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.

rangana
09-10-2008, 12:02 AM
Now I understand what you mean, try to add highlighted instead:


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.

cold drink
09-10-2008, 02:42 PM
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:



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.