Display posts on external page updating issue

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky
Contact:

Display posts on external page updating issue

Post by Rotten Apple »

I’m hoping I posted this in the right section, but I’m using this code on this website and when I went to post an update by starting a new topic on the board where it retrieves posts from, it would no longer update on the front page of my website.

The board has 44 topics and 60 posts and 3 pages. (It's my updates and announcements board.) When it reached the 44th topic it would no longer retrieve newly posted topics. There was absolutely no problem when I had it below 44 topics (it updated the 43rd topic just fine) but this issue began once it reached 44 topics. The code is set to retrieve the latest 5 topics posted in board 57 and it's no longer doing this. Is there a way to rectify this issue? I only want it to display 5 topics on the index page of my website, so that's no the issue - it's just a problem retrieving the posts.

The code I use:

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './board/';    # REPLACE WITH YOUR OWN ROOT PATH Example: './phpbb/'
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    require_once($phpbb_root_path . 'common.' . $phpEx);
    require_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    require_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
    require_once('functions.' . $phpEx);

    #Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    $limit = 5; #SPECIFY THE AMOUNT OF ARTICLES YOU WANT TO APPEAR ON THE PAGE.
    $offset = ceil(abs(request_var('start', 1))); #rounds up the start number to the nearest integer. The 'start' is the number which will be offset when paginated.

    # Get the posts
    $posts = get_news(array(57), false, $limit, $offset, true, sort_order_query('sticky_recent_desc')); #Change array(1) to array(number of your forum). It must be an array. OR change the false to array (number of your forum), however you need $include_children to be true.

    #Define the variable output. Also put a header in just to make it useful. Note that if you remove this, this will generate a notice for an undefined variable, which can be removed by changing your error reporting level (Its not an error, it's a notice).
    $output = '<h1>Updates</h1>';
    # Build the output. You can now change whatever you want in order to suit your needs. For example, you can build the datas to however you like. OR you can change the output variables. That is where the html gets outputted. If you know php variables and html, you can modify that to your own usage.
    foreach($posts as $post){
       
       #First set all the data in vars
       $total_forum_items    = get_total_items($post['total_forum_ids']);
       $bbcode_options   = (($post['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) + (($post['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) + (($post['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
       
       #Actual Post
       $post_text      = generate_text_for_display($post['post_text'], $post['bbcode_uid'], $post['bbcode_bitfield'], $bbcode_options);
       $post_text      = bbcode_nl2br($post_text);
       $post_text      = smiley_text($post_text);
       $post_link      = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, array('f' => $post['forum_id'], 't' => $post['topic_id'])) . '#p' . $post['post_id'];
       $post_subject   = censor_text($post['topic_title']);
       $post_time      = $user->format_date($post['post_time']);
       $post_replies_count      = $post['topic_replies_real'];
       $post_views    = $post['topic_views'];
          #Post Tracking (Is it unread or not?)
       $topic_tracking_info = get_complete_topic_tracking($post['forum_id'], $post['topic_id'], true);
       $is_this_unread = (isset($topic_tracking_info[$post['topic_id']]) && $post['topic_last_post_time'] > $topic_tracking_info[$post['topic_id']]) ? 'class="unread"' : 'class="read"';
          #Post Icons
       $post_icon = $icon_alt_text = $topic_type = '';
       topic_status($post, $post['topic_replies_real'], $is_this_unread, $post_icon, $icon_alt_text, $topic_type);
       $post_icon = $user->img($post_icon, $icon_alt_text, false, '', 'src');
       $icon_alt_text = $user->lang[$icon_alt_text];
          #Attachments
       $is_there_attachments    = $post['is_there_attachments'];
       $post_attachments    = $post['attachments'];
       $post_attachment_names    = $post['attachment_names'];
       $post_attachment_downloads    = $post['attachment_downloads'];
       $post_attachment_comments    = $post['attachment_comments'];
       $post_attachment_filesize    = $post['attachment_filesize'];
       $num_of_attachments    = $post['num_of_attachments'];
          #Breadcrumbs
       $breadcrumb_urls = '<a href="' . append_sid($phpbb_root_path) . '">Board Index</a>';
       if($post['breadcrumb_ids']){
       
          foreach($post['breadcrumb_ids'] as $name => $id){
          
             $url = append_sid($phpbb_root_path . 'viewforum.' . $phpEx, array('f' => $id));
             $breadcrumb_urls .= '<strong>‹</strong><a href="' . $url . '">' . $name . '</a>';
             
          }
       
       }
       
       #User Information
       if($post['allow_avatar']){
       
          $poster_avatar   = get_user_avatar($post['user_avatar'], $post['user_avatar_type'], $post['user_avatar_width'], $post['user_avatar_height']);
       
       }
       $poster_link   = append_sid($phpbb_root_path . 'memberlist.' . $phpEx, array('mode' => 'viewprofile', 'u' => $post['user_id']));
       $poster_name   = get_username_string('full', $post['user_id'], $post['topic_first_poster_name'], $post['user_colour']);
          #Ranks
       if($post['allow_ranks']){
       
          unset($user_rank_title, $user_rank_image, $user_rank_image_relative_src);
          if($post['user_id'] != ANONYMOUS){
          
             get_user_rank($post['user_rank_id'], $post['user_posts'], $user_rank_title, $user_rank_image, $user_rank_image_relative_src);
          
          }
          
       }
          #Signatures
       if($post['allow_sigs']){
       
          $user_signature  = generate_text_for_display($post['user_sig'], $post['user_sig_bbcode_uid'], $post['user_sig_bbcode_bitfield'], $bbcode_options);
          $user_signature  = bbcode_nl2br($user_signature);
          $user_signature  = smiley_text($user_signature);
          
       }
       
       #THE BUILDING BLOCKS ARE DONE!
       #ITS TIME TO START PUTTING THE BLOCKS TOGETHER INTO COHERENT HTML
       $output .= '';
       $output .= '<div class="updates"><a ';
       $output .= $is_this_unread;
       $output .= ' href="' . $post_link . '" title="' . $post_subject . '">' . $post_subject .'</a></div><div class="datetime">Posted on ' . $post_time .'</div><br />';

       $output .= '<div class="text">' . $post_text . '</div> <br />';

       if($is_there_attachments && $post['disallow_attachments']){
          
          $output .= '<div class="attachment_info">';
          
          $filesize = bytesize($post_attachment_filesize);
          
          $output .= '<em>Attachments:</em><br />Number of Attachments: ' . $num_of_attachments;
          
          for($j=key($post_attachments);$j<$num_of_attachments;$j++){
             
             $output .= '<br /><a href="' . $post_attachments[$j] . '">' . $post_attachment_names[$j] . '</a>' . (!empty($post_attachment_comments[$j]) ? '<br />Attachment Comments: ' . $post_attachment_comments[$j] : false) . '<br />Number of Downloads: ' . $post_attachment_downloads[$j] . ' (Does not count downloads from "here")<br />Filesize: ' . $filesize[$j];
             
          }
          
          $output   .= '</div>';
          
       }
              $output .= '<table style="font-size: 12px; width: 810px;"><tr><td><b>POSTED BY: ' . $poster_name . '</b></td><td><a ';

       $output .= 'href="' . $post_link . '" style="float: right; text-transform: uppercase;">';
       $output .= '<b>Comments</b>: ' . $post_replies_count . "</a></td></tr></table>\n";

       $output .= '<br><br>';
       
    }

    #doing pagination,
    if(isset($total_forum_items)){
    $pagination = generate_pagination('index.php', $total_forum_items, $limit, $offset, true);
    }else{
    echo '<h4>OOPS! you have offset more topics than there is. This page will display no topics, try lowering the number offsetted in your url which begins as ?start=**</h4>';
    }
    ?>
<? include('top.php'); ?>
Content is here.

<!-- Start posts -->
    <?php
    #pagination.
    print ($output);
    ?>
    
    
<? include('bottom.php'); ?>
Assistance with this would greatly be appreciated! I'm using version 3.0.8 and a custom Subsilver based theme. The website is not using phpBB external pages either. It's simply the index page of the website that's retrieving topics from a board.
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky
Contact:

Re: Display posts on external page updating issue

Post by Rotten Apple »

I'm still looking for assistance with this. I did a test run last night and the 44th post will display only after I post a new topic (45th) but the new topic (45th) won't display unless I repeat the process of creating a new topic. So the problem's still there, and I'm not sure what's causing it. :\
User avatar
Rotten Apple
Registered User
Posts: 211
Joined: Wed Oct 06, 2010 2:27 am
Location: Florida, USA
Name: Vicky
Contact:

Re: Display posts on external page updating issue

Post by Rotten Apple »

Still looking for assistance!
CMCDragonkai
Registered User
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Display posts on external page updating issue

Post by CMCDragonkai »

This looks like my code. Can you post in my thread so I can properly keep track of support.
http://www.phpbb.com/community/viewtopi ... 1&t=587812
Show phpbb threads as html articles. V.5.03 Thanks Erik! (This will be updated constantly as I or others contribute...) This code is to be used on external HTML page, but if you want a template version see here.

For the best PHPBB total modification to posting - bbcode, embedding... everything! Visit MSSTI's ABBC3 Modification.
Locked

Return to “[3.0.x] MOD Writers Discussion”

cron