External Page Recent Topics Problem

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
yemliha24
Registered User
Posts: 6
Joined: Sat Apr 21, 2018 11:34 am

External Page Recent Topics Problem

Post by yemliha24 » Sat Apr 21, 2018 11:41 am

Hi...

i have a forum phpBB version is 3.2.2

my home page /index.php
my forum page /forum/

i want show index.php recent post.

how make to this ?

Can you help me please ?

i try this page https://wiki.phpbb.com/Practical.Displa ... rnal_pages

but this error show me
Screenshot_3.png

User avatar
posey
Registered User
Posts: 706
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: External Page Recent Topics Problem

Post by posey » Sun Apr 22, 2018 8:05 pm

https://wiki.phpbb.com/Practical.Displa ... base_calls
Note: If you are using phpBB 3.1.x references to topic_approved in the following examples must be changed to topic_visibility.
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

yemliha24
Registered User
Posts: 6
Joined: Sat Apr 21, 2018 11:34 am

Re: External Page Recent Topics Problem

Post by yemliha24 » Mon Apr 23, 2018 9:16 am

Thank you so much. my english so bad i no understand he what say me :)

Now i want usage css but how see external_body.html desing ?

external_body.html if i go you see this picture ?
Screenshot_4.png
if i go php page you see this
Screenshot_5.png
i want usage css html how.

Again thank you so much

User avatar
posey
Registered User
Posts: 706
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: External Page Recent Topics Problem

Post by posey » Mon Apr 23, 2018 9:24 am

Do you have the page_header() and page_footer() functions in your php file?

Code: Select all

    page_header('External page');

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

    page_footer();
@see: https://wiki.phpbb.com/Practical.Displa ... conclusion
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

yemliha24
Registered User
Posts: 6
Joined: Sat Apr 21, 2018 11:34 am

Re: External Page Recent Topics Problem

Post by yemliha24 » Mon Apr 23, 2018 9:31 am

This is my code php file.

php page name sonukonu.php

php page url /sonukonu.php

forum url /forum

external page url : C:\xampp\htdocs\dontfree\brahmaclubturkey.com\forum\styles\prosilver\template/external_body.html

i try this http://localhost/dontfree/brahmaclubtur ... _body.html

but only text show me


Code: Select all


<?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 : './forum/';
$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;
            
        }

        $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 = 10;

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

$topic_id = array(20, 50);
$topic_id_where = create_where_clauses($topic_id, 'topic');

// -------------------------------------------------------------------------------


$posts_ary = array(
    'SELECT'    => 'p.*, t.*, u.username, u.user_colour',
    
    'FROM'      => array(
        POSTS_TABLE     => 'p',
    ),
    
    'LEFT_JOIN' => array(
        array(
            'FROM'  => array(USERS_TABLE => 'u'),
            'ON'    => 'u.user_id = p.poster_id'
        ),
        array(
            'FROM'  => array(TOPICS_TABLE => 't'),
            'ON'    => 'p.topic_id = t.topic_id'
        ),
    ),
    
    'WHERE'     => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
    AND t.topic_status <> ' . ITEM_MOVED . '
    AND t.topic_visibility = 1',
    
    'ORDER_BY'  => 'p.post_id DESC',
);

$posts = $db->sql_build_query('SELECT', $posts_ary);

$posts_result = $db->sql_query_limit($posts, $search_limit);

while( $posts_row = $db->sql_fetchrow($posts_result) )
{
   $topic_title       = $posts_row['topic_title'];
   $post_author       = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
   $post_date          = $user->format_date($posts_row['post_time']);
   $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&amp;t=' . $posts_row['topic_id'] . '&amp;p=' . $posts_row['post_id']) . '#p' . $posts_row['post_id'];

   $post_text = nl2br($posts_row['post_text']);

   $bbcode = new bbcode(base64_encode($bbcode_bitfield));         
   $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

   $post_text = smiley_text($post_text);

   $template->assign_block_vars('announcements', array(
       'TOPIC_TITLE'       => censor_text($topic_title),
       'POST_AUTHOR'       => $post_author,
       'POST_DATE'       => $post_date,
       'POST_LINK'       => $post_link,
       'POST_TEXT'         => censor_text($post_text),
   ));
}
// -------------------------------------------------------------------------




    page_header('External page');

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

    page_footer();


