Display - Hook/filter

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
topdown
Registered User
Posts: 12
Joined: Sat Dec 01, 2007 5:04 am

Display - Hook/filter

Post by topdown »

I'm sure this is nothing new and is probably even in the plan already. These are just my thoughts.

I've been playing with something so I can demonstrate how I think the OOP phpBB as far as displaying and hooking into those displays.
By displaying I mean anything from posts, to profiles, to profile fields.

If everything is an (object) array coming from the database it will be a whole lot easier to handle.

So here we go, (This code is just a very quick example, I am by no means considering this completed or clean)
I didn't want to post the code as it is 100 lines so http://topdown.pastebin.com/XTCaLu4c

Keep in mind, that is just an example
Using this

Code: Select all

$test = new content_hook();

echo $test->filter(array('add' => 'Adding new content to the post.<br />'));
echo '<br />';
echo $test->filter(array('add' => 'Adding new content to the post.<br />'), 'post_title');
echo '<br />';
echo $test->filter(array('add' => 'Adding new content to the post.<br />'), 'content');
echo '<br />';
echo $test->filter(array('add' => 'Adding new content to the post.<br />'), 'post_footer'); 
Will output

Code: Select all

Adding new content to the post.
Post title
Some post content
Post signature

Post title
Adding new content to the post.
Some post content
Post signature

Post title
Some post content
Adding new content to the post.
Post signature

Post title
Some post content
Post signature
Adding new content to the post.
The point is that something like this allows easy hooking and adding whatever you want into specific areas without having to write 3 files of code to access that spot.
Something like this process should be used on anything that is displayed and with some geniuses behind the code such as the dev team :) and making something like this real, this could be key in the future of easily modding phpBB.

Just my thoughts.

aelitahopper
Registered User
Posts: 4
Joined: Fri Feb 18, 2011 12:17 am

Re: Display - Hook/filter

Post by aelitahopper »

being someone who develops code for drupal, i agree that a hooking system that allows modules without hacking core code is ideal, perhaps something similar to drupal's module system could be implimented
http://api.drupal.org/api/drupal/includ ... voke_all/5

just a suggestion

edt
---
in case you aren't programmers, with drupal, modules are stored in a 'modules' folder and themes in a 'themes' folder and remain dormant until 'activated' by an administrator via a control panel upon which a status of 1 is flagged in the database, once activated the core then is allowed to call upon the hook functions defined within the modules (eg hook_menu(), hook_block() etc.., most of these hooks are expected to return arrays which are then processed by the core to provide or modify the output)

a system like this would reduce the risk of one module from tripping over the other as the core code remains intact and hook functions in drupal are conveniently named module_name_hook()

note: with a system like this, everything is funnelled through index.php so instead of the path for the acp being
/forum/acp.php
it would be something like
/forum?page=acp

Post Reply