Firefox PHP

new list hook

Posted by Zdravko Balorda 
new list hook
November 04, 2010 06:16AM
Hi,
I am writing a module for subject classification into categories. I found list hook to be called too late for my problem.
The idea is for list.php to support threads list from other sources, too, not just what phorum_db_get_thread_list() returns based on $page only.

I wonder if you have already gave some thoughts into extending list.php behavour?

Regards, Zdravko
Re: new list hook
November 04, 2010 10:06AM
Where do you think you need the hook to be?

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: new list hook
November 04, 2010 10:20AM
And what would you feed to that hook? What is the exact problem that you'd be tackling?

You are asking about "extending" the list.php behavior, but from the few pointers that you gave on what you are doing, it sounds more like you want to "modify" the behavior.

What would "other sources" be for you? Are those simply Phorum threads that would normally not be shown?


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: new list hook
November 04, 2010 10:52AM
Probably I didn't write enough details. I would say extend behavior so that list.php can show arbitrary list of threads, while
handling paging and caching.

A hook would return this list according to some extra url arguments.

Hmm, it seems also that I need an approach to handling extra arguments, too. As it is I can add url parameter "category=16" without messing up phorum, but paging should also produce links with such
a parameter added to url.


Well, with a solution to these two issues I could complete forum categorization.
Re: new list hook
November 04, 2010 11:05AM
I'm afraid that what you want takes a lot more than only a simple hook. What you describe, fundamentally clashes with what the list page is about. Modifying the paging links would not really be too difficult (one can always hook into the Phorum output hooks to do some just-in-time updates to the template data), but the core process of retrieving messages to list is a totally different story.

What you would need is a customized version of the db list function, that handles your queries for retrieving the correct messages to show. If you do not implement something like this at the database level, then paging will become very difficult, if not impossible.

Therefore, if I would have to implement this, then I'd override the full list page (e.g. using the page_list hook) and implement my own code fully, so I could also provide custom db queries for handling the list page message retrieval.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: new list hook
November 05, 2010 02:29AM
Well, yes, there are no db hooks, or module db extensions/replacements. There is a module functions db_thread_list similar
to phorum_db_get_thread_list, but I would like to avoid scanning db twice. Once by list.php and one more time by module function. Other than that I'm fine with phorum hooks. Even paging links could be tweaked from list hook. I'm not sure though if caching can be handled properly and without overhead.

Regards, Zdravko
Re: new list hook
November 05, 2010 07:43AM
Paging links can be handled from a hook, it's the actual paging that I'd be more worried about. Unless of course your module would only mix extra threads into the first page of the list, but I think that is not the case. When paging, how would you handle determining what messages to show on the second (or 100th) page? Or would you always simply combine the paging output from both db calls, not regarding the configured list page length?

Anyway, if you think that you can handle all that you need by implementing an extra hook in the list.php script, then we're happy to add it. Please try implementing the hook yourself in a spot where you think it is appropriate and check if you can indeed use it to implement your code. If all works out well, then tell us what your hook looks like in the list.php code and we will add it to the list.php in the distribution.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login