Nome Mod: Mod Topic of the week
Autore: Micogian
Descrizione della Mod: Consente di selezionare un certo numero di Topic che contengono nel testo il bbcode [img].
La Mod provvede a estrarre il link dell'immagine inserito tra i bbcode e visualizzarla in una striscia inserita nella Home page del Forum.
Può tornare utile per evidenziare immagini che richiamano alcuni Topics, come "Foto del mese", "Topics della settimana", ecc.
Versione Mod: 1.0.1
Versioni compatibili phpBB: 3.0.x
Istruzioni
1) Creare un Topic in area riservata. Questo Topic ha lo scopo di contenere nel testo la lista dei topic_id selezionati separati da una virgola.
(es. 4523,4530,4600,4602,4607) Il testo non deve contenere altre stringhe al di fuori della Lista topic_id.
2) Nella root del Forum creare il file mod_week_img.php con il contenuto seguente:
Codice: Seleziona tutto
<?php
// Mod Topic of the week - by Micogian 2010
if (!defined('IN_PHPBB'))
{
exit;
}
$post_ori = '9999'; // inserire il post_id del Topic contenente la Lista dei topic_id
// Estrae la lista dei post_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
$sql1 = "SELECT topic_id, post_id, post_subject, post_text, bbcode_uid FROM " . POSTS_TABLE . " WHERE topic_id IN(" . $topic_list . ") ORDER BY topic_id, 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'){
// Titolo
if (strlen($row1['post_subject'] > '28'))
{
$topic_title_short = substr($row1['post_subject'],0,27) . "...";
}else{
$topic_title_short = $row1['post_subject'];
}
// immagine compresa 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] ; // link dell'immagine
// descrizione compresa tra i tag [quote]...[/quote]
$post_quote_tmp = str_replace("[/quote:]","[quote:]", $post_text_tmp) ;
$post_quote2 = explode("[quote:]", $post_quote_tmp) ;
$post_quote = $post_quote2[1] ;
if (strlen($post_quote) > 200){
$post_quote_short = substr($post_quote,0,200) . "..." ;
}else{
$post_quote_short = $post_quote ;
}
$template->assign_block_vars('week_topic', array(
'U_WEEK_TITLE' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $row1['topic_id']),
'WEEK_TITLE' => $row1['post_subject'] ,
'WEEK_TITLE_SHORT' => $topic_title_short,
'WEEK_IMG' => $post_img ,
'WEEK_SHORT_TEXT' => $post_quote_short
));
$lista_topics .= "," . $row1['topic_id'] ;
}
}
?>
Codice: Seleziona tutto
include($phpbb_root_path . 'mod_week_img.' . $phpEx);
Codice: Seleziona tutto
// Output page
Creare nella cartella "template" dello style di derivazione subsilver2 il file mod_week_img_body.html con il seguente contenuto:
Codice: Seleziona tutto
<div align='center'>
<table class="tablebg" width="100%" cellspacing="1">
<tr class="nav">
<td class="cat" valign="middle" align="center">I Films della settimana</td>
</tr>
<tr>
<td class="row1">
<div align="center">
<table width="98%" border="0" cellspacing="2" cellpadding="0">
<tr>
<!-- BEGIN week_topic -->
<td align="center" valign="top" width="20%" style="font-size: 0.9em;"><a href="{week_topic.U_WEEK_TITLE}" title="{week_topic.WEEK_TITLE}">{week_topic.WEEK_TITLE_SHORT}</a></td>
<!-- END week_topic -->
</tr>
<tr>
<!-- BEGIN week_topic -->
<td>
<div align="center">
<a href="{week_topic.U_WEEK_TITLE}" title="{week_topic.WEEK_SHORT_TEXT}"><img src="{week_topic.WEEK_IMG}" alt="{week_topic.WEEK_TITLE}" height="250" border="0"></a></div>
</td>
<!-- END week_topic -->
</tr>
</table>
<br>
</div>
</td>
</tr>
</table>
</div>
<br clear="all" />
Codice: Seleziona tutto
<!-- INCLUDE forumlist_body.html -->
Codice: Seleziona tutto
<!-- INCLUDE mod_week_img_body.html -->
Naturalmente la Mod, con opportune modifiche, si presta per realizzare una striscia di immagini relative a Topic da mettere in evidenza, come "Foto del mese", "Topics della settimana", ecc.
Non l'ho provata, è solo teorica, spero funzioni.