Página 1 de 1

Existe mod que: te lleve a un tema de forma aleatoria??

Publicado: 24 Jul 2011, 00:49
por Cruciattus
Hola, mi pregunta es, hay algun mod que haga lo siguiente:
Quiero poner una imagen y cuando la gente cliquee sobre esa imagen, que sean llevados a un tema cualquiera al azar de ciertos foros. Cada vez que alguien cliquee sobre la imagen vaya a un tema distinto cada vez. Se puede lograr mediante algun mod? o quizas un bbcode?. Espero haberme explicado bien, gracias

Re: Existe mod que: te lleve a un tema de forma aleatoria??

Publicado: 26 Jul 2011, 06:32
por Cruciattus
Bueno he visto por ahi que la gente reflota sus hilos si no les responden^^ asi que refloto mi pregunta xD
hay algo que pueda llevarte a un tema de forma aleatoria?? por ejemplo clicando sobre una imagen. Esto me vendria muy bien para mi foro^^ gracias.

Re: Existe mod que: te lleve a un tema de forma aleatoria??

Publicado: 26 Jul 2011, 06:35
por loquitomed
Hola BlackGril!

Razon de por que no te responden:
http://www.phpbb-es.com/foro/rules/index.php#rule1h

Salu2 :wink:

Re: Existe mod que: te lleve a un tema de forma aleatoria??

Publicado: 26 Jul 2011, 06:40
por memoadian
Reflotar va en contra de las normas blackgirl, pero creo que te puedo ayudar.

aqui el problema sería la consulta sql, pues bien veamos si con un poco de código se puede.

creamos un archivo llamado aleatorio.php y colocamos este código dentro, asi como está
SPOILER_SHOW

Código: Seleccionar todo

<?php 

// Amount of active topics to show 
define("TOPIC_COUNT", 1); 

// Path to the phpBB 3.0 root directory 
define("PHPBB_PATH", "../"); 

// URL to the phpBB 3.0 installation 
define("PHPBB_LOCATION", "http://www.cruciatus-hogwarts.com/"); 

// Time format to output the date/time (for format see PHP manual) 
define("TIME_FORMAT", "d/m/Y");

// php extension using
$phpEx = "php";

// No Editing unless you know what your doing
if ( !defined('IN_PHPBB') ) 
{
	define('IN_PHPBB', true);
}

// Get the needed phpbb files, thank you phpbb =]
include($phpbb_root_path  . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);
$user->setup();

// HTML header start 

?> 
<style>
a:link, 
a:visited {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #496c9f;	
	text-decoration: none;	
}

a:hover {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #496c9f;	
	text-decoration: underline;
}

a:active {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #496c9f;	
	text-decoration: none; 	
}
</style>
<table border="0" cellpadding="1" cellspacing="1" width="100%"> 
<tr> 
<th align="center" bgcolor="#DFE6EF"><font color="#5F5757" size="2">Titulo</font></th> 
<th align="center" bgcolor="#DFE6EF"><font color="#5F5757" size="2">Visitas</font></th> 
<th align="center" bgcolor="#DFE6EF"><font color="#5F5757" size="2">Respuesta</font></th> 
<th align="center" bgcolor="#DFE6EF"><font color="#5F5757" size="2">Ultimos mensajes</font></th> 
<th align="center" bgcolor="#DFE6EF"><font color="#5F5757" size="2">Fecha</font></th> 
</tr> 
<?php 

// HTML header end 

$sql = "SELECT DISTINCT t.topic_title, 
t.topic_id,t.topic_views,t.topic_replies, t.topic_last_post_id, t.topic_last_poster_colour,
p.post_time,p.poster_id, 
f.forum_name, 
u.user_id, u.username, u.style_color, u.style_fontweight, u.style_fontstyle, u.style_background, u.style_decoration, u.style_border, u.style_enabled
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f, " . USERS_TABLE . " AS u 
WHERE t.forum_id = f.forum_id

AND p.topic_id = t.topic_id 
AND p.poster_id = u.user_id 
AND p.post_id = t.topic_last_post_id 
ORDER BY RAND() DESC LIMIT " . TOPIC_COUNT; 
$nt_result = $db->sql_query($sql); 

if(!$nt_result)
{
    die("Failed obtaining list of active topics".mysql_error());
}
else 
{
    $nt_data = $db->sql_fetchrowset(); 
}

