Código PHP:
<?php
$phpbb_root_path = './foro/'; //Path to forum
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
// Start session management
$user->setup();
?>
<div align="justify" class="Estilo4">
<?php
//
// Configuration
//
$forum_id = 7; //Forum ID to pull posts from
$num_posts = 2; //Number of posts to display
//
// Auth
//
$can_read_forum = $auth->acl_getf('f_read'); //Get the forums the user can read from
$forum_id_ary = array_keys($can_read_forum); //Rework the array some
unset($can_read_forum);
//
// Recent posts
//
if(array_key_exists($forum_id, $forum_id_ary)) //See if the user is authed to read from that forum
{
$sql = 'SELECT p.post_id, t.topic_id, t.topic_replies, t.topic_views, p.post_subject, p.post_text, p.post_time, p.bbcode_bitfield, p.bbcode_uid, u.username
FROM ' . TOPICS_TABLE . ' t
INNER JOIN ' . POSTS_TABLE . ' p ON (t.topic_id = p.topic_id)
INNER JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)
WHERE t.topic_approved = 1
AND p.post_approved = 1
AND p.forum_id = ' . $forum_id . '
AND p.post_id = t.topic_first_post_id
ORDER BY p.post_time DESC';
$result = $db->sql_query_limit($sql, $num_postsn);
$row = $db->sql_fetchrowset($result);
for($i = 0; $i < $num_posts; $i++)
{
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $forum_id . '&t=' . $row[$i]['topic_id'] . '&p=' . $row[$i]['post_id'] . 'p' . $row[$i]['post_id']);
//-----------------+
$views = $row[$i]['topic_views'];
$reply = $row[$i]['topic_replies'];
//-----------------+
$uid = $bitfield = $options = '';
$allow_bbcode = $allow_smilies = $allow_urls = true;
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
function limitarPalabras($cadena, $longitud, $elipsis = "...")
{
$palabras = explode(' ', $cadena);
if (count($palabras) > $longitud)
return implode(' ', array_slice($palabras, 0, $longitud)) . $elipsis;
else
return $cadena;
}
$cadena = generate_text_for_display($row[$i]['post_text'], $row[$i]['bbcode_uid'], $row[$i]['bbcode_bitfield'], $flags);
// $reply = generate_text_for_display( $row[$i]['topic_replies'], $flags);
echo '<div width="90%"><div align="left">Fecha: ' . date('d-m-Y [G:i]', $row[$i]['post_time']) . '</div>---------------------------------------------------------------------------------------------------------------<br>
<span class="titulo"><strong>' . censor_text($row[$i]['post_subject']) . '</strong></span><br>
---------------------------------------------------------------------------------------------------------------<br>
<div class="contenido">'limitarPalabras($cadena,6)'</div><br>---------------------------------------------------------------------------------------------------------------<br><div align="right"> <a href="' . $post_url . '" target=\"_blank\">Leer todo</a> | ' . $reply .' Comentarios | '. $views .' Visitas<br>
---------------------------------------------------------------------------------------------------------------<br>
<span class="subtitulo"> Escrito por <b><u><span title="' . $row[$i]['username'] . '">' . $row[$i]['username'] . '</span></u></b><br></div>
---------------------------------------------------------------------------------------------------------------<br>---------------------------------------------------------------------------------------------------------------<br>
</div>';
}
$db->sql_freeresult($result);
}
?>
Código PHP:
function limitarPalabras($cadena, $longitud, $elipsis = "...")
{
$palabras = explode(' ', $cadena);
if (count($palabras) > $longitud)
return implode(' ', array_slice($palabras, 0, $longitud)) . $elipsis;
else
return $cadena;
}
$cadena = generate_text_for_display($row[$i]['post_text'], $row[$i]['bbcode_uid'], $row[$i]['bbcode_bitfield'], $flags);
Código PHP:
<div class="contenido">'limitarPalabras($cadena,6)'</div><br>
La pagina de donde lo de limitar palabras es:
dxpro.es/index.php?topic=239.0
La pagina donde aparece el error (los errores):
animextra.net78.net/index-3.php
(lamento tener que dar enlaces antes de mis 30posts pero tenia que mostrar las paginas de donde saque los codigos y donde esta la pagina donde pruebo los codigos, nuevamente perdon)