Re: Code for hiding block titles
Posted by dconn6 on 1210187850
thanks to both of you for your help. It was easy to find a show_hide javascript and the foreach xoops-block code was easily modified. I can now click my top buttons and bring up the appropriate multiMenu block on the left. The only small problem I had was persistence. For example when I press my top Elementary button the multimenu block containing the Elementary submenus appears but when I select a submenu from this block the page refreshes and the Elementary block disappears(reverts back to the default which is to show the home button block). We have overcome this by putting an init() function in the start.js script in multiMenu/scripts
function addToStart(fnc){
if(!window.listStart) window.listStart = new Array();
window.listStart.push(fnc)
}
function start(){
var ls = window.listStart;
if(ls){
for(i=0; i<ls.length; i++){
ls[i]();
}
}
init(); <------this has been added.
}
window.onload = start;
This init() function will be in the scripts section of the theme.html and will keep the relevant menu in place when the page is refreshed.
Actually if you have any thoughts on other ways for establishing persistence I would be interested. For example this is my left block loop
<{foreach item=block from=$xoops_lblocks}>
<{if ($block.title == 'Elementary' || $block.title == 'Home')}>
<div id="_<{$block.title}>" style="display: none; visibility: hidden;"><{$block.content}></div>
<{/if}>
<{if ($block.title !== 'Elementary' && $block.title !== 'Home')}>
<{include file="$xoops_theme/blocks/theme_blockleft.html"}>
<{/if}> <{/foreach}>
This is working okay, but could I link a smarty variable to help the page remember which block is current. The only way I have been able to link the smarty with the javascript is via the id set in the smarty code above. The page is operating under two masters, smarty and javascript and I wonder are there other ways where they can connect.
This Post was from: https://www.impresscms.org/iforum/viewtopic.php?topic_id=1079&post_id=16186