How to add a new panel to post editor

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
alf007
Registered User
Posts: 36
Joined: Sun Mar 13, 2005 5:46 pm
Location: France (78)

How to add a new panel to post editor

Post by alf007 » Mon Nov 10, 2014 12:36 am

In 3.0 mod time you could look for
styles/<prosilver or other>/template/posting_buttons.html
then search for

Code: Select all

var panels = new Array('options-panel', 'attach-panel', 'poll-panel');
and insert you ownpanel name
then in
styles/prosilver/template/posting_editor.html
looking for an existing tab

Code: Select all

<!-- IF S_SHOW_POLL_BOX || S_POLL_DELETE --><li id="poll-panel-tab"><a href="#tabs" onclick="subPanels('poll-panel'); return false;"><span>{L_ADD_POLL}</span></a></li><!-- ENDIF -->
to insert your own
and finally adding to
styles/prosilver/template/posting_layout.html
an inclusion of the new panel html page

So now, looks like it's missing some events to add all those things in 3.1

alf007
Registered User
Posts: 36
Joined: Sun Mar 13, 2005 5:46 pm
Location: France (78)

Re: How to add a new panel to post editor

Post by alf007 » Sat May 16, 2015 3:40 pm

Created ticket: https://tracker.phpbb.com/browse/PHPBB3-13843
Added PR: https://github.com/phpbb/phpbb/pull/3612

Usage would be by creating files:
STYLE/template/event/posting_editor_add_panel_tab.html

Code: Select all

				<!-- IF S_SHOW_CUSTOM_PANEL_BOX -->
					<li id="custom_panel-panel-tab" class="tab">
						<a href="#tabs" data-subpanel="custom_panel-panel" role="tab" aria-controls="custom_panel-panel">{L_CUSTOM_PANEL_TITLE}</a>
					</li>
				<!-- ENDIF -->
STYLE/template/event/posting_layout_include_panel_body.html

Code: Select all

<!-- IF S_SHOW_CUSTOM_PANEL_BOX --><!-- INCLUDE posting_topic_custom_panel.html --><!-- ENDIF -->
STYLE/template/posting_topic_custom_panel.html

Code: Select all

<div class="panel bg3" id="custom_panel-panel">
	<div class="inner">
	<fieldset class="fields2">
		<dl>
			<dt><label>{L_CUSTOM_PANEL_OPTION}:</label></dt>
			<dd><input ... /></dd>
		</dl>
		... whatever options fields ...
	</fieldset>
	...
	</div>
</div>
and in the Extension listener subscribe to core event core.posting_modify_template_vars

Code: Select all

	static public function getSubscribedEvents()
	{
		return array(
			...
			'core.posting_modify_template_vars'			=> 'posting_modify_template',
			...
		);
	}
...
	public function posting_modify_template($event)
	{	// Activate our editor custom panel
		$template_data = $event['page_data'];
		$template_data['S_SHOW_CUSTOM_PANEL_BOX'] = true;
		$event['page_data'] = $template_data;
		...
	}

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: How to add a new panel to post editor

Post by javiexin » Sun May 17, 2015 10:13 am

I like this, and I support this change. I see an alternative use case, for example, in replacing existing tabs when the functionality provided by an extension is different that the basic one. I would probably use it for the Advanced Polls extension we are working on...

BUT, you should figure out a way to make an equivalent change in subsilver2.

Yes, not mainstream any longer, but no extension should break it either...

-javiexin

User avatar
david63
Registered User
Posts: 16827
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: How to add a new panel to post editor

Post by david63 » Sun May 17, 2015 10:21 am

javiexin wrote:you should figure out a way to make an equivalent change in subsilver2
Not sure that is really necessary for two reasons:

1. Extensions are only required to work with prosilver
2. My understanding is that subsilver2 will be being dropped in the no too distant future
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: How to add a new panel to post editor

Post by javiexin » Sun May 17, 2015 1:50 pm

If it were an extension in itself, I agree with you david63.

But the proposed change is a change to the core of phpbb, not an extension, so it should at least not break subsilver2, and allow for extension developers to have the choice to do something similar in both cases...

My proposal would be something like adding an event in subsilver2, posting_body.html around line 375, that would be equivalent to the proposed <!-- EVENT posting_layout_include_panel_body -->.
I would probably call them both posting_include_panel_body to make it consistent.

And as I said, I think this is a good change, and I would personally use it...
-javiexin

alf007
Registered User
Posts: 36
Joined: Sun Mar 13, 2005 5:46 pm
Location: France (78)

Re: How to add a new panel to post editor

Post by alf007 » Sun May 17, 2015 2:26 pm

Well, i didn't proposed the equivalent change to subsilver2 style, as it's not included in default 3.1.x package installation, though it's still present in the development branch repository, effectively ^^
Anyway, as you proposed, the changes are quite simple in the core for this case.

Post Reply

Return to “Extension Writers Discussion”