yemliha24
Registered User
Posts: 6
Joined: Sat Apr 21, 2018 11:34 am

Re: External Page Recent Topics Problem

Post by yemliha24 » Mon Apr 23, 2018 12:12 pm

ohh thank you so much bro.

i fix problem.


CODE THİS

Code: Select all

$posts_ary = array(
    'SELECT'    => 'p.*, t.*, u.username, u.user_colour',
    
    'FROM'      => array(
        POSTS_TABLE     => 'p',
    ),
    
    'LEFT_JOIN' => array(
        array(
            'FROM'  => array(USERS_TABLE => 'u'),
            'ON'    => 'u.user_id = p.poster_id'
        ),
        array(
            'FROM'  => array(TOPICS_TABLE => 't'),
            'ON'    => 'p.topic_id = t.topic_id'
        ),
    ),
    
    'WHERE'     => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
    AND t.topic_status <> ' . ITEM_MOVED . '
    AND t.topic_visibility = 1',
    
    'ORDER_BY'  => 'p.post_id DESC',
);
$d=1;

$posts = $db->sql_build_query('SELECT', $posts_ary);

$posts_result = $db->sql_query_limit($posts, $search_limit);

while( $posts_row = $db->sql_fetchrow($posts_result) ):

   $topic_title       = $posts_row['topic_title'];
   $post_author       = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
   $post_date          = $user->format_date($posts_row['post_time']);
   $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&amp;t=' . $posts_row['topic_id'] . '&amp;p=' . $posts_row['post_id']) . '#p' . $posts_row['post_id'];

   $post_text = nl2br($posts_row['post_text']);

   $bbcode = new bbcode(base64_encode($bbcode_bitfield));         
   $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

   $post_text = smiley_text($post_text);


echo "<tr>";
echo "<th scope='row'>";
echo $d++;
echo "</th>";
echo "<td  class='text-left' >";
echo "<a href='". $post_link ."'>";
echo $topic_title;
echo "</a>";
echo "</td>";
echo "<td  class='text-center'>";
echo $post_author;
echo "</td>";
echo "<td  class='text-right'>";
echo $post_date;
echo "</td>";
echo "</tr>";

endwhile;
output
Screenshot_6.png

tofino
Registered User
Posts: 34
Joined: Fri Nov 06, 2015 1:55 pm

Re: External Page Recent Topics Problem

Post by tofino » Mon Jun 04, 2018 12:54 am

Does not seem to recognize forum ID's it just seems to get latest posts.

THX tho

tofino
Registered User
Posts: 34
Joined: Fri Nov 06, 2015 1:55 pm

Re: External Page Recent Topics Problem

Post by tofino » Mon Jun 04, 2018 7:28 pm

This is the code I managed to fix up that works in my prosilver phpbb 3.2
I had to use phpbb pages ext for the iframe
https://www.phpbb.com/customise/db/extension/pages/

Code: Select all

<?php
/*
* sample.php 
* Description: example file for displaying latest posts and topics in selected forum id's
* by clight77 
*/

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

        $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 = 70;                  // ------------------------------------------------------------------- your search amount
$forum_id = array(289, 288);         // ------------------------------------------------------------------- your id's go here
$forum_id_where = create_where_clauses($forum_id, 'forum');
$topic_id = array(20, 50);
$topic_id_where = create_where_clauses($topic_id, 'topic');

$posts_ary = array(
    'SELECT'    => 'p.*, t.*, u.username, u.user_colour',
    
    'FROM'      => array(
        POSTS_TABLE     => 'p',
    ),
    
    'LEFT_JOIN' => array(
        array(
            'FROM'  => array(USERS_TABLE => 'u'),
            'ON'    => 'u.user_id = p.poster_id'
        ),
        array(
            'FROM'  => array(TOPICS_TABLE => 't'),
            'ON'    => 'p.topic_id = t.topic_id'
        ),
    ),
    
    'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where ) .
		'AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_visibility = 1',
	'ORDER_BY'	=> 'p.post_id DESC',
);
 $d=1;   
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);

