Hook build_forumbits_forum and Templates

I'm writing a little plugin for my forum, to show a random thread between two categories. In the attachement it's the part "Eigener Inhalt" (Translation: Kategorie = Category, Eigener Inhalt = own content (like a random thread)).

Now I began writing my plugin, install/deinstall/activate/deactivate works great - but the main function creats an Error 500 as soon as I try to include a new template that I created during installation of the plugin.

The working format by now is:

$plugins->add_hook('build_forumbits_forum', 'wanted_index');

function wanted_index(&$forum)
  global $mybb, $db, $templates;

// Reading the settings - at which category should it be shown?
// In the settings this is a selectforumsingle
  $wanted_show = $mybb->settings['wanted_show'];

// If the ForumID isn't the selected forum, then ..
  if ($forum['fid'] != $wanted_show) return;

// In other cases
  $forum['wanted_index'] = "Test text";

As soon as I try calling a template with
eval('$forum['wanted_index'] = "'.$templates->get('wanted_index').'";');
it shows Error 500.

eval('$wanted_index = "'.$templates->get('wanted_index').'";'); 
and including {$wanted_index} in forumbit_depth1_cat (instead of {$forum['wanted_index']}), it shows nothing.

Yes, there is missing a lot of stuff, but before I write this, my question is: Is there any possibility to include a template at any way using that hook?
I'm working with MyBB 1.8.27

Thank you! Smile
Please ask if you don't understand everything. English isn't my native language so mistakes and misunderstandings happen!

Attached Files Thumbnail(s)

Messages In This Thread
Hook build_forumbits_forum and Templates - by windkind - 2021-08-22, 07:02 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)