Page 1 of 1

Collapsible options when posting

Posted: Tue May 06, 2008 1:03 pm
by HaArD
I am trying to modify our forum so that two options (polls and attachements) on the posting page are collapsed by default and can be expanded by checking a checkbox.

I've added a javascript function to an existing script file used by the template and specified within overall_header.tpl.

I've modified add_attachment_body.tpl and posting_poll_body.tpl to have a checkbox with an onclick action that call the javascript function and a div which is not displayed initially.

The problem I'm having is that while these changes to the template file work perfectly when it's saved as HTML locally, but they do not work at all when phpBB creates the page. The section is always displayed and the checkbox seems to have no effect whatsoever.

I've looked at several "collapsible" mods (Faq, Rules, Categories) and they all seem far more complex so I haven't been able to learn anything from them except that they seem to take a totally different (not javascript) approach. My forum is for a small community, everyone uses windows and has either IE6 or 7 or Firefox 2, I have no need for any further level of compatibility.

overall_header.tpl contains:

Code: Select all

<script language="javascript" type="text/javascript" src="templates/cs/scripts.js"></script>
scripts.js contains:

Code: Select all

function toggle(id)
{
	el = document.getElementById(id);
	var display = el.style.display ? '' : 'none';
	el.style.display = display;
}
posting_poll_body.tpl contains:

Code: Select all

			<tr>
				<th class="thHead" colspan="2"><input type=checkbox onclick="toggle('ShowPollYN')">{L_ADD_A_POLL}</th>
	        </tr>
<div id="ShowPollYN" style="display:none">
.
.
.
</div>
add_attachment_body.tpl contains:

Code: Select all

	<tr>
		<th class="thHead" colspan="2"><input type=checkbox onclick="toggle('ShowAttachYN')">{L_ADD_ATTACH_TITLE}</th>
	</tr>
<div id="ShowAttachYN" style="display:none">
.
.
.
</div>
Attachment Mod is
* @package attachment_mod
* @version $Id: attachment_mod.php,v 1.6 2005/11/06 18:35:43 acydburn Exp $
* @copyright (c) 2002 Meik Sievertsen
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
phpBB version 2.0.22....

Re: Collapsible options when posting

Posted: Wed May 07, 2008 6:02 am
by HaArD
OK I've figured out part of my problem....

You cannot have a <DIV> between <TR> in a <TABLE>

So my approach of defining a subset of the rows within a <DIV> and then changing the visibility of that <DIV> will not work....

*EDIT*

Sometimes the answer is quite simple.... I changed my <DIV>'s to <TABLE>'s and it's all working now.

Re: Collapsible options when posting

Posted: Wed May 07, 2008 3:11 pm
by Brf
You can use <TBODY> to group table rows.

Re: Collapsible options when posting

Posted: Sun Jun 29, 2008 3:23 pm
by HaArD
Thanks! <tbody> works much better.

<table> was working on the initial post but if you previewed or edited the post is screwed up the whole page structure.

<tbody> looks perfect in all modes.