1
DonXoop
Show/Hide left blocks revisisted

I'm trying to find a way to hide and show a left column (mainly for the forums). There is some javascript for this but it only lasts for the current screen.

I'd like to make that a toggle that lasts between screens. Ideally it would only last while in the current module and then toggle.

If I manually set xoops_lblocks I can hide and show:
$this->assign("xoops_lblocks", FALSE) ;

Perhaps there is a simple way to do this?
FYI, I am using a very simple language module that toggles xoops_langcode, perhaps I can add something in there?

Here is the code I've pulled from a theme with block hiding.
Javascript in theme.html:
<script type="text/javascript">

script>


HTML code in theme.html to toggle show/hide:
<span style="float: left; width: 23px;"><img name="toggle" src="<{$xoops_imageurl}>images/toggle1.gif" width="23" height="23" border="0" alt="Hide/show left column" class="pointer" onclick="toggleDisplay('leftcolumn','block','none')">span>

2
Mithrandir
Re: Show/Hide left blocks revisisted

Set a cookie through JavaScript to specify whether the blocks are on or off?

3
DonXoop
Re: Show/Hide left blocks revisisted

Thanks for the reply. I'm no javascript coder so would be starting from zero on that one. I know others have tried this but haven't posted any success stories.

Main use is to turn off the left columns in forums if the user desires. The other users prefer to keep the useful blocks I have in the column.

Since I have the language module (simple alternative to the ML hack) I was thinking of using that. I added a cookie code for the language flip but lack the actual method to set and keep xoops_lblock empty until flipped again. The functions.php file from that module looks like this:
        if ($HTTP_GET_VARS['sel_lang']>'') {
                
//sets a cookie for a month with the language that the user selected
                
setcookie('selected_language'$HTTP_GET_VARS['sel_lang'], time()+3600*24*30'/');
        
$xoopsConfig['language'] = $HTTP_GET_VARS['sel_lang'];
    } elseif (
$HTTP_COOKIE_VARS['selected_language'] > '') {
        
$xoopsConfig['language'] = $HTTP_COOKIE_VARS['selected_language'];
    }

// ##### Added code to set cookie for column switching //
        
if ($HTTP_GET_VARS['sel_col']>'') {
                
//sets a cookie for one hour with the column toggle
                
setcookie('selected_column'$HTTP_GET_VARS['sel_col'], time()+3600'/');
    } elseif (
$HTTP_COOKIE_VARS['selected_column'] > '') {
        
$xoopsConfig['language'] = $HTTP_COOKIE_VARS['selected_column'];
    }
?>

4
Dave_L
Re: Show/Hide left blocks revisisted
  • 2005/2/16 21:36

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


If it helps, here are Javascript cookie functions:

function set_cookie(namevalueexpires)
{
   
document.cookie name '=' escape(value) + '; expires=' expires.toGMTString();
}

function 
get_cookie(name)
{
   var 
cookie document.cookie;
   var 
start cookie.indexOf(name '=');
   var 
len start name.length 1;
   if (!
start && name != cookie.substring(0name.length)) return null;
   if (
start == -1) return null;
   var 
end cookie.indexOf(';'len);
   if (
end == -1end cookie.length;
   return 
unescape(cookie.substring(lenend));
}

5
DonXoop
Re: Show/Hide left blocks revisisted

Thank you for the code snips. I'll have a look at it and see if I can make it work in my theme.

I'm surprised that nobody has worked on a hide/show column code that sticks across a screen refresh. I'm not sure if javascript is the most desirable method but I'm going to try a few things.

6
LazyBadger
Re: Show/Hide left blocks revisisted

Quote:

I'm surprised that nobody has worked on a hide/show column code that sticks across a screen refresh.

Why "nobody"? I know at least one theme (is_urbanize from chatnoir), where block's statuses are persistent not only between refreshes, but even - between different pages jumps

7
DonXoop
Re: Show/Hide left blocks revisisted

Well "nobody" has made it obvious that this was done. Until now.

I'll now search for the named theme.
thanks.

8
larrymac
Re: Show/Hide left blocks revisisted
  • 2005/2/23 6:52

  • larrymac

  • Just popping in

  • Posts: 40

  • Since: 2005/2/6 1


I've switched mywebsite to the IS_Urbanize theme, actually - really cool. The only problem (and I'm guessing it might be related to this thread) is that if I edit style.css to adjust the width of the left and right columns, nothing happens.

Any thoughts on what I might be missing? I've done it with other themes (although I can't swear that I've done so since upgrading Xoops).

Login

Who's Online

414 user(s) are online (299 user(s) are browsing Support Forums)


Members: 0


Guests: 414


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits