Collapsible options when posting

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
HaArD
Registered User
Posts: 11
Joined: Fri Sep 23, 2005 10:11 am

Collapsible options when posting

Post by HaArD » Tue May 06, 2008 1:03 pm

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....

HaArD
Registered User
Posts: 11
Joined: Fri Sep 23, 2005 10:11 am

Re: Collapsible options when posting

Post by HaArD » Wed May 07, 2008 6:02 am

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.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50702
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Collapsible options when posting

Post by Brf » Wed May 07, 2008 3:11 pm

You can use <TBODY> to group table rows.

HaArD
Registered User
Posts: 11
Joined: Fri Sep 23, 2005 10:11 am

Re: Collapsible options when posting

Post by HaArD » Sun Jun 29, 2008 3:23 pm

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.

Post Reply

Return to “[2.0.x] MOD Writers Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests

cron