MyBB Community Forums

Full Version: Hook request in forumdisplay
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can i suggest to add an hook point at line 1070 of forumdisplay.php, to allow plugins to change/overwrite some of the $thread['x'] values?

$plugins->run_hooks("forumdisplay_thread_end", $thread);

mavericck
Couldn't you modify the template instead to use your custom variables?
I need to change the behavior of threads icons and subjects in some specified forums only. If i remove the original $thread['subject'] and $icon from the template, replacing them with custom variables, i'll need to copy all of the code that generates the "standard" icons and subjects into my plugin (double sizing it) to reproduce the "normal" behavior of icons and subjects of forums where the plugin doesn't have to change anything.

A similar hook is already placed at line 553 of search.php (search_results_thread), so i don't think it would be harmful to add a line like that in forumdisplay too, imho.

mavericck
search_results_thread exists so that we can highlight search terms. Can you argue that your proposed hook is as useful?
(2008-10-13, 02:52 PM)mavericck Wrote: [ -> ]I need to change the behavior of threads icons and subjects in some specified forums only. If i remove the original $thread['subject'] and $icon from the template, replacing them with custom variables, i'll need to copy all of the code that generates the "standard" icons and subjects into my plugin (double sizing it) to reproduce the "normal" behavior of icons and subjects of forums where the plugin doesn't have to change anything.
You can dynamically change the template then, ie:
function thehook() {
 global $fid, $templates;
 if($fid != 2) return;
 if(!$templates->cache['thetemplate']) $templates->cache('thetemplate');
 $templates->cache['thetemplate'] = str_replace('a', 'b', $templates->cache['thetemplate']);
}

Hope that helps.
(2008-10-13, 10:36 PM)laie_techie Wrote: [ -> ]search_results_thread exists so that we can highlight search terms. Can you argue that your proposed hook is as useful?

The only "highlight" code in this block of search.php, adds the searched word to the querystring. The highlighting of thread's words is done after, by showthread.php and not search.php. I can't find an "useful" reason to change the hl value passed to showthread.php, so i don't think that the 'search_results_thread' hook exists for that.

(2008-10-14, 02:31 AM)ZiNgA BuRgA Wrote: [ -> ]
(2008-10-13, 02:52 PM)mavericck Wrote: [ -> ]I need to change the behavior of threads icons and subjects in some specified forums only. If i remove the original $thread['subject'] and $icon from the template, replacing them with custom variables, i'll need to copy all of the code that generates the "standard" icons and subjects into my plugin (double sizing it) to reproduce the "normal" behavior of icons and subjects of forums where the plugin doesn't have to change anything.
You can dynamically change the template then, ie:
function thehook() {
 global $fid, $templates;
 if($fid != 2) return;
 if(!$templates->cache['thetemplate']) $templates->cache('thetemplate');
 $templates->cache['thetemplate'] = str_replace('a', 'b', $templates->cache['thetemplate']);
}

Hope that helps.
I've manually added the custom hook point, but this solution is good too. Thanks Wink

mavericck