1
m0nty
Blocks Question??
  • 2004/2/4 22:03

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


On Koudanshi's sitehttp://www.bbpixel.com

there are 2 buttons at the top, which turn each block on/off when u click them!!

is this a hack that's generally available as I think it's pretty damn nifty, and oughta be implemented into the core..

2
Mithrandir
Re: Blocks Question??

Yeah, pretty nifty.

If you could figure out, how it is done, I'm sure it will be welcomed by everyone

3
SevenD
Re: Blocks Question??
  • 2004/2/5 1:19

  • SevenD

  • Not too shy to talk

  • Posts: 143

  • Since: 2003/7/23



Save this code like html file and give a look, this is simple demo of javascript controled column.

Quote:

<html>
<head>
<script type="text/javascript">
<!--
var getById = (typeof document.getElementById != "undefined");
function toggleDisplay(obj,display1,display2){
if(!getById) return;
obj = getRef(obj);
if(obj.style.display == display2)
obj.style.display = display1;
else
obj.style.display = display2;
repaintFix();
}
function getRef(obj){
if(getById)
return(typeof obj == "string") ? document.getElementById(obj) : obj;
}
function repaintFix(obj){
if("undefined" == typeof document.body
|| "undefined" == typeof document.body.style) return;
if(obj == null)
obj == document.body;
else obj = getRef(obj);
document.body.style.visibility = "hidden";
document.body.style.visibility = "visible";
}
//-->
</script>
</head>
<body>

<table width="500" border="2" align="center" cellpadding="0" cellspacing="0"><tr>
<td width="150" bgcolor="#990000"><img src="http://www.7dana.com/img/pic22.gif" alt="Block controler" width="22" height="22" align="left" onclick="toggleDisplay('leftcolumn','block','none')" /></td>
<td width="200">&nbsp;</td>
<td width="150" bgcolor="#339966"><img src="http://www.7dana.com/img/pic22.gif" alt="Block controler" width="22" height="22" align="right" onclick="toggleDisplay('rightcolumn','block','none')" /></td>
</tr>
</table>
<table width="500" border="2" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="leftcolumn" width="150" height="228" bgcolor="#990000">&nbsp;</td>
<td width="200">&nbsp;</td>
<td id="rightcolumn" width="150" bgcolor="#339966">&nbsp;</td>
</tr>
</table>

</body>
</html>



4
hsalazar
Re: Blocks Question??
  • 2004/2/5 1:46

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Another possible path: download theme MP00 and see how it's done.

https://xoops.org/modules/news/article.php?storyid=1098

Cheers.

5
m0nty
Re: Blocks Question??
  • 2004/2/5 2:41

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


yeah thanks guys.. i figured it out by viewin his source on his page.. been tryin to implement into my own theme.. and i've just about done it..

so if anyone else wants to implement into their existing theme then >

enter this into the head section of theme.html

<script type="text/javascript">
<!--
var getById = (typeof document.getElementById != "undefined");

function toggleDisplay(objname, display1, display2) {
if (!getById) {
return;
}
obj = getRef(objname);
if (obj.style.display == display2) {
obj.style.display = display1;
}
else
{
obj.style.display = display2;
}

// Set cookie
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
ckstr = escape(obj.style.display);
SetCookie("disp_" + objname, ckstr, expdate, "/");
}

function getRef(obj) {
if (getById) {
return(typeof obj == "string") ? document.getElementById(obj) : obj;
}
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";", offset);
if (endstr == -1) {
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
return getCookieVal (j);
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) {
break;
}
}
return null;
}

function SetCookie(name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
//-->
</script>

then where u want the switch buttons in the main body use something similar to this >

<td id="headerbar" width=5%><img src="<{$xoops_imageurl}>images/swich.gif" width="23" height="24" alt="Left Block Control" style="cursor: pointer" onclick="toggleDisplay('leftcolumn', 'block', 'none')" /></td>

<td id="headerbar" width=5%><img src="<{$xoops_imageurl}>images/swich.gif" width="23" height="24" alt="Right Block Control" style="cursor: pointer" onclick="toggleDisplay('rightcolumn', 'block', 'none')" /></td>

& finally the columns section (will vary depending on your theme tho) >

<{if $xoops_lblocks}>
<td id="leftcolumn" width=150 height=100%>
<script type="text/javascript">
<!--
if (GetCookie("disp_leftcolumn")) {
obj = getRef("leftcolumn");
obj.style.display = GetCookie("disp_leftcolumn");
}
// -->
</script>
<!-- Start left blocks loop -->
<{foreach item=block from=$xoops_lblocks}>
<{include file="<theme name>/theme_blockleft.html"}>
<{/foreach}>
<{/if}>
<!-- End left blocks loop -->

</td>

<td id="centercolumn">
<div id="content">
<{$xoops_contents}>
</div>

<!-- Display center blocks if any -->
<{if $xoops_showcblock == 1}>

<table cellspacing="0">
<tr>
<td id="centerCcolumn" colspan="2">

<!-- Start center-center blocks loop -->
<{foreach item=block from=$xoops_ccblocks}>
<{include file="<theme name>/theme_blockcenter_c.html"}>
<{/foreach}>
<!-- End center-center blocks loop -->

</td>
</tr>
<tr>
<td id="centerLcolumn">

<!-- Start center-left blocks loop -->
<{foreach item=block from=$xoops_clblocks}>
<{include file="<theme name>/theme_blockcenter_l.html"}>
<{/foreach}>
<!-- End center-left blocks loop -->

</td><td id="centerRcolumn">

<!-- Start center-right blocks loop -->
<{foreach item=block from=$xoops_crblocks}>
<{include file="<theme name>/theme_blockcenter_r.html"}>
<{/foreach}>
<!-- End center-right blocks loop -->

</td>
</tr>
</table>

<{/if}>
<!-- End display center blocks -->

<br />

</td>

<{if $xoops_showrblock == 1}>

<td id="rightcolumn" width=180 height=100%>
<script type="text/javascript">
<!--
if (GetCookie("disp_rightcolumn")) {
obj = getRef("rightcolumn");
obj.style.display = GetCookie("disp_rightcolumn");
}
// -->
</script>
<!-- Start right blocks loop -->
<{foreach item=block from=$xoops_rblocks}>
<{include file="<theme name>/theme_blockright.html"}>
<{/foreach}>
<!-- End right blocks loop -->
</td>

<{/if}>

</tr>
</table>

again thanks, and thanks to koudanshi for the source code ;)

6
script_fu
Re: Blocks Question??

Very cool... Most of the e-xoops themes have this toggle blocks fuction also. Nice work on the port guys...

Login

Who's Online

271 user(s) are online (173 user(s) are browsing Support Forums)


Members: 0


Guests: 271


more...

Donat-O-Meter

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

Latest GitHub Commits