Les archives de FluxBB.fr
Vous n'êtes pas identifié(e).
Bonjour à tous,
j'aimerai afficher sur l'accueil du forum (index.php), l'avatar des derniers membres ayant posté dans chaque forum d'une catégorie.
J'ai besoin pour cela de récupérer l'id de $cur_forum['last_poster']
Problème : il n'existe pas de $cur_forum['last_poster_id']
et $cur_forum['last_poster'] m'affiche le pseudo de l'utilisateur...
Que faire svp?
Merci d'avance pour votre aide!
NB : Pour récupérer l'avatar du dernier poster sur l'accueil, je ferai ensuite cet appel :
$last_post = '<span style="float:left"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['last_poster_id'].'.gif" width="100" /></span>............Dernière modification par grvincent (13-08-2013 18:34:55)
Hors ligne
Salut!
C'est une (très) vieille mod, mais tu pourrais tester Max Visu Avatars, ou au moins t'inspirer de la jointure qui est faite. Tu peux aussi (plus léger) créer une colonne last_poster_id dans la table forums et l'actualiser à chaque post.
Hors ligne
Bonjour adaur et merci pour ta réponse rapide.
Je viens de regarder le code utilisé, mais je ne parviens toujours pas à faire apparaitre les avatar des last_poster sur l'index.
Dans la mod est destiné aux version 1.4.X..., et je suis toujours sur une 1.2....
$user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.gif" class="maxavatar" alt="" />';$cur_forum['uid'] n'existe pas sur la 1.2.XX
Que faire?
Hors ligne
Tu peux aussi (plus léger) créer une colonne last_poster_id dans la table forums et l'actualiser à chaque post.
Je sais créer la colonne dans la table, facile..; Mais je ne sais pas ce qu'il y aurait à ajouter sur post.php afin que l'id du poster soit ajouté dans cette nouvelle colonne last_poster_id que l'on aurait créé dans la table forums. Sais tu me dire quoi ajouter stp?
(la suite je sais faire, cad appeler last_poster_id sur index.php, mais bon.. Il me manque le plus gros)
Merci encore adaur pour ton aide!
Vincent.
Dernière modification par grvincent (14-08-2013 10:40:22)
Hors ligne
Pas vu le 1.2, désolé! Dans ce cas: http://fluxbb.fr/mods/mods.php?mid=121
Dans la 1.4, une fonction est appelée à chaque nouveau topic pour mettre à jour la table forum, update_forum je crois, dans include/functions.php.
Hors ligne
Je cherchais la mod pour les versions 1.2.XX mais je ne trouvais pas... (quel nul je suis)
Ca y est cela fonctionne super.
Un GRAND merci adaur! 
Vincent.
Hors ligne
C'est maintenant sur viewforum.php que je bloque... : "An error was encountered" à chaque essai...
Pour afficher les avatars, je dois remplacer ceci :
// Fetch list of topics to display on this page
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
// Without "the dot"
$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
// With "the dot"
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
case 'sqlite':
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
break;
default:
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
}
}Par :
// Fetch list of topics to display on this page
//---------------------
// Dans toutes les requetes --> u.id AS uid <-- a été rajouté
// ainsi que --> LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username <--
//---------------------
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
// Without "the dot"
$sql = 'SELECT u.id AS uid, t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
// With "the dot"
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
case 'sqlite':
$sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
break;
default:
$sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
}
}Mais le problème est que j'ai plus d'infos qui sont recupérés à cause des différentes mod déjà installées.
Voici mon code :
// Fetch list of topics to display on this page
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
// Without "the dot"
$sql = 'SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, question, e.voters, e.votes, t.Important FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'evaluate AS e ON t.id=e.t_id WHERE t.forum_id='.$id.' ORDER BY sticky DESC, '.$sort_by[$cur_forum['sort_by']].' LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
// With "the dot"
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, e.voters, e.votes, t.Important FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.$sort_by[$cur_forum['sort_by']].' LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
case 'sqlite':
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, e.voters, e.votes, t.Important FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.$sort_by[$cur_forum['sort_by']].' LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
break;
default:
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, e.voters, e.votes, t.Important FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, p.poster_id ORDER BY sticky DESC, '.$sort_by[$cur_forum['sort_by']].' LIMIT '.$start_from.', '.$pun_user['disp_topics'];
break;
}
}Serais tu m'aider un dernier coup stp?
Hors ligne