PDA

View Full Version : Featured Content Slider Linking Issue



jnegron
03-06-2008, 05:20 PM
1) Script Title: Featured Content Slider

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

3) Describe problem: Been working on implementing the "Featured Content Slider" and have run into an issue. Id like to create a link from within the content that would link to another one of the content slides. Tried different things but nothing seems to work. Anyone out there may have a suggestion?

thanks in advance.
JN

ddadmin
03-06-2008, 09:45 PM
Sure, you can do so using the private function:


ContentSlider.turnpage('slider_id', pagenumber)

Change "slider_id" to the ID of the Content Slider itself, and pagenumber, the page you wish to go to (0=page 1). For example:


<a href="javascript:ContentSlider.turnpage('slider1', 0)">Go to page 1</a>

jnegron
03-07-2008, 05:03 PM
you rock. thanks. worked perfectly.

ptengler
06-05-2008, 03:27 PM
Hello,

This is exactly what I need, but I can't make it work. I get the Error: 'contentslider' is undefined.

I have a contact form as one of the slides (slide 4), and I want to make the slider show this form when clicking on a link in slide 2. The slider-id is 'content':

<a href="javascript:contentslider.turnpage('content', 3)">Contact Form</a>

The main page (index.html), the content page (content.html) and the contentslider.js are separate files. The javascript file is referenced in the index.html only, and the contentslider.js is in a seperate 'js' folder.

I've tried to reference the javascript in the content.html too, but this didn't help.

Any idea what I'm doing wrong?

Many thanks in advance.
Petr

ddadmin
06-05-2008, 07:11 PM
Hi Petr:
Please post a link to the page on your site that contains the problematic script so we can check it out.

ptengler
06-06-2008, 06:13 AM
Hello,
here it is: http://www.mille-feuilles.ch/

The link is in the section 'activités', the 11th bullet point from the top:
Contact: Formulaire de contact"

ddadmin
06-06-2008, 09:01 AM
I see the problem. JavaScript is case sensitive, so you need to capitalize the "C" in your link:


<a href="javascript:Contentslider.turnpage('content', 3)">.....</a>

ptengler
06-06-2008, 09:28 AM
I've tested your suggestion locally (I can't upload it from where I am right now) and the problem persists. My javascript filename is in lowercase "contentslider.js".
I have referenced it like this in the index.html page:
<script type="text/javascript" src="js/contentslider.js">

In any case, somehow he isn't able to see the js file. Do I have to define the private function (or its location) somewhere ?

ddadmin
06-06-2008, 09:50 AM
Actually, this has nothing to do with the case sensitivity of the file "contentslider.js". Contentslider.turnpage() is the name of the method within this file that you're calling, which is case sensitive (ie: the "C" must be capitalized).

ptengler
06-06-2008, 10:40 AM
I have checked how the .init method is called from the main page (featuredcontentslider.init) and I changed the call accordingly to:
<a href="javascript:featuredcontentslider.turnpage('content', 3)">

This time it seems that the method is found, but I get another error:
"contentdivs.length is null or not an object", referring to this part of the script:

var totalpages=setting.contentdivs.length
var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage)
turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage

ddadmin
06-06-2008, 11:28 AM
Ah there's a problem with the code I posted above- it's based on the old Featured Content Slider script. Sorry, forgot that the old and current version's turnpage() function behaves differently from one another.

I'll see if I make some changes to the new version later today to easily support turning pages by calling a method. Will update this thread.

ddadmin
06-06-2008, 10:49 PM
Ok, to explicitly turn to a particular slide by calling a method in Featured Content Slider v2.0, use the modified .js file below. Then, you'd have a link like:


<a href="javascript:featuredcontentslider.slideto('slider1', 2)">Turn to 2nd slide</a>

Where "slider1" is the ID of your slider instance, and 2 is the slide to turn to (1=1st slide etc).

ptengler
06-09-2008, 12:33 PM
Great ! Many thanks !