MyBB Community Forums

Full Version: Problem with my plugin and templates.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

I seem to be having a problem outputting content from my plugin into where it's supposed to go. I have the following code;

// PROFILE
$plugins->add_hook('member_profile_start', 'game_library_index');

function game_library_index() {
    global $mybb, $db, $templates;
    
    /* Get the current user id on the profile. */
    $uid = $mybb->input['uid'];
    
    /* Get games from the library for the specific user. */
    $user_games_query = $db->query("
        SELECT * FROM ".TABLE_PREFIX."games_library
        WHERE uid = '$uid'
    ");
    
    /* Loop through our query to get all the games. */
    while($game = $db->fetch_array($user_games_query)) {
        $gid = $game['gid'];
        
        /* Get information regarding the specific game. */
        $game_information_query = $db->query("
            SELECT * FROM ".TABLE_PREFIX."games
            WHERE ID = '$gid'
        ");
        
        $game_information = $db->fetch_array($game_information_query);
        
        $GameTitle = $game_information['GameTitle'];
        
        eval("\$games_profile_item .= \"".$templates->get("games_profile_item")."\";");
    }

    eval("\$games_output = \"".$templates->get("games_profile_index")."\";");
}

Then to output the content I have the following on member_profile template;

{$games_output}

This should work I think, but it doesn't. However in the first code if I echo $games_output it displays it at the top of the member profile.

Can someone help me on this?
Have you added $games_output in member_profile template ? Also add $games_output as global object, like this;
global $mybb, $db, $templates, $games_output;
Thanks Yaldaram.