Recordad que para pedir soporte alguno, debéis facilitar los datos de soporte oportunos por favor, mirad aquí y leer las Normas generales del foro, esto nos servirá de ayuda para dar el mejor soporte..

Gracias.

La Administración de phpBB España.

Mostrar ultimos temas en pagina externaTema Solucionado

Foros donde podréis dejar vuestras dudas sobre phpBB 3.0.x
Cerrado
Avatar de Usuario
Makoto
Elite
Mensajes: 2929
Registrado: 10 Sep 2009, 23:44
Género:
Edad: 37

Mostrar ultimos temas en pagina externa

#1

Mensaje por Makoto »

Bueno segui el tutorial de aqui
https://wiki.phpbb.com/Practical.Displa ... rnal_pages

al realizar todo me sale el siguiente error en la cabecera

Código: Seleccionar todo

[phpBB Debug] PHP Notice: in file /public_html/index.php on line 77: Undefined variable: topic_id_list
el codigo que uso es

Código: Seleccionar todo

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './foro/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/web');

/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing 
* posts and topics */

function create_where_clauses($gen_id, $type)
{
global $db, $auth;

    $size_gen_id = sizeof($gen_id);

        switch($type)
        {
            case 'forum':
                $type = 'forum_id';
                break;
            case 'topic':
                $type = 'topic_id';
                break;
            default:
                trigger_error('No type defined');
        }

    // Set $out_where to nothing, this will be used of the gen_id
    // size is empty, in other words "grab from anywhere" with
    // no restrictions
    $out_where = '';

    if( $size_gen_id > 0 )
    {
    // Get a list of all forums the user has permissions to read
    $auth_f_read = array_keys($auth->acl_getf('f_read', true));

        if( $type == 'topic_id' )
        {
            $sql     = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
                        WHERE ' .  $db->sql_in_set('topic_id', $gen_id) . '
                        AND ' .  $db->sql_in_set('forum_id', $auth_f_read);

            $result     = $db->sql_query($sql);

                while( $row = $db->sql_fetchrow($result) )
                {
                        // Create an array with all acceptable topic ids
                        $topic_id_list[] = $row['topic_id'];
                }

            unset($gen_id);

            $gen_id = $topic_id_list;
            $size_gen_id = sizeof($gen_id);
        }

    $j = 0;    

        for( $i = 0; $i < $size_gen_id; $i++ )
        {
        $id_check = (int) $gen_id[$i];

            // If the type is topic, all checks have been made and the query can start to be built
            if( $type == 'topic_id' )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }

            // If the type is forum, do the check to make sure the user has read permissions
            else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }    

        $j++;
        }
    }

    if( $out_where == '' && $size_gen_id > 0 )
    {
        trigger_error('A list of topics/forums has not been created');
    }

    return $out_where;
}

$search_limit = 5;

    $forum_id = array(2, 51);
    $forum_id_where = create_where_clauses($forum_id, 'forum');

    $topic_id = array(15, 16);
    $topic_id_where = create_where_clauses($topic_id, 'topic');
	
$topics = 'SELECT * FROM ' . TOPICS_TABLE . '
            ' . $forum_id_where . '
              AND topic_status <> ' . ITEM_MOVED . '
              AND topic_approved = 1
            ORDER BY topic_id DESC';

   $topics_result = $db->sql_query_limit($topics, $search_limit);

      while( $topics_row = $db->sql_fetchrow($topics_result) )
      {
		// www.phpBB-SEO.com SEO TOOLKIT BEGIN
        if (!empty($topics_row['topic_url'])) {
            $phpbb_seo->prepare_iurl($topics_row, 'topic', '');
        } else {
            if ($phpbb_seo->modrtype > 2) {
                $topics_row['topic_title'] = censor_text($topics_row['topic_title']);
            }
            $cur_forum_id = (int) $topics_row['forum_id'];
            $parent_forum = $topics_row['topic_type'] == POST_GLOBAL ? $phpbb_seo->seo_static['global_announce'] : (!empty($phpbb_seo->seo_url['forum'][$cur_forum_id]) ? $phpbb_seo->seo_url['forum'][$cur_forum_id] : false);
            if ($parent_forum) {
                $phpbb_seo->prepare_iurl($topics_row, 'topic', $parent_forum);
            }
        }
        // www.phpBB-SEO.com SEO TOOLKIT END   
         $topic_title       = $topics_row['topic_title'];
         $topic_author       = get_username_string('full', $topics_row['topic_poster'], $topics_row['topic_first_poster_name'], $topics_row['topic_first_poster_colour']);
         $topic_date       = $user->format_date($topics_row['topic_time']);
         $topic_last_post    = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topics_row['forum_id'] . '&t=' . $topics_row['topic_id'] . '&p=' . $topics_row['topic_last_post_id']) . '#p' . $topics_row['topic_last_post_id'];
         $topic_last_author    = get_username_string('full', $topics_row['topic_last_poster_id'], $topics_row['topic_last_poster_name'], $topics_row['topic_last_poster_colour']);
         $topic_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topics_row['forum_id'] . '&t=' . $topics_row['topic_id']);

         $template->assign_block_vars('announcements', array(
         'TOPIC_TITLE'       => censor_text($topic_title),
         'TOPIC_AUTHOR'       => $topic_author,
         'TOPIC_DATE'       => $topic_date,
         'TOPIC_LAST_POST'    => $topic_last_post,
         'TOPIC_LAST_AUTHOR' => $topic_last_author,
         'TOPIC_LINK'       => $topic_link,
         ));
      }