if ( count($nt_data) == 0 ) 
{
    die("No topics found"); 
} 
else 
{ 
    $cq = 1; 
    $cc = FFFFFF; 
// $nt_data contains all interesting data 
    for ($i = 0; $i < count($nt_data); $i++) 
    { 
        $title = $nt_data[$i]['topic_title'];
        $Turl = PHPBB_LOCATION . 'viewtopic.' . $phpEx . "?t=" . $nt_data[$i]['topic_id']; 
        $LPurl = PHPBB_LOCATION . "topic-t". $nt_data[$i]['topic_id'] . ".html#p" . $nt_data[$i]['topic_last_post_id'];
        $st_color = $nt_data[$i]['style_enabled'];
		if($st_color == "true"){
			$color = $nt_data[$i]['style_color'];
			$color = str_replace("#", "", $color);
			$fontweight = $nt_data[$i]['style_fontweight'];
			$fontstyle = $nt_data[$i]['style_fontstyle'];
			$background = $nt_data[$i]['style_background'];
			$decoration = $nt_data[$i]['style_decoration'];
			$border= $nt_data[$i]['style_border'];
		}else{
			$color = $nt_data[$i]['topic_last_poster_colour'];
		}
		
        $on_forum = 'Foro ' . $nt_data[$i]['forum_name']; 
        $post_time = date(TIME_FORMAT, $nt_data[$i]['post_time']); 
//Profile profile.php?mode=viewprofile&u=23 
        $profile = PHPBB_LOCATION . 'memberlist.' . $phpEx . "?mode=viewprofile&u=" . $nt_data[$i]['poster_id'] ; 
        $usrname = $nt_data[$i]['username']; 
// Item HTML start 

        if($cq%2 == 0)
        {
            $cc = E8EFF4;$cq++;
        } 
        else
        {
            $cc = E8EFF4;$cq++;
        }
?> 
<tr> 
<td bgcolor="#<?php echo $cc;?>" align="left"><a href="<?php echo $LPurl; ?>" title="<?php echo $on_forum; ?>" 

target="_parent"><font face="verdana" color="#496C9F" size="1"><B><?php echo $title; ?></B></font></a></td> 
<td bgcolor="#<?php echo $cc;?>" align="left"><div align="center"><font face="verdana" color="#5B5B5B" size="1"><?php echo 

$nt_data[$i]['topic_views'] ?></div></td> 
<td bgcolor="#<?php echo $cc;?>" align="left"><font face="verdana" color="#5B5B5B" size="1"><div align="center"><?php echo 

$nt_data[$i]['topic_replies'] ?></div></td> 
<td align="center" bgcolor="#<?php echo $cc;?>" align="left"><font face="verdana" color="#666666" size="1">
<?php if($st_color == "false"){?>
<a href="<?php 

echo $profile; ?>" target="_parent"><font face="verdana" color="#496C9F" size="1"><B><span style="color:#<?php echo $color;?>;"><?php echo $usrname?></span></B></a>
<?php }else{?>
<a class="username-coloured" style="color: <?php echo $color;?>; font-weight: <?php echo $fontweight;?>; font-style: <?php echo $fontstyle;?>; background-color: <?php echo $background;?>; text-decoration: <?php echo $decoration;?>; border: <?php echo $border;?>;" href="<?php echo $profile;?>"><?php echo $usrname;?></a>
<?php
}?>
</td>
<td bgcolor="#<?php echo $cc;?>" align="left"><font face="verdana" color="#5B5B5B" size="1"><div align="center"><?php echo 

$post_time ?></div></td> 
</tr> 
<?php 

// Item HTML end 

    } 
} 

// Footer HTML start 

?>
luego lo subes a la raíz de tu foro y vas a

http://www.cruciatus-hogwarts.com/aleatorio.php

te debe mostrar un resultado de un mensaje de menera totalmente aleatoria. bueno segun mysql y la función rand()

sería cuestión de aplicarse con el diseño, y lo puedes colocar en tu foro en un frame, hay muchas posibilidades

pero ahorita ya me dio sueño :-|

Re: Existe mod que: te lleve a un tema de forma aleatoria??

Publicado: 26 Jul 2011, 11:54
por Cruciattus
Es la primera vez que refloto....creo, y lo he hecho porque he visto como lo han hecho aqui en esta seccion xDD. Lo tendré en cuenta la proxima vez sin duda, gracias a los dos por la indicacion.
Memoadian; gracias por la ayuda en primer lugar!! parece un codigo sencillo y ademas facil de hacer! voy a ponerlo en practica enseguida a ver si logro lo que tenia pensado.