Página 1 de 1

Temas Recientes en Web Externa!

Publicado: 09 Abr 2014, 16:39
por drAkeTool
URL: http://www.esparcraft.corpmore.com/
Versión phpBB: 3.0.12
MODs Instalados: UMIL - Unified Mod Install Library
NV recent topics
Topic Preview
Reputation System
Advanced BBCode Box 3 (aka ABBC3)
board3 Portal
PBWoW 2
PBWoW 2 - Topic Preview 2.0 MOD
Sortables CAPTCHA Plugin
Plantilla(s) usada(s): Prosilver
Servidor: Hostgator
Actualización desde otra versión: No
Conversión desde otro sistema de foros: No
AutoMOD: Si

Hola amigos, espero estén muy bien este día "o el dia que lo lean :D"
bueno pues como el titulo lo dice, como hacer que los últimos post del foro, aparezcan en una web externa :)

estuve investigando y casi todo me llevo a este tema:
https://blog.phpbb.com/2009/11/09/how-t ... nal-pages/

ahora en lo muy poco que entendi (O.O)
creo que el codigo iria asi:
el archivo se llama "home.php"

Código: Seleccionar todo

<?php
/*
* home.php 
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../Nightmare/';
$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('viewforum');

/* 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, 5);
    $forum_id_where = create_where_clauses($forum_id, 'forum');

    $topic_id = array(20, 50);
    $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) )
      {
         $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('The title of your page goes here');

$template->set_filenames(array(
'body' => 'home_body.html'
));

page_footer();
?>
Ahora esto me lanza el siguiente error:

Código: Seleccionar todo

Error General
template->_tpl_load_file(): File ../Nightmare/styles/pbwow2/template/home_body.html does not exist or is empty

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/functions_template.php
LINE: 63
CALL: trigger_error()

FILE: [ROOT]/includes/template.php
LINE: 437
CALL: template_compile->_tpl_load_file()

FILE: [ROOT]/includes/template.php
LINE: 224
CALL: template->_tpl_load()

FILE: [ROOT]/includes/functions.php
LINE: 4884
CALL: template->display()

FILE: C:/xampp/htdocs/test/home.php
LINE: 146
CALL: page_footer()
Ahora según entiendo el archivo "home_body.html" no existe, y efectivamente no existe
Aquí es donde entran mis dudas

1- El codigo esta bien? o necesita hacerle correcciones, pregunto esto porque veo que el articulo es bastante viejo, jeje

2- Por otro lado, alguna idea de como que tengo que escribir en el "home_body.html" :?:

Lo que requiero es que aparezcan los últimos temas de mi foro en la web externa, que se llamaría "index.html"

Muchísimas gracias por la atención, que tengan un excelente día y que dios los bendiga.

Re: Temas Recientes en Web Externa!

Publicado: 12 Abr 2014, 14:37
por angelismo
Tienes que crear el archivo home_body.htm, con este codigo

Código: Seleccionar todo

<!-- BEGIN announcements -->
Title: {announcements.TOPIC_TITLE}
Author: {announcements.TOPIC_AUTHOR}
Date: {announcements.TOPIC_DATE}
Last post: {announcements.TOPIC_LAST_POST}
Topic link: {announcements.TOPIC_LINK}
<!-- END announcements -->
Te dejo este otro tutorial sobre lo mismo
[kb=http://www.phpbb-es.com/biblioteca/kb_show.php?id=79]Últimos mensajes en el índice del foro y en páginas externas[/kb]

Re: Temas Recientes en Web Externa!

Publicado: 07 Jun 2014, 14:14
por drAkeTool
angelismo escribió:Tienes que crear el archivo home_body.htm, con este codigo

Código: Seleccionar todo

<!-- BEGIN announcements -->
Title: {announcements.TOPIC_TITLE}
Author: {announcements.TOPIC_AUTHOR}
Date: {announcements.TOPIC_DATE}
Last post: {announcements.TOPIC_LAST_POST}
Topic link: {announcements.TOPIC_LINK}
<!-- END announcements -->
Te dejo este otro tutorial sobre lo mismo
[kb=http://www.phpbb-es.com/biblioteca/kb_show.php?id=79]Últimos mensajes en el índice del foro y en páginas externas[/kb]
Wow Muchísimas gracias, seguí el tutorial que me pusiste y funciono sin problemas
ahora solo tengo una duda, use el ejemplo 2, donde se ponen los post de un foro especifico en una web externa

quisiera ponerle estilo al echo

Código: Seleccionar todo

echo "<b>!!</b> <a href=\"$topic_link\" ><h3>$topic_title</a> por $topic_author - <small>$topic_date<br>";
hasta ahi sin problemas, pero quisiera agregarle esto a los Links

Código: Seleccionar todo

class="newsitem"
y quedaria asi

Código: Seleccionar todo

echo "<b>!!</b> <a class="newsitem" href=\"$topic_link\" ><h3>$topic_title</a> por $topic_author - <small>$topic_date<br>";
pero me manda error jeje, sabes de alguna manera de arreglar eso?