par
Jean-Pierre » 29 déc. 2010, 03:18
Bonjour, je possède un forum phpbb, et je suis en train d'élaborer un portail par moi-même.
Je veux que certains textes des postes d'une catégorie du forum soit affichés sur le portail sous forme de news et limités à 40 caractères et qu'il y ait des points de suspension à la fin.
J'ai une table dans ma base de donnée : post_text qui contient des valeurs dont le texte qui va s'afficher, pour l'instant je n'ai pas eu de mal à faire le code pour afficher la news mais le probleme viens maintenant à la fonction pour tronquer la variable sql suivante : ' . $row['post_text'] . '
J'implore votre aide, je tourne en rond depuis deux heure, j'ai aussi fait une recherche dans le forum mais je n'ai pas trouvé de solution.
Voici le code de ma page pour l'instant
Code : Tout sélectionner
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="styles/prosilver/theme/list-44.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul class="list-44">
<?php define('IN_PHPBB', TRUE);
$phpbb_root_path = '';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$sql = "SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name, p.post_text, p.post_time, u.user_id, u.username, t.topic_first_poster_name
FROM phpbb_topics AS t, phpbb_forums AS f, phpbb_posts AS p, phpbb_users AS u
WHERE t.forum_id = f.forum_id
AND t.topic_moved_id = 0
AND u.user_id = p.poster_id
AND f.forum_id = 28
AND t.topic_first_post_id = p.post_id
ORDER BY t.topic_last_post_id DESC
LIMIT 2";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
echo '
<li>
<div>
<img src="/styles/prosilver/images/1page-img8.jpg" alt="">
<strong>
' . $row['topic_title'] . '
</strong>
<p>
' . $row['post_text'] . '
</p>
<a target="_blank" class="link" href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '"><span>Lire plus</span></a>
<b><a target="_blank" href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '">' . $row['topic_replies'] . ' commentaires</a>
</b>
</div>
</li>';
}
?>
</ul>
</body>
</html>
Passez une bonne nuit et merci.
Bonjour, je possède un forum phpbb, et je suis en train d'élaborer un portail par moi-même.
Je veux que certains textes des postes d'une catégorie du forum soit affichés sur le portail sous forme de news et limités à 40 caractères et qu'il y ait des points de suspension à la fin.
J'ai une table dans ma base de donnée : post_text qui contient des valeurs dont le texte qui va s'afficher, pour l'instant je n'ai pas eu de mal à faire le code pour afficher la news mais le probleme viens maintenant à la fonction pour tronquer la variable sql suivante : ' . $row['post_text'] . '
J'implore votre aide, je tourne en rond depuis deux heure, j'ai aussi fait une recherche dans le forum mais je n'ai pas trouvé de solution.
Voici le code de ma page pour l'instant
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="styles/prosilver/theme/list-44.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul class="list-44">
<?php define('IN_PHPBB', TRUE);
$phpbb_root_path = '';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$sql = "SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name, p.post_text, p.post_time, u.user_id, u.username, t.topic_first_poster_name
FROM phpbb_topics AS t, phpbb_forums AS f, phpbb_posts AS p, phpbb_users AS u
WHERE t.forum_id = f.forum_id
AND t.topic_moved_id = 0
AND u.user_id = p.poster_id
AND f.forum_id = 28
AND t.topic_first_post_id = p.post_id
ORDER BY t.topic_last_post_id DESC
LIMIT 2";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
echo '
<li>
<div>
<img src="/styles/prosilver/images/1page-img8.jpg" alt="">
<strong>
' . $row['topic_title'] . '
</strong>
<p>
' . $row['post_text'] . '
</p>
<a target="_blank" class="link" href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '"><span>Lire plus</span></a>
<b><a target="_blank" href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '">' . $row['topic_replies'] . ' commentaires</a>
</b>
</div>
</li>';
}
?>
</ul>
</body>
</html>[/code]
Passez une bonne nuit et merci.