By jsabater on
Hello everyone!
I am developing a roster module for an online game. I have a roster page, and you click the name and you get to view the node information (the profile of the character). Now I'd like to display, at the bottom of that profile, a list of other characters from the same account. Therefore, I've written the following code in the hook_load, which works just fine.
/**
* Implementation of hook_load().
*/
function roster_load($node) {
$additions = db_fetch_object(db_query('SELECT * FROM {roster} WHERE vid = %d', $node->vid));
// Find other characters by this user
$stmt = "SELECT n.title, r.* FROM {node} n INNER JOIN {roster} r ON n.vid = r.vid WHERE n.uid = %d AND n.status = 1 AND n.nid <> %d ORDER BY r.first_name, r.last_name, r.nid";
$query = db_query($stmt, $node->uid, $node->nid);
$toons = array();
while ($row = db_fetch_object($query)) {
$toons[$row->nid] = $row->title;
}
$additions->other_chars = $toons;
return $additions;
}
What I'd like to know is whether this is the right place to do this sort of things or whether there is a better place for it.
Thanks in advance.