(use "if" "cookie value= something" rule here instead of MosCountModules)
<?php if(!$editmode and (mosCountModules('right') or ($sidenav and $menu_side == 'right'))) : ?>
<td class="right">
<?php if($sidenav and $menu_side == 'right') : ?>
<div id="vert-menu">
<?php echo $sidenav; ?>
</div>
<?php endif; ?>
<div id="toggle2" >
</div>
<div id="test2">
<?php mosLoadModules('right', -2); ?>
</div>
</td>
<?php endif; ?>
<script type="text/javascript">
window.addEvent('domready', function(){
//just an habit, not necessary but i make less mistakes this way than when using $ or $$ each time... always end forgetting a ' somewhere :)
var toggle2 = $('toggle2');
var mySlide2 = new Fx.Slide('test2', {
mode: 'horizontal', duration: 500, //transition: Fx.Transitions.Bounce.easeOut, //i let you add the other options, let's just concentrate on that cookie issue, don't need mode: vertical, it's the default mode
onComplete: function(){
if(this.wrapper.offsetWidth != 0) {
Cookie.set('toggleState', 'opened', {path: "/"});
}
else {
Cookie.set('toggleState', 'closed', {path: "/"});
}
}
})
//here you check existence and value of 'toggleState' in a cookie
if ( (Cookie.get('toggleState')) && (Cookie.get('toggleState') == 'opened') ) {
mySlide2.show();
}
else {
mySlide2.hide();
}
//here is you simple toggling link click event
toggle2.addEvent('click', function(e){
e = new Event(e).stop();
mySlide2.toggle();
});
});
</script>
Time to create page: 0.055 seconds