Re: Code for hiding block titles |
by dconn6 on 2008/5/7 12:17:30 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. |
Re: Code for hiding block titles |
by Will on 2008/5/6 4:38:02 My apologies, Nachenko is always having to correct me on whether its ajax or js, or whatever. ![]() anywho... http://www.webmasterworld.com/forum91/441.htm There are tons of scripts already fabbed up out there. Generally you can just google "Javascript show/hide" and get 1000's of results. BOL |
Re: Code for hiding block titles |
by TheRplima on 2008/5/5 13:37:27 You can add an id to the the div and get it with javascript. Something like this: Quote:
|
Re: Code for hiding block titles |
by dconn6 on 2008/5/5 13:32:00 thanks for the tip. I started another topic and nanchenko suggests exactly why you have said. I was going down the wrong track trying to use smarty functions for something that really is dynamic and needing javascript and css. For example the html for the left blocks contains this line <td width="98%" style="background-image: url(<{$xoops_imageurl}>images/lb_tc.gif);"><div class="blockTitle"><{$block.title}></div></td> If javascript can recognise smarty variables like {$block.title} then it will be relatively easy to write a script that either hides or shows a block depending on this smarty variable. This is what you were suggesting right? |
Re: Code for hiding block titles |
by nachenko on 2008/5/5 9:04:42 This is not really AJAX, just javascript. Pity my company's site is not finished yet, as I'm considering to do something like this using jQuery. You could copy the code. |