Create Plugin Hook Point
#1
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?
[Image: TheShadeGamer.jpg]
[Image: logo.png]
Reply
#2
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/
Reply
#3
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.
[Image: TheShadeGamer.jpg]
[Image: logo.png]
Reply
#4
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.
Reply
#5
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.
[Image: TheShadeGamer.jpg]
[Image: logo.png]
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)