Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > content slider paging : highlight this slide control View modes: 
User avatar
Member
Member
dcollins-marketwired - 2/6/2014 3:40:28 PM
   
content slider paging : highlight this slide control
I'm using a content slider with a doctype that contains just a jpg url and a link URL. It makes a standard slider (i.e. click on image3, go to URL3, wait for image4, click and go to URL4) with a 5s delay. Navigation is done via the common "dots" layout (i.e. 6 slides means 6 dots along the bottom).

So far I'm doing great. I made dots by enabling the slider pager, then styling it so they look like dots instead of numbers, like so:
big jpg[     . . . .     ]

The one thing I can't seem to do is restyle the current slide that's active. (At best, it should not be clickable, at least, it should be a different colour.)
big jpg[     . . . .     ]

I've been looking at the code and while there are properties attached to the jpg that indicate which one is active, there are no properties that distinguish the active click link from the inactive ones.
<div class="Slider">
<div id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero" class="Content" style="width: 780px; height: 200px; overflow: hidden; position: relative; left: 0px;">
<div
id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_0_content"
class="ContentPage"
style="
width: 780px; height: 200px;
overflow: hidden; left: 0px; position: absolute;
opacity: 1;
z-index: 10; visibility: visible;">
<a href="/foo.html">
<img src="/MWIntranet/images/HP_hero_slides/slide0.png">
</a>
</div>
<div
id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_1_content"
class="ContentPage"
style="
width: 780px; height: 200px;
overflow: hidden; left: 0px; position: absolute;
opacity: 0;
z-index: -10; visibility: hidden;">
<a href="/bar.html">
<img src="/MWIntranet/images/HP_hero_slides/slide2.png">
</a>
</div>
</div>

<div id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_pager" class="Pager" style="width:780px;">
<div class="PagerPage" style="width:10px;">
<a
id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_page_0"
onclick="
CurrentPage_p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero=0;
document.getElementById('p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_runSlider').style.display='inline';
return false;"
href="#">
1
</a>
</div>
<div class="PagerPage" style="width:10px;">
<a
id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_page_1"
onclick="
CurrentPage_p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero=1;
document.getElementById('p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_runSlider').style.display='inline';
return false;"
href="#">
2
</a>
</div>
<div id="p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_runSlider" class="Control" style="display:none;">
<a onclick="document.getElementById('p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero_runSlider').style.display='none';autoTurnPage(Slider_p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero,CurrentPage_p_lt_ctl01_pageplaceholder_p_lt_ctl00_sliderHero,5600, false); return false;" href="#">Start</a>
</div>
<div style="clear:both;height:0;line-height:0;"></div>
</div>
</div>

User avatar
Member
Member
kentico_davidb2 - 2/7/2014 6:54:03 AM
   
RE:content slider paging : highlight this slide control
Unfortunately, there is no such feature. You would need to customize the webpart itself in:
CMSWebParts/Viewers/Effects/ContentSlider

Dave

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/7/2014 7:54:41 AM
   
RE:content slider paging : highlight this slide control
The basic content slider works for simple situations but I'd recommend something like the BX Slider. Its pretty quick and easy to implement and you can have full control over your styles.

User avatar
Member
Member
dcollins-marketwired - 2/7/2014 8:06:13 AM
   
RE:content slider paging : highlight this slide control
FroggEye wrote: The basic content slider works for simple situations but I'd recommend something like the BX Slider. Its pretty quick and easy to implement and you can have full control over your styles.

Yeah, that's always an option. But it seems a shame to go full 3rd party when the provided one gets me 99% of what I need before having to customize. I'll try this until I hit a dead end before moving to 3rd party.
kentico_davidb2 wrote: Unfortunately, there is no such feature. You would need to customize the webpart itself in: CMSWebParts/Viewers/Effects/ContentSlider

Yeah, I'm currently dabbling in there.

I wonder if there's a way to make changes without overwriting an existing file. That's not very forward-compatible. Can I duplicate the webpart, customize it, then point my page that that one?

User avatar
Member
Member
dcollins-marketwired - 2/7/2014 4:04:06 PM
   
