MyBB Community Forums
Create Plugin Hook Point - 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: Create Plugin Hook Point (/thread-172373.html)



Create Plugin Hook Point - XerShade - 2015-06-25

Okay so I am trying to code a plugin that displays the most recent posters avatar on the forum index and have hit a snag, basically I am trying to do this in my code:

$lastpost = "<img src=\"$avatar_url\" />" . $lastpost;

But the snag is here on line 339 of inc/functions_forumlist.php

			// If this forum is a link or is password protected and the user isn't authenticated, set lastpost to "-"
			if($forum['linkto'] != '' || $hideinfo == true || $hidelastpostinfo == true)
			{
				eval("\$lastpost = \"".$templates->get("forumbit_depth2_forum_lastpost_hidden")."\";");
			}

Basically I need to hook in after this part of the code but no hook exists that I can find, is there a way to add in something like build_forumbits_forum_end to go with the build_forumbits_forum hook at the start so I can change the $lastpost variable before the template is built?


RE: Create Plugin Hook Point - Destroy666 - 2015-06-26

Why do you need to hook after that code? The way you're trying to do it is just not recommended. You should make use of find_replace_templatesets() and a new template for the avatar. http://docs.mybb.com/1.8/development/plugins/templates/


RE: Create Plugin Hook Point - XerShade - 2015-06-26

Because I am not trying to add a new variable in I am trying to modify one that already exists in the MyBB software. The issue is that the $lastpost variable in the forumbit generation is made AFTER the build_forumbits_forum hook so I can not append the change to it.


RE: Create Plugin Hook Point - Destroy666 - 2015-06-26

Well, feel free to create a hook the same way other hooks are added then ($plugins->run_hooks)... If you really want to do it the wrong way.


RE: Create Plugin Hook Point - XerShade - 2015-06-26

Okay the plugin now adds {$lpavatar} into the forum bit but the code my hook is on is not setting the {$lpvariable}, Here is the code.

function xsrpa_avatar_forumlist(&$forum)
{
	global $lpavatar;
	$lpavatar = "Override!";
}

Solved.