Les archives de FluxBB.fr
Vous n'êtes pas identifié(e).
Pages : 1
Salut ☺
En voulant afficher le titre ( Passant, Régulier...) sur la page Profil
J'ai essayé le code trouvé dans functions.php
function get_title($user) (ligne ~490)
// Are there any ranks?
if ($pun_config['o_ranks'] == '1' && !empty...
Et <?php echo $user_title ?>mais sans succès.
Votre aide serait grandement appréciée.
Hors ligne
???
Le titre est (il me semble) DEJA affiché sur la partie profil : là, par exemple, sous "beeriz", je vois bien "Membre"...
Où je n'ai pas compris la question...
EDIT : Ahh, sur la "page Profil"... ok (au temps pour moi)
EDIT 2 : maintenant que j'ai compris la question, je ne vois pas pourquoi ça ne marcherait pas. Quel est précisemment le code que tu as inséré dans profile.php (note : NE PUBLIES PAS l'intégralité du fichier, trop long. Seulement les modifs) ?
Dernière modification par Mpok (31-12-2009 02:17:07)
Hors ligne
je ne vois pas non plus pourquoi cela ne marcherait pas 
une petite question, tu cherches à afficher le rang, j'imagine que $pun_config['o_rank'] est donc toujours égal à 1, mais, dans ta situation, le rang peut-il être vide ? si oui que voudrait-tu afficher à la place ?
désolé mais je n'utilise pas ce système 
Hors ligne
Comment le rang peut-il être vide ?
Ce que je veux faire, c'est d'afficher le rank (des membres seulement) sans vérifier si l'utilisateur à modifier son titre..., donc on calcule le nombre de post puis on le compare avec la valeur de rang.
//
// Determines the correct title for $user
// $user must contain the elements 'username', 'title', 'posts', 'g_id' and 'g_user_title'
//
function get_title($user)
{
global $db, $pun_config, $pun_bans, $lang_common;
static $ban_list, $pun_ranks;
// If not already built in a previous call, build an array of lowercase banned usernames
if (empty($ban_list))
{
$ban_list = array();
foreach ($pun_bans as $cur_ban)
$ban_list[] = strtolower($cur_ban['username']);
}
// If not already loaded in a previous call, load the cached ranks
if ($pun_config['o_ranks'] == '1' && empty($pun_ranks))
{
@include PUN_ROOT.'cache/cache_ranks.php';
if (!defined('PUN_RANKS_LOADED'))
{
require_once PUN_ROOT.'include/cache.php';
generate_ranks_cache();
require PUN_ROOT.'cache/cache_ranks.php';
}
}
// If the user has a custom title
if ($user['title'] != '')
$user_title = pun_htmlspecialchars($user['title']);
// If the user is banned
else if (in_array(strtolower($user['username']), $ban_list))
$user_title = $lang_common['Banned'];
// If the user group has a default user title
else if ($user['g_user_title'] != '')
$user_title = pun_htmlspecialchars($user['g_user_title']);
// If the user is a guest
else if ($user['g_id'] == PUN_GUEST)
$user_title = $lang_common['Guest'];
else
{
// Are there any ranks?
if ($pun_config['o_ranks'] == '1' && !empty($pun_ranks))
{
@reset($pun_ranks);
while (list(, $cur_rank) = @each($pun_ranks))
{
if (intval($user['num_posts']) >= $cur_rank['min_posts'])
$user_title = pun_htmlspecialchars($cur_rank['rank']);
}
}
// If the user didn't "reach" any rank (or if ranks are disabled), we assign the default
if (!isset($user_title))
$user_title = $lang_common['Member'];
}
return $user_title;
}Hors ligne
Tu dois créer une nouvelle fonction identique à celle-ci, en changeant son nom bien entendu, et en supprimant les lignes suivantes :
if ($user['title'] != '')
$user_title = pun_htmlspecialchars($user['title']);
// If the user is banned
elseCette fonction fonctionnera exactement comme l'autre, sauf qu'elle ne prendra pas en compte les titres choisis dans le profil.
Si ça ne te convient, il te suffit de lire les commentaires des lignes qui suivent pour voir ce que ça fait, ou encore de faire des tests en local pour enlever les parties qui te gênent encore.
Nous ne faisons pas le travail à votre place mais nous prenons le temps de vous montrer le chemin. Merci de lire ce que l'on vous dit et de réfléchir avant de re-demander une explication.
Hors ligne
Génial ça marche ! Merci
// Determines the rank for $user
function get_rank($user)
{
global $db, $pun_config, $pun_bans, $lang_common;
static $ban_list, $pun_ranks;
// If not already built in a previous call, build an array of lowercase banned usernames
if (empty($ban_list))
{
$ban_list = array();
foreach ($pun_bans as $cur_ban)
$ban_list[] = strtolower($cur_ban['username']);
}
// If not already loaded in a previous call, load the cached ranks
if ($pun_config['o_ranks'] == '1' && empty($pun_ranks))
{
@include PUN_ROOT.'cache/cache_ranks.php';
if (!defined('PUN_RANKS_LOADED'))
{
require_once PUN_ROOT.'include/cache.php';
generate_ranks_cache();
require PUN_ROOT.'cache/cache_ranks.php';
}
}
// If the user is banned
if (in_array(strtolower($user['username']), $ban_list))
$user_title = $lang_common['Banned'];
// If the user group has a default user title
else if ($user['g_user_title'] != '')
$user_title = "Spécial";
// If the user is a guest
else if ($user['g_id'] == PUN_GUEST)
$user_title = $lang_common['Guest'];
else
{
// Are there any ranks?
if ($pun_config['o_ranks'] == '1' && !empty($pun_ranks))
{
@reset($pun_ranks);
while (list(, $cur_rank) = @each($pun_ranks))
{
if (intval($user['num_posts']) >= $cur_rank['min_posts'])
$user_title = pun_htmlspecialchars($cur_rank['rank']);
}
}
// If the user didn't "reach" any rank (or if ranks are disabled), we assign the default
if (!isset($user_title))
$user_title = $lang_common['Member'];
}
return $user_title;
}Bonne journée.
Hors ligne
Pages : 1