RE:content slider paging : highlight this slide control
I found a solution that works. My only concern is that it dabbles in Kentico code, meaning, if ever there's an update or migration or what-have-you, this custom snippet in the JavaScript might get overwrrtein.

In this file:
\KenticoCMS7\CMSWebParts\Viewers\Effects\ContentSlider_files\ContentSlider.js

I added the emphasized lines:
    show:function(page){  
slidernodes[this.id].each(function(item, index){
item.setOpacity(0);
item.setStyle('z-index','-10');
});
slidernodes[this.id][page].setOpacity(1);
slidernodes[this.id][page].setStyle('z-index','10');

// custom code part1of2 - DaveC 2014/02
// This, and code below, is for the homepage hero slider's navigation dots.
//
// Applies CSS class 'active-slide' to <a>'s parent element 'PagerPage'.
// <a> has a unique id whereas parent does not.
var linkId = "p_lt_ctl02_pageplaceholder_p_lt_ctl00_sliderHero_page_0";
var parentNode = $$("a#" + linkId)[0].parentNode;
parentNode.setAttribute('class', parentNode.getAttribute('class') + ' active-slide';);
// custom code part1of2 - ends
},
//turn page (fadeIn-fadeOut effect)
turnPage:function(page,isAuto){
// custom code part2of2 - DaveC 2014/02
// Removes CSS class 'active-slide' from ALL 'PagerPage' elements.
// Then adds class back to <a>'s parent 'PagerPage', based on 'page' param.
// See global.css for styling of .PagerPage.active-slide

var linkNodes = $$(".PagerPage");
for (var i=0;i<linkNodes.length; i++){
linkNodes]i[.setAttribute('class', 'PagerPage');// >:-( fix these square brackets!!
}
var linkId = "p_lt_ctl02_pageplaceholder_p_lt_ctl00_sliderHero_page_" + page;
var parentNode = $$("a#" + linkId)[0].parentNode;
parentNode.setAttribute('class', parentNode.getAttribute('class') ? parentNode.getAttribute('class') + ' active-slide' : 'active-slide';);
// custom code part2of2 - ends

if (isAuto)
etc...

Then in my home.css I style .active-slide:
.main .Slider {
position: relative;
}
.main .Slider .Pager{
position: absolute;
bottom: 0;
right: 0;
z-index: 20;
text-align: right;
padding-right: 6px;
opacity: .7;
filter: alpha(opacity=70);
}
.main .Slider .Pager .PagerPage{
display: inline;
border: 1px solid white;
background-color: white;
font-size: 0pt;
display: inline-block;
margin: 8px 2px;
padding: 0;
color: white;
height: 4px;
width: 4px !important;
}
.main .Slider .Pager .PagerPage a{
display: block;
}


.main .Slider .Pager .PagerPage.active-slide{
background-color: #888;
border: 1px solid #888;
-webkit-transition: background .1s;
-moz-transition: background .1s;
-o-transition: background .1s;
-transition: background .1s;
-webkit-transition: border .1s;
-moz-transition: border .1s;
-o-transition: border .1s;
-transition: border .1s;
}


.main .Slider .Pager .Control{
display: none !important;
}

(This block of CSS also incidentally contains my code for turning the pager results into navigation dots that float in the lower right corner of the slides. It also turns off the 'Start' control:

User image

User avatar
Member
Member
dcollins-marketwired - 2/7/2014 4:13:11 PM
   
RE:content slider paging : highlight this slide control
.... whiiiiiiiich is not going to work.

Because this:
p_lt_ctl02_pageplaceholder_p_lt_ctl00_sliderHero_page_0
changes every time it's run.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/7/2014 6:15:01 PM
   
RE:content slider paging : highlight this slide control
The standard is clone the webpart in the SIte Manager which will create a new set of files and then you can modify those files and not worry about breaking an upgrade.

As far as your ID, simply wrap a div around the pager items and assign a class to it, this way you can do something like .pager-slider .active-item { }

User avatar
Member
Member
dcollins-marketwired - 2/10/2014 8:30:05 AM
   
RE:content slider paging : highlight this slide control
Am trying cloning it. Went OK until I went to add the new webpart to a zone. Blam!
Server Error in '/' Application.
'<', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 6782.

I'll try ways around it.

User avatar
Member
Member
dcollins-marketwired - 2/10/2014 8:34:17 AM
   
RE:content slider paging : highlight this slide control
FroggEye wrote:
As far as your ID, simply wrap a div around the pager items and assign a class to it, this way you can do something like .pager-slider .active-item { }

But the pger items are not exposed anywhere I could wrap anything around them. (I'd need a place to wrap the individual pager controls - one for each slide, but that is entirely system-generated - no way to get at it.)

User avatar
Member
Member
dcollins-marketwired - 2/10/2014 10:56:12 AM
   
RE:content slider paging : highlight this slide control
OK, have not solved the cloned custom web part crashing problem, so I'm still editing the web part.

But I've found a way to target the pager controls by id. (To recap: the pager controls are dots, and should highlight according to which slide is showing)

My solution:

In this file:
\CMSWebParts\Viewers\Effects\ContentSlider_files\ContentSlider.js
append these lines:
    show:function(page){  
//...etc.
slidernodes[this.id][page].setStyle('z-index','10');
// custom slider pt.1 of 2 - DaveC 2014/02
// finds sliderHero and adds class .active-slide to it

// NOTE that there are two nodes of interest:
// <a> has the unique targetable id tied to param 'page'
// whereas its parent div.PagerPage is the one to which the style is applied
var aIdSnippet = sliderPagerPage + " a[id~='sliderHero_page_0";
$$(aIdSnippet)[0].parentNode.addClass('active-slide');

// custom slider pt.1 of 2 end

},


turnPage:function(page,isAuto){
if (isAuto)
{
//...etc.
oldslide[this.id] = curentslide[this.id];
curentslide[this.id] = page;

// custom slider pt.2 of 2 - DaveC 2014/02
// remove any previous '.active-slider'
// TODO: this is inefficient: loops through ALL slides to remove class, Would be better if it could somehow leverage 'oldslide'

var sliderPagerPage = "#hero-slider .PagerPage";
$$(sliderPagerPage).each(function(item, index){
item.removeClass('active-slide')'
});

// add class '.active-slide' to <a>'s parent container with an id matching this 'page'

var aIdSnippet = sliderPagerPage + " a[id~='sliderHero_page_" + page + "']";
$$(aIdSnippet)[0].parentNode.addClass('active-slide');

// custom slider pt.2 of 2 end

}



User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/11/2014 6:43:26 PM
   
RE:content slider paging : highlight this slide control
dcollins-marketwired wrote: But the pger items are not exposed anywhere I could wrap anything around them. (I'd need a place to wrap the individual pager controls - one for each slide, but that is entirely system-generated - no way to get at it.)
Just guessing you've probably spent a few days working on this. I'd spend the next hour toying around with the BX Slider. It won't involve you needing to write any custom webpart and you'd probably have it implemented in about 2-3 hours at max. If you'd like some help implementing it, please let me know and I'd be glad to help. Usually takes me about an hour to get it put in place, tested, and style applied.

bkehren at gmail dot com.

Brenden

User avatar
Member
Member
kentico_davidb2 - 2/7/2014 10:15:12 PM
   
RE:content slider paging : highlight this slide control
As mentioned by FroggEye, when modifying standard webparts, please follow the recommended steps as described at: http://devnet.kentico.com/docs/devguide/modifying_the_code_of_standard_web_parts.htm This way, everything will be preserved through future upgrades.

Regarding the bxSlider. This one is actually also used on http://www.kentico.com and it(s integration is very easy. Basically you link the javascript, generate the list by a repeater webpart and then run the bxSlider javascript initialization. Basically their example code will do.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/7/2014 6:16:39 PM
   
RE:content slider paging : highlight this slide control
The 3rd party slider is way more powerful than the built in slider and I'd recommend looking at that over the built in because it involves less overhead and is much easier to work with.

User avatar
Member
Member
dcollins-marketwired - 2/12/2014 8:54:51 AM
   
RE:content slider paging : highlight this slide control
Thanks. I'll take a look at BX slider.