PDA

View Full Version : How to make a normal URL work inside Featured Content Glider?



nberidze
02-04-2015, 10:14 AM
1) Script Title: Featured Content Glider

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

3) Describe problem: How to insert a normal URL into the script so that when the reader clicks on one of the items, browser follows that URL normally (as opposed to displaying current/previous/next item in glider.)

ddadmin
02-04-2015, 10:59 PM
Hmm please clarify what you mean by insert a link into the script. Do you mean a link inside one of the content slides? If so each content slide's actual content is just HTML, so you're free to define any HTML you like inside it, for example:


<div class="glidecontent">
<img src="http://i15.tinypic.com/72vilba.jpg" style="float: right; padding: 5px"/>
Ontario is a province located in the central part of Canada, the largest by population and second largest, after Quebec in total area. Toronto, the capital of Ontario, is the centre of Canada's financial services and banking industry. <a href="http://www.google.com">Google</a>
</div>

nberidze
02-08-2015, 04:13 PM
Hmm please clarify what you mean by insert a link into the script. Do you mean a link inside one of the content slides? If so each content slide's actual content is just HTML, so you're free to define any HTML you like inside it, for example:


<div class="glidecontent">
<img src="http://i15.tinypic.com/72vilba.jpg" style="float: right; padding: 5px"/>
Ontario is a province located in the central part of Canada, the largest by population and second largest, after Quebec in total area. Toronto, the capital of Ontario, is the centre of Canada's financial services and banking industry. <a href="http://www.google.com">Google</a>
</div>

No, I mean to include an URL inside the selector - the area where you can choose previous/current/next item in the glider. I'm looking at a theme where the creator has modified this glider code so that there is a selector area and a featured post area. The selector area contains the headlines of all five featured posts, while the featured posts rotates between the five. When you click on one of the items in the selector area, the corresponding post (excerpt+thumbnail) appears in the featured post area.

Our readers have asked: is it possible to click on the selector area and go directly to the full post? To do that we would have to have a URL in the selector area. I've tried, but it made some strange changes. So I was wondering, has anybody else done this, and is there a recommended way to do it?

nberidze
02-13-2015, 11:50 AM
I want the link in the selector, not the glider content. Many of our readers have asked to make the selector point directly to the full article, not the glider content.

ddadmin
02-13-2015, 04:23 PM
Hmm, the "selector" section of the script is also implemented as regular HTML (with certain class names triggering special functionality). So if you want to swap out the default pagination links with links that actually go to specific URLs, you can simply do so via regular HTML, ie:


<div id="p-select" class="glidecontenttoggler">
<a href="#" class="prev">Prev</a>
<a href="http://www.dynamicdrive.com">Page 1</a> <a href="http://www.cssdrive.com">Page 2</a> <a href="http://www.google.com">Page 3</a>
<a href="#" class="next">Next</a>
</div>

Or are you asking for a way to store all the URLs inside a JavaScript variable and have the links dynamically generated? This would only make sense if you have lots of links.

nberidze
02-24-2015, 07:53 PM
Hmm, the "selector" section of the script is also implemented as regular HTML (with certain class names triggering special functionality). So if you want to swap out the default pagination links with links that actually go to specific URLs, you can simply do so via regular HTML, ie:


<div id="p-select" class="glidecontenttoggler">
<a href="#" class="prev">Prev</a>
<a href="http://www.dynamicdrive.com">Page 1</a> <a href="http://www.cssdrive.com">Page 2</a> <a href="http://www.google.com">Page 3</a>
<a href="#" class="next">Next</a>
</div>

Or are you asking for a way to store all the URLs inside a JavaScript variable and have the links dynamically generated? This would only make sense if you have lots of links.

No, the first one. Just a normal URL. I want the selector to show the featured story which the pointer hovers over, but if the user clicks, he/she gets sent to the actual URL of that article.

This is a very common type of funtionality.

ddadmin
02-24-2015, 09:10 PM
No, the first one. Just a normal URL. I want the selector to show the featured story which the pointer hovers over, but if the user clicks, he/she gets sent to the actual URL of that article.

This is a very common type of funtionality.

Ah ok you should have just said that then- show feature story onmouseover, go to a URL onclick. :)

Try the below modified .js file, which selects a panel when the mouse rolls over one of the pagination links. Your pagination links should still contain a CSS class of "toc", but with a href defined to point to a URL (so it goes to that page when clicked on):


<div id="p-select" class="glidecontenttoggler">
<a href="#" class="prev">Prev</a>
<a href="http://www.cnn.com" class="toc">Page 1</a> <a href="http://cssdrive.com" class="toc">Page 2</a> <a href="http://dynamicdrive.com" class="toc">Page 3</a>
<a href="#" class="next">Next</a>
</div>

nberidze
02-24-2015, 09:40 PM
Thanks! Can you look a little bit at my code. I am using the wordpress theme BTextended, which is using a modified featured content glider.


