secondo questo codice, me lo potresti modificare a tale punto da ricercare all'interno del foum id 48 gli ultimi 4 topic(che hanno sicuramente al pimo messaggio il tag [img]:
Codice: Seleziona tutto
<?php// Mod Topic of the week - by Micogian 2010
$post_ori = '9999'; // inserire il post_id del Topic contenente la Lista dei topic_id
// Estrae dal post_id indicato in $post_ori la lista dei topic_id da elaborare
$sql = "SELECT post_id, post_text FROM " . POSTS_TABLE . " WHERE post_id = " . $post_ori ;
$result = $db->sql_query($sql);
{
$row = $db->sql_fetchrow($result);
$topic_list = $row['post_text'];
}
// elabora i topic selezionati della lista $topic_list
$sql1 = "SELECT tt.topic_id, tt.topic_title, tt.topic_poster, tt.topic_first_poster_name, tt.topic_attachment, tt.forum_id, tt.topic_first_poster_colour,
tp.topic_id, tp.post_id, tp.post_text, tp.bbcode_uid,
tf.forum_id, tf.forum_name
FROM " . TOPICS_TABLE . " tt," . POSTS_TABLE . " tp," . FORUMS_TABLE . " tf
WHERE tt.topic_id IN(" . $topic_list . ")
AND tt.topic_id = tp.topic_id
AND tt.forum_id = tf.forum_id
ORDER BY tp.topic_id, tp.post_id";
$result1 = $db->sql_query($sql1);
$lista_topics = '';
while ($row1 = $db->sql_fetchrow($result1))
{
// estrae solo il primo post di ogni Topic.
if( strpos($lista_topics, $row1['topic_id']) == '0'){
// Riduce la lunghezza del Titolo
if (strlen($row1['topic_title'] > '28'))
{
$topic_title_short = substr($row1['topic_title'],0,27) . "...";
}else{
$topic_title_short = $row1['topic_title'];
}
// estrae l'url delle immagini comprese tra i tag [img]...[/img]
$post_text_tmp = $row1['post_text'] ; // testo del post
$post_text_tmp = str_replace($row1['bbcode_uid'],"",$post_text_tmp);
$post_text1 = str_replace("[/img:]","[img:]", $post_text_tmp) ;
$post_text2 = explode("[img:]", $post_text1) ;
$post_img = $post_text2[1] ; // url dell'immagine
// Variabili da passare al template
$template->assign_block_vars('list_pictures_img', array(
'U_PIC_TITLE' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $row1['topic_id']),
'PIC_TOPIC_ID'=> $row1['topic_id'],
'PIC_TITLE' => $row1['topic_title'],
'PIC_IMG' => $post_img ,
'PIC_TITLE_SHORT' => $topic_title_short,
'PIC_FORUM' => $row1['forum_name'],
'PIC_AUTHOR' => get_username_string('full', $row1['topic_poster'], $row1['topic_first_poster_name'], $row1['topic_first_poster_colour']),
));
$lista_topics .= "," . $row1['topic_id'] ;
}
}
?>