I am working on Urban Life template of joomla XTC framework. Its header can be made sticky from back-end (I made it non-sticky from back-end). I am adding a div which contains a banner above the existing header of template and it should be non sticky. while the header containing menu should stick after scroll. I added the following code
$(function(){
var stickyHeaderTop = $('#header').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('#header').css({position: 'fixed', top: '0px'});
} else {
$('#header').css({position: 'static', top: '0px'});
}
});
});
The existing code of template is as follows
<?php if ($stickyClass == 'sticky' && !$xtc->agent->isMobile) { ?>
<script>
jQuery(window).scroll(function () {
if (jQuery("#headerwrap").offset().top > 1) {
jQuery("#headerwrap").addClass("stickyscroll")
} else {
jQuery("#headerwrap").removeClass("stickyscroll")
}
});
</script>
<?php } ?>
Now to display we have the following code in the body. Note the div top is added by me.
<body class="<?php echo $pageview;?> <?php echo $stickyClass;?> <?php echo $pageclass; ?> <?php echo $extension; ?>">
<div id="headerwrap" class="<?php echo $stickyClass;?> xtc-bodygutter">
<div id="top">
<p style=""><img style="display: block; margin-left: auto; margin-right: auto; border: 1px solid #ffffff; width: 725px;" src="images/banners/jeeptop.gif" alt="" /></p>
</div>
<div id="header" class="<?php echo $hdclass; ?> clearfix">
<div id="logo" class="hd2">
<a class="hideTxt" href="index.php">
<?php echo $app->getCfg('sitename');?>
</a>
</div>
It didn't work. Please suggest any solution.