page_header($user->lang['WEB_TITLE']);

$template->set_filenames(array(
	'body' => 'web/index_body.html')
);

page_footer();

?>
URL del foro: FIIS-UNAC
Versión phpBB: phpBB3 ( 3.1.5)
Extensiones Instaladas
SPOILER_SHOW
  • Add User 1.0.2
  • Auto Database Backup 1.1.0
  • Auto Groups 1.0.0
  • Avatars on Memberlist 1.0.3
  • Board Announcements 1.0.2
  • Board Rules 1.0.1
  • cBB Chat 1.1.1
  • Fancy Lazy Topics loader 2.1.5
  • Genders 1.0.0
  • Last Post Avatar
  • Log failed logins
  • Rank Post Styling
  • Share On 1.0.0
  • SiteSplat BBCore 2.1.1
  • Sortables Captcha 2.0.0
  • Topic Author 1.0.1
  • Upload Extensions 3.1.2-beta2
Plantilla(s) usada(s):
  • FLATBOOTS 2.0.1
Servidor: Dattatec[/size]

Avatar de Usuario
Alorse
Ex Staff
Mensajes: 5144
Registrado: 22 Mar 2008, 02:14
Género:
Edad: 37

Re: Mostrar ultimos temas en pagina externa

#2

Mensaje por Alorse »

Este tema, tal vez pueda ayudarte Mod para mostrar mensajes en pág externa??
Aunque el error que te sale es relativamente sencillo, solo debes declarar la variable $topic_id_list y debería solucionarse.

Avatar de Usuario
Makoto
Elite
Mensajes: 2929
Registrado: 10 Sep 2009, 23:44
Género:
Edad: 37

Re: Mostrar ultimos temas en pagina externa

#3

Mensaje por Makoto »

Bueno _Vinny_ de phpBB.com me dio una solución, esta bien así?

https://www.phpbb.com/community/viewtop ... #p13176030
URL del foro: FIIS-UNAC
Versión phpBB: phpBB3 ( 3.1.5)
Extensiones Instaladas
SPOILER_SHOW
  • Add User 1.0.2
  • Auto Database Backup 1.1.0
  • Auto Groups 1.0.0
  • Avatars on Memberlist 1.0.3
  • Board Announcements 1.0.2
  • Board Rules 1.0.1
  • cBB Chat 1.1.1
  • Fancy Lazy Topics loader 2.1.5
  • Genders 1.0.0
  • Last Post Avatar
  • Log failed logins
  • Rank Post Styling
  • Share On 1.0.0
  • SiteSplat BBCore 2.1.1
  • Sortables Captcha 2.0.0
  • Topic Author 1.0.1
  • Upload Extensions 3.1.2-beta2
Plantilla(s) usada(s):
  • FLATBOOTS 2.0.1
Servidor: Dattatec[/size]

Avatar de Usuario
Alorse
Ex Staff
Mensajes: 5144
Registrado: 22 Mar 2008, 02:14
Género:
Edad: 37

Re: Mostrar ultimos temas en pagina externa  Tema Solucionado

#4

Mensaje por Alorse »

No es la manera más correcta, ya que solo esta validando que no este vacía, pero si lo ésta?
Mejor definela vacía antes del while o cambia $gen_id = !empty($topic_id_list); por $gen_id = isset($topic_id_list); así se garantiza que la variable se está definiendo.

Avatar de Usuario
Makoto
Elite
Mensajes: 2929
Registrado: 10 Sep 2009, 23:44
Género:
Edad: 37

Re: Mostrar ultimos temas en pagina externa

#5

Mensaje por Makoto »

Gracias!
URL del foro: FIIS-UNAC
Versión phpBB: phpBB3 ( 3.1.5)
Extensiones Instaladas
SPOILER_SHOW
  • Add User 1.0.2
  • Auto Database Backup 1.1.0
  • Auto Groups 1.0.0
  • Avatars on Memberlist 1.0.3
  • Board Announcements 1.0.2
  • Board Rules 1.0.1
  • cBB Chat 1.1.1
  • Fancy Lazy Topics loader 2.1.5
  • Genders 1.0.0
  • Last Post Avatar
  • Log failed logins
  • Rank Post Styling
  • Share On 1.0.0
  • SiteSplat BBCore 2.1.1
  • Sortables Captcha 2.0.0
  • Topic Author 1.0.1
  • Upload Extensions 3.1.2-beta2
Plantilla(s) usada(s):
  • FLATBOOTS 2.0.1
Servidor: Dattatec[/size]

Cerrado

Volver a “Foros de Soporte 3.0.x”