<div id="togglebox" class="glidecontenttoggler">
<a href="#" class="prev"></a>
<?php
$slidecat = get_option('BTExtended_slide_category');
$my_query = new WP_Query('showposts=5&offset=0');
while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
?>
<a href="#" class="toc">
<small><?php
$category = get_the_category();
echo $category[0]->cat_name;
?></small>
<span class="fet"><?php the_title(); ?></span>
<small>by <?php the_author(); ?></small>
</a>
<?php endwhile; ?>
<a href="#" class="next"></a>
</div>

So: where do I insert your code snippet?

ddadmin
02-24-2015, 11:03 PM
Ok with PHP and templating involved you probably don't want to edit that part of your page unless you're familiar with PHP. Is the entire markup of your featured content glider dynamically generated, ie, the following portion as well:


<div id="canadaprovinces" class="glidecontentwrapper">

<div class="glidecontent" data-url="http://www.cnn.com">
<img src="http://i11.tinypic.com/8efzmmf.jpg" style="float: left; padding: 5px" />
British Columbia is the westernmost of Canada's provinces and is famed for its natural beauty. It's capital is Victoria, located at the southeastern tip of Vancouver Island. BC's most populous city is Vancouver, located in southwest corner of the BC mainland called the Lower Mainland.
</div>

<div class="glidecontent" data-url="http://www.google.com">
<img src="http://i15.tinypic.com/72vilba.jpg" style="float: right; padding: 5px"/>
Ontario is a province located in the central part of Canada, the largest by population and second largest, after Quebec in total area. Toronto, the capital of Ontario, is the centre of Canada's financial services and banking industry.
</div>

<div class="glidecontent" data-url="http://www.dynamicdrive.com">
<img src="http://i17.tinypic.com/8bg0lkx.jpg" style="float: left; padding: 5px"/>
Yukon, still commonly referred to as "The Yukon Territory", is the westernmost of Canada's three northern territories. The Yukon's major appeal is its nearly pristine nature. Tourism relies heavily on this and there are many organised outfitters and guides available to hunters and anglers and nature lovers of all sorts.
</div>

</div>

I'm trying to figure out which portion is not- and just static HTML you add manually to your page- in which I can use to define the URL of each pagination link.

nberidze
02-25-2015, 07:50 AM
Here is the whole featured.php.

ddadmin
02-25-2015, 04:48 PM
Hmm the zip file didn't seem to have uploaded properly. Please re-zip and upload again.

nberidze
02-25-2015, 06:25 PM
5598 here

ddadmin
02-26-2015, 09:07 PM
Ok, try the latest modified .js file,which lets you specify a list of URLs to go to when the pagination links are clicked on, respectively, inside the initialization portion of the script. This lets you define the URLs without touching the dynamic, PHP generated portion of the script. To specify the links, add the code in red to your initialization code:


<script type="text/javascript">

featuredcontentglider.init({
gliderid: "canadaprovinces", //ID of main glider container
contentclass: "glidecontent", //Shared CSS class name of each glider content
togglerid: "p-select", //ID of toggler container
remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable
selected: 0, //Default selected content index (0=1st)
persiststate: false, //Remember last content shown within browser session (true/false)?
speed: 500, //Glide animation duration (in milliseconds)
direction: "downup", //set direction of glide: "updown", "downup", "leftright", or "rightleft"
autorotate: true, //Auto rotate contents (true/false)?
paginationlinks: ['http://cnn.com', 'http://google.com', 'http://dynamicdrive.com'],
autorotateconfig: [3000, 2], //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
onChange: function(previndex, curindex, $allcontents){ // fires when Glider changes slides
//custom code here
}
})


</script>

nberidze
02-26-2015, 09:53 PM
Alright, thanks. But I want the reader to be able to click on each of the (in my case) five elements in the selector, and go to the full article. So somehow, paginationlinks must contain those five links. Links to the last five posts. How to do that? When I tried this, it worked for the first item in the selector, but not the next four.

To have an extra loop in there would not be desirable, as it would slow down the server.

ddadmin
02-27-2015, 04:30 AM
Alright, thanks. But I want the reader to be able to click on each of the (in my case) five elements in the selector, and go to the full article. So somehow, paginationlinks must contain those five links. Links to the last five posts. How to do that? When I tried this, it worked for the first item in the selector, but not the next four.


Hmm by "each of the (in my case) five elements in the selector" do you mean each pagination link should go to a different URL, so if you have 5 pagination links, that means 5 links? If so this is simply done by specifying 5 links inside the paginationlinks option:


paginationlinks: ['http://cnn.com', 'http://google.com', 'http://dynamicdrive.com', 'http://javascriptkit.com', 'http://cssdrive.com'],

nberidze
02-27-2015, 06:17 AM
Did you read my featured.php? If so, you see that the togglebox queries wordpress for five posts and shows the title, category and author of each. I want the reader to be able to open the permalink to the corresponding post by clicking.

ddadmin
02-27-2015, 06:37 AM
Looking at featured.php in more detail now, I gather this is the portion of each pagination link that you actually want to onmouseover to load a panel, and onclick to go to a specific URL:


<span class="fet"><?php the_title(); ?></span>

?

Do you have a link to the fully generated page? It'll make things lot easier to picture.

nberidze
02-27-2015, 09:13 AM
I have sent you the link in a private message. Please get back to me when you have had a chance to look at it.