![]() |
Hook build_forumbits_forum and Templates - Printable Version +- MyBB Community Forums (https://community.mybb.com) +-- Forum: Extensions (https://community.mybb.com/forum-201.html) +--- Forum: Plugins (https://community.mybb.com/forum-73.html) +---- Forum: Plugin Development (https://community.mybb.com/forum-68.html) +---- Thread: Hook build_forumbits_forum and Templates (/thread-233359.html) |
Hook build_forumbits_forum and Templates - windkind - 2021-08-22 Hi! 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:
As soon as I try calling a template with it shows Error 500.With 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! ![]() Please ask if you don't understand everything. English isn't my native language so mistakes and misunderstandings happen! RE: Hook build_forumbits_forum and Templates - Matt - 2021-08-22 You'll need to globalise $wanted_index, and I think escape some characters in the eval itself:
See if that works. The reason this breaks and causes a 500:
is because you're using single quotes in the eval, and in the array key, so it closes the quotes and would result in a parse error. If you do it that way, you need to escape them, or use double quotes:
or:
RE: Hook build_forumbits_forum and Templates - windkind - 2021-08-22 Hi Matt! Thank you very very much. ![]() With the $wanted_index in global it still showed nothing. But with the corrected eval it works fine! ![]() Thank you! ![]() RE: Hook build_forumbits_forum and Templates - Matt - 2021-08-22 You're welcome ![]() RE: Hook build_forumbits_forum and Templates - Omar G. - 2021-08-22
RE: Hook build_forumbits_forum and Templates - Matt - 2021-08-22 (2021-08-22, 10:50 PM)Omar G. Wrote: :o Since when?! RE: Hook build_forumbits_forum and Templates - Omar G. - 2021-08-23 (2021-08-22, 11:48 PM)Matt Wrote:(2021-08-22, 10:50 PM)Omar G. Wrote: Since 1.8.0 😅 The core just wasn't updated to make use of it so it isn't as used as it should be by now. RE: Hook build_forumbits_forum and Templates - windkind - 2021-08-23 (2021-08-22, 10:50 PM)Omar G. Wrote: I tried it (and of course make $wanted_index global again) - but nothing. I think it is because of that special hook that I need to work with the array $forum ![]() RE: Hook build_forumbits_forum and Templates - Omar G. - 2021-08-23
Is just a replacement of :
It should simply work. |