Results 1 to 4 of 4

Thread: Featured Content Slider v2.5 - Using multiple external content sources

  1. #1
    Join Date
    Aug 2013
    Location
    PGH PA US
    Posts
    12
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Post Featured Content Slider v2.5 - Using multiple external content sources

    1) Script Title: Featured Content Slider v2.5

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

    3) Describe problem: I'm using this script to display the output items (each individual item is wrapped in a "contentdiv" tag) of a php file located on my home server. It's been a successful test run to this point but I have additional, similar files (at least 5 more) on my server for which I would like to have their content displayed in the same manner.

    My questions are:

    1. Is this script capable of processing multiple external files via the contentsource: ["ajax", "path_to_file"] parameter, be it out of the box or with modifications to the contentslider.js file? And, if so,
    2. Will the script process the output of each file in order? That is, will the script display all "contentdiv" tagged items in external file "A" then all "contentdiv" tagged items in external file "B", then "C", etc. etc.?


    Thanks so much in advance!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,821
    Thanks
    2
    Thanked 425 Times in 419 Posts

    Default

    the following 3 functions will need replacing

    Code:
    ajaxconnect:function(setting){
    	var page_request = false
    	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
    		try {
    		page_request = new ActiveXObject("Msxml2.XMLHTTP")
    		}
    		catch (e){
    			try{
    			page_request = new ActiveXObject("Microsoft.XMLHTTP")
    			}
    			catch (e){}
    		}
    	}
    	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
    		page_request = new XMLHttpRequest()
    	else
    		return false
    	var pageurl=setting.contentsource[setting.an];
    	page_request.onreadystatechange=function(){
    		featuredcontentslider.ajaxpopulate(page_request, setting)
    	}
    	var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    	page_request.open('GET', pageurl+bustcache, true)
    	page_request.send(null)
    },
    
    ajaxpopulate:function(page_request, setting){
    	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    		document.getElementById(setting.id).innerHTML+=page_request.responseText
            setting.an++;
            if (setting.contentsource[setting.an]){
      		 this.ajaxconnect(setting);
    
            }
            else {
             this.buildpaginate(setting);
           }
    	}
    },
    
    init:function(setting){
    	var persistedpage=this.getCookie("fcspersist"+setting.id) || 1
    	var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index
    	this.settingcaches[setting.id]=setting //cache "setting" object
    	setting.contentdivs=[]
    	setting.toclinks=[]
    	setting.topzindex=0
    	setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1)
    	setting.prevpage=setting.currentpage
    	setting.revealtype="on"+(setting.revealtype || "click")
    	setting.curopacity=0
    	setting.onChange=setting.onChange || function(){}
    	if (setting.contentsource[0]=="inline")
    		this.buildpaginate(setting)
    	if (setting.contentsource[0]=="ajax"){
        	document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg
            setting.an=1;
    		this.ajaxconnect(setting);
        }
      }
    
    }

    and the ajax files listed in the contentsource array

    Code:
    featuredcontentslider.init({
    	id: "slider1",  //id of main slider DIV
    	contentsource: ["ajax", "a1.htm", "a2.htm"],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
    	toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]
    	nextprev: ["Previous", "Next"],  //labels for "prev" and "next" links. Set to "" to hide.
    	revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
    	enablefade: [true, 0.2],  //[true/false, fadedegree]
    	autorotate: [true, 3000],  //[true/false, pausetime]
    	onChange: function(previndex, curindex, contentdivs){  //event handler fired whenever script changes slide
    		//previndex holds index of last slide viewed b4 current (0=1st slide, 1=2nd etc)
    		//curindex holds index of currently shown slide (0=1st slide, 1=2nd etc)
    	}
    })
    the ajax files will be loaded in order
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    yuengling25 (07-31-2014)

  4. #3
    Join Date
    Aug 2013
    Location
    PGH PA US
    Posts
    12
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Works a charm from the quick test I just did using two separate files. No reason to believe it won't work just as well with 3+. The only problem I found was that the "Fetching slider Contents. Please wait..." text and the gif remain visible while the slider cycles through the content. For a quick (albeit "wonky") fix, I just deleted the <img src= reference to the gif and the "Fetching...." text from within the ajaxloadingmsg div, and all was right with the world. That said, is there a better and more proper way to go about it?

    Thanks so much for the help!

  5. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,821
    Thanks
    2
    Thanked 425 Times in 419 Posts

    Default

    Code:
    ajaxpopulate:function(page_request, setting){
    	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    		var o=document.getElementById(setting.id);
            o.innerHTML+=page_request.responseText
            setting.an++;
            if (setting.contentsource[setting.an]){
      		 this.ajaxconnect(setting);
    
            }
            else {
             o.removeChild(o.childNodes[0]);
             this.buildpaginate(setting);
           }
    	}
    },
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. The Following User Says Thank You to vwphillips For This Useful Post:

    yuengling25 (08-01-2014)

Similar Threads

  1. Combining Featured Content Slider with Featured Content Glider problems.
    By ortizhj in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-18-2011, 03:12 PM
  2. Replies: 4
    Last Post: 12-19-2010, 09:46 AM
  3. Replies: 2
    Last Post: 07-28-2010, 01:15 PM
  4. Multiple Featured Content Slider v2.4 Issue
    By eslaydon in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 02-04-2009, 03:58 AM
  5. Featured Content Slider - external data
    By sol07 in forum Dynamic Drive scripts help
    Replies: 32
    Last Post: 08-14-2007, 08:37 AM

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
  •