while( $posts_row = $db->sql_fetchrow($posts_result) ):

   $topic_title       = $posts_row['topic_title'];
   $post_author       = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
   $post_date          = $user->format_date($posts_row['post_time']);
   $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&amp;t=' . $posts_row['topic_id'] . '&amp;p=' . $posts_row['post_id']) . '#p' . $posts_row['post_id'];

echo $d++;
echo "<a href='". $post_link ."'> - ";
echo $topic_title;
echo "</a>&nbsp; &bull; &nbsp;";
echo $post_author;
echo " - ";
echo $post_date;
echo "<br><hr>";
endwhile;

page_footer();
	
?>
Last edited by tofino on Wed Jun 06, 2018 3:41 pm, edited 3 times in total.

User avatar
GanstaZ
Registered User
Posts: 569
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: External Page Recent Topics Problem

Post by GanstaZ » Mon Jun 04, 2018 8:46 pm

Using echo and template system at the same time doesn't make any sense and code in the while loop can be updated by modifying/removing some lines of code.
"When answer lies in the question,.. question becomes redundant!"

tofino
Registered User
Posts: 34
Joined: Fri Nov 06, 2015 1:55 pm

Re: External Page Recent Topics Problem

Post by tofino » Tue Jun 05, 2018 1:34 am

GanstaZ wrote:
Mon Jun 04, 2018 8:46 pm
Using echo and template system at the same time doesn't make any sense and code in the while loop can be updated by modifying/removing some lines of code.
recent.html only contains...

{% INCLUDE 'overall_header.html' %}

Nothing else.

I just posted this for people that have trouble doing this.
Don't like it post your fix.

I have removed some un-needed code in my 1st post and edited it.

User avatar
GanstaZ
Registered User
Posts: 569
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: External Page Recent Topics Problem

Post by GanstaZ » Tue Jun 05, 2018 1:43 am

Don't get me wrong, I was only pointing to:

Code: Select all

// Echo
echo $d++;
echo "<a href='". $post_link ."'> - ";
echo $topic_title;
echo "</a>&nbsp; &bull; &nbsp;";
echo $post_author;
echo " - ";
echo $post_date;
echo "<div style=\"height:8px;\"><hr>";


endwhile;

// Template system
    $template->set_filenames(array(
        'body' => 'recent.html',
  ));
there's no need to use both.
"When answer lies in the question,.. question becomes redundant!"

tofino
Registered User
Posts: 34
Joined: Fri Nov 06, 2015 1:55 pm

Re: External Page Recent Topics Problem

Post by tofino » Tue Jun 05, 2018 3:46 pm

GanstaZ wrote:
Tue Jun 05, 2018 1:43 am
Don't get me wrong, I was only pointing to:

Code: Select all

// Echo
echo $d++;
echo "<a href='". $post_link ."'> - ";
echo $topic_title;
echo "</a>&nbsp; &bull; &nbsp;";
echo $post_author;
echo " - ";
echo $post_date;
echo "<div style=\"height:8px;\"><hr>";


endwhile;

// Template system
    $template->set_filenames(array(
        'body' => 'recent.html',
  ));
there's no need to use both.
NP I am not a coder, I just posted it to help others. :)

But I have a modified prosilver dark, so without the html I can't read some of the text, but with factory pro silver you are right you don't need this part:

Code: Select all

// Template system
    $template->set_filenames(array(
        'body' => 'recent.html',
  ));

User avatar
Lumpy Burgertushie
Registered User
Posts: 65207
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: External Page Recent Topics Problem

Post by Lumpy Burgertushie » Tue Jun 05, 2018 4:03 pm

the point is that you don't need to put php in any html template file. or html in any php file no matter what style you are using. the whole point of the phpbb template system is that the php and html are totally separate.


robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 2 guests