Les archives de FluxBB.fr
Vous n'êtes pas identifié(e).
Bonjour, je suis en train d'élaborer un mod; et je n'arrive pas à faire deux choses :
cela concerne en fait la recherche.
Je voudrais que
1) Quand on fait une recherche, le "status" du topic s'affiche (si c'est un "sticky", etc)
2) Que l'on puisse faire une recherche par status de sticky (j'ai ajouté une checkbox sur la page de recherche pour les limiter aux topics sticky)
J'aimerais en particulier résoudre au plus vite le 2e point.
Le problème est que je ne sais pas où je dois modifier la requête dans le search.php...
Il faudrait mettre en place une condition de type
SI checkbox = cochée;
ALORS ..requete... WHERE sticky=1
Merci pour votre aide !
Hors ligne
salut,
tu trouvera dans la doc une page "Infos développeurs" avec une partie Références tables de la base de données
est-ce que cela t'aide ? ou ai-je mal compris la question ? ah bah y'a pas de question 
Hors ligne
Hello, bien utile comme page; mais, non, ça ne m'aide pas... 
Bon en gros voilà ce que j'ai modifié
if ($show_as == 'posts')
{
$substr_sql = ($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR';
$sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
}
else
$sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM '.$db->prefix.'topics AS t WHERE t.id IN('.$search_results.') GROUP BY t.id, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.sticky, t.news, t.forum_id'.$group_by_sql.' ORDER BY '.$sort_by_sql;
if ($show_as == 'posts')
{
$substr_sql = ($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR';
$sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies,t.news, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
}
else
$sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.sticky, t.news, t.forum_id FROM '.$db->prefix.'topics AS t WHERE t.id IN('.$search_results.') GROUP BY t.id, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.news, t.forum_id'.$group_by_sql.' ORDER BY '.$sort_by_sql;
if ($action != 'show_new' && $action != 'show_24h' && $action != 'show_unanswered' && $action != 'show_subscriptions')
message($lang_common['Bad request']);
if ($action != 'show_new' && $action != 'show_24h' && $action != 'show_news' && $action != 'show_unanswered' && $action != 'show_subscriptions')
message($lang_common['Bad request']);
else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_user' || (...)
else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_news' || $action == 'show_user' || (...)
// If it's a search for posts by a specific user ID
else if ($action == 'show_user')
{
...
}
// If it's a search for subscribed topics
else if ($action == 'show_subscriptions')
{
...
}
// If it's a search for posts by a specific user ID
else if ($action == 'show_user')
{
...
}
// If it's a search for news
else if ($action == 'show_news')
{
$result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.news_id=1 GROUP BY t.id') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
$num_hits = $db->num_rows($result);if (!$num_hits)
message($lang_search['No user posts']);
}
// If it's a search for subscribed topics
else if ($action == 'show_subscriptions')
{
...
}
Mais il me fait direct un "Error: Unable to fetch topic list." quand je fais
search.php?action=show_news
Dernière modification par grosbouff (28-11-2006 12:10:02)
Hors ligne
tu peut activer le mode debug pour avoir plus de détails sur l'erreur SQL
Hors ligne