Show forum threads as news articles on html website? How to?

Discussion forum for MOD Writers regarding MOD Development.

Re: Show forum threads as news articles on html website? How

Postby brine » Mon Jun 27, 2011 1:05 pm

is there an easy way to have it display first posts from specific topics (based on its title) in a given forum? I have a board where all the forums have four topics with specific names ("Game", "Sets", "Patches", "Extras"), and I would like the topics array function to use those specific topic names instead of an ID range.
brine
Registered User
 
Posts: 4
Joined: Sat Jun 25, 2011 7:07 pm

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Tue Jun 28, 2011 5:17 am

It is possible, but this code requires some intermediate level php modification. Before you start anything take a look at the code and see if you understand how it works. If you don't you're better off requesting a mod.
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby adipnayak » Tue Jul 12, 2011 3:34 pm

Hi there i am trying to put together a custom mainpage for my forum http://aquascape.co.in/forum/mainpage.php

I'vegot all the basic working correctly by following this tutorial http://blog.phpbb.com/2009/11/09/how-to-display-posts-and-topics-on-external-pages/ and am working on styling the page now. Wanted to know.

1. How do i show just a part of the post, just a few lines, instead of the whole post itself with a "more" link in the end?
2. {announcements.POST_DATE} Shows the entire date and time. Is there any way to customize date display according to our need? So i can style day/month/year seperately and not display time.
3. From the above tutorial i couldn't get "EXAMPLE 2: Display first post from the last five topics" by copying the code i get an SQL error.

Pls help :(
adipnayak
Registered User
 
Posts: 80
Joined: Sun May 22, 2011 4:59 pm

Re: Show forum threads as news articles on html website? How

Postby divergence » Sun Aug 07, 2011 4:20 am

I've tried finding the answer to this problem myself, but I haven't had much luck. Please redirect me to the answer if you know it. :c

Are unordered list bbcodes supposed to work with this hack? If not, how would I get them to work?

Thanks. ><
divergence
Registered User
 
Posts: 18
Joined: Sun Jul 10, 2011 7:18 pm

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Sun Aug 07, 2011 9:17 am

Please elaborate further. I'm confused about your problem.
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby divergence » Sun Aug 07, 2011 1:57 pm

CMCDragonkai wrote:Please elaborate further. I'm confused about your problem.

I'm trying to type a list on my forum (in bbcode) and display it on an external page. Every bbcode I've tested has worked with the exception of the list(s) (both ordered and unordered). They don't translate to HTML. I was wondering if there was an easy fix to this, or if it was intended to work this way. Any lists I type just display as regular text (without indentations or bullet points or numbers or anything).

For example:

  • This is a list.
  • It has two bullet points.
The above will display on my page as:

This is a list.
It has two bullet points.

----------------------

EDIT:
I actually just inspected my code, and the list tags do show up in the code... they just don't actually display on the site. I guess it has to do with my styling... >< Ugh. Sorry for wasting your time.
divergence
Registered User
 
Posts: 18
Joined: Sun Jul 10, 2011 7:18 pm

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Sun Aug 07, 2011 2:05 pm

Yep. That's exactly what I thought.
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby Neuropass » Sat Aug 27, 2011 5:57 pm

UseLess wrote:Greetings,

Been fiddling with this and altered it a little ... ;)

Some things, especially in the language file may already be defined by phpBB, so you may get strange behaviour depending on what other mods you have installed... perhaps the lang stuff should be prefixed?

Anyway it works which was the main thing, all (well most) of the code has just been commented out.

The files:
Filename: news.php
Code: Select all
<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';    // Replace with your own root path
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include_once($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

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

// Gets the name of this file
$this_file = get_this_filesname(__FILE__);

/*
   FROM HERE, 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.
*/
//
// User Config Options
//
$fora_ids = array(2);   // array of forum ids you want posts from
$parent_ids = false;   // array of parent forum ids, set to false if not used
$articles = 5;         // number of posts to return
$offset = 0;         // offset : Set this variable if you don't want the result set begin on the first entry
$children = false;      // This variable specifies whether we should include the "child forums" of the given $forum_ids in the results
$sort_order = sort_order_query('recent_desc');
$allow_attach = true;   // Show attachments, if any ?
$allow_ranks = true;   // Show ranks ?
$allow_sigs = true;      // Show signatures ?
$allow_avatar = true;   // Show avatars ?

//  Get the posts
$posts = get_news($fora_ids, $parent_ids, $articles, $offset, $children, $sort_order, $allow_attach, $allow_ranks, $allow_sigs, $allow_avatar);

// Assign Common vars
// Language vars are in: language/en/mods/news_articles.php
$template->assign_vars(array(
   'L_BREADCRUMBS'   => $user->lang['LN_BREADCRUMBS'],
   'L_NUM_REPLIES'   => $user->lang['LN_NUM_REPLIES'],
   'L_NUM_VIEWS'   => $user->lang['LN_NUM_VIEWS'],
   'L_POST_ATTACHMENT'   => $user->lang['LN_POST_ATTACHMENTS'],
   'L_ATTACHMENTS'   => $user->lang['LN_ATTACHMENTS'],
   'L_IS_ATTACHMENTS'   => $user->lang['LN_IS_ATTACHMENTS'],
   'L_NUM_ATTACHMENTS'   => $user->lang['LN_NUMBER_ATTACHMENTS'],
   'L_ATTACH_DOWNLOADS'   => $user->lang['LN_ATTACH_DOWNLOADS'],
   'L_ATTACH_COMMENTS'      => $user->lang['LN_ATTACH_COMMENTS'],
   'L_DOWNLOAD_EXPLAIN'   => $user->lang['LN_DOWNLOAD_EXPLAIN'],
   'L_POSTED_ON'   => $user->lang['LN_POSTED_ON'],
   'L_POSTED_BY'   => $user->lang['LN_POSTED_BY'],
   'L_RANK_TITLE'   => $user->lang['LN_RANK_TITLE'],
   'L_DISCUSS_TOPIC'   => $user->lang['LN_DISCUSS_TOPIC'],
   'L_INDEX'      => $user->lang['FORUM_INDEX'],
   
   'U_INDEX'      => append_sid($phpbb_root_path),
));

// Build the output
foreach($posts as $post)
{
   // First set all the data in vars
   $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'], false);
   $is_this_unread = (isset($topic_tracking_info[$post['topic_id']]) && $post['topic_last_post_time'] > $topic_tracking_info[$post['topic_id']]) ? true : false;
   // 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'];

   
   $poster_avatar = $user_rank_title = $user_rank_image = $user_signature = '';
   // 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'])
   {
     if($post['user_id'] != ANONYMOUS)
     {
//       unset($user_rank_title, $user_rank_image, $user_rank_image_relative_src);
       unset($user_rank_image_relative_src);
       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
   $template->assign_block_vars('postrow', array(
      'POST_ID'         => $post['post_id'],
      'POST_ICON'         => $post_icon,
      'POST_ICON_ALT'      => $icon_alt_text,
      'POST_SUBJECT'      => $post_subject,
      
      'S_UNREAD'         => ($is_this_unread ? true : false),

      'U_POST_LINK'      => $post_link,
      
      'REPLY_COUNT'      => $post_replies_count,
      'VIEW_COUNT'      => $post_views,
      'HAS_ATTACHMENTS'   => $is_there_attachments,
      'POST_TIME'         => $post_time,
      'POST_AUTHOR'      => $poster_name,
      'POSTER_AVATAR'      => $poster_avatar,
      'POSTER_PROFILE'   => $poster_link,
      'RANK_TITLE'      => $user_rank_title,
      'RANK_IMG'         => $user_rank_image,
      
      'MESSAGE'         => $post_text,
      
      'SIGNATURE'       => (!empty($user_signature) ? $user_signature : ''),
      'L_ATTACH_SHOWN'   => ($allow_attach ? $user->lang['LN_ATTACH_DISPLAY'] : $user->lang['LN_ATTACH_NOT_DISPLAY']),
      ));

   // Breadcrumbs
   if(isset($post['breadcrumb_ids']))
   {
     foreach($post['breadcrumb_ids'] as $name => $id)
     {
      $template->assign_block_vars('postrow.nav_links', array(
         'U_VIEW_FORUM'   => append_sid($phpbb_root_path . 'viewforum.' . $phpEx, array('f' => $id)),
         'FORUM_NAME'   =>   $name,
      ));
     }
   }
   if($is_there_attachments && $post['allow_attachments'])
   {
     foreach($post_attachment_filesize as &$filesize)
     {
       $filesize = get_formatted_filesize($filesize);
     }
     unset($filesize); // Breaking reference

     for($j=key($post_attachments);$j<$num_of_attachments;$j++)
     {
      $template->assign_block_vars('postrow.attachments', array(
         'NUM_ATTACHMENTS'   => $num_of_attachments,
         'URL_ATTACHMENT'   => $post_attachments[$j],
         'NAME_ATTACHMENT'   => $post_attachment_names[$j],
         'HAS_COMMENTS'   => (!empty($post_attachment_comments[$j]) ? true : false),
         'ATTACHMENT_COMMENT'   => (!empty($post_attachment_comments[$j]) ? $post_attachment_comments[$j] : ''),
         'DOWNLOAD_COUNT'   => ( ($post_attachment_downloads[$j] > 0) ? $post_attachment_downloads[$j] : 0),
         'FILESIZE'         => $post_attachment_filesize[$j],
      ));
     }
   }
}

$template->assign_block_vars('navlinks', array(
   'U_VIEW_FORUM'   => append_sid($phpbb_root_path . $this_file . '.' . $phpEx),
   'FORUM_NAME'   => $user->lang['LN_FORUM_NEWS'],
));

// Output page
page_header($user->lang['LN_FORUM_NEWS']);

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

page_footer();
exit;

/*
 * Start Functions block
 */
/*
 * Get the name of the file
 *
 * @param $info passed as __FILE__
 * @return (string) the name of the file minus the file ext
 */
function get_this_filesname($info)
{
   // Gets the name of this file
   $this_file = pathinfo($info);
   return substr($this_file['basename'], 0, strpos($this_file['basename'], '.'));
}

/*
* @param String $sort_order Has 12 options: (Default is recent_desc)
* Options:
    1. 'recent_asc' Gives oldest to newest topics
    2. 'recent_desc' Vice versa
    3. 'active_asc' Gives the early replied to recently replied
    4. 'active_desc' Vice versa
    5. 'subject_asc' Gives it in alphabetical order
    6. 'subject_desc' Vice versa
    7. 'author_asc' Gives authors in alphabetical order
    8. 'author_desc' Vice versa
    9. 'views_asc' Gives the least views to most views
   10. 'views_desc' Vice versa
   11. 'replies_asc' Gives the least replies to the most replies
   12. 'replies_desc' Vice versa
* @return String $sort_order_query The mysql coding to be used in the get_news function
*/
function sort_order_query($sort_order)
{
   // switches for sort_order
   switch ($sort_order)
   {
     case 'recent_asc':
       $sort_order_query = 't.topic_time ASC';
       break;
     case 'recent_desc':
       $sort_order_query = 't.topic_time DESC';
       break;
     case 'active_asc':
       $sort_order_query = 't.topic_last_post_id ASC';
       break;
     case 'active_desc':
       $sort_order_query = 't.topic_last_post_id DESC';
       break;
     case 'subject_asc':
       $sort_order_query = 't.topic_title ASC';
       break;
     case 'subject_desc':
       $sort_order_query = 't.topic_title DESC';
       break;
     case 'author_asc':
       $sort_order_query = 't.topic_first_poster_name ASC';
       break;
     case 'author_desc':
       $sort_order_query = 't.topic_first_poster_name DESC';
       break;
     case 'views_asc':
       $sort_order_query = 't.topic_views ASC';
       break;
     case 'views_desc':
       $sort_order_query = 't.topic_views DESC';
       break;
     case 'replies_asc':
       $sort_order_query = 't.topic_replies_real ASC';
       break;
     case 'replies_desc':
       $sort_order_query = 't.topic_replies_real DESC';
       break;
     default:
       $sort_order_query = 't.topic_time DESC';

   }
   return($sort_order_query);
}

/** VERSION 4.09
 * Retrieve the first post of each topic in a given forum
 *
 * @param Array $forum_ids  An array containing all the forum ids of the forums that must be included
 * @param Array $parent_only_ids An array containg the forum ids that will only give you the topics inside that forum, and not any children. It is used to mix up with $forum_ids. However if $include_children is false, this will do nothing. If you do not want to use it, declare false on it when calling the function
 * @param Integer $limit The maximum number of topics to be returned
 * @param Integer $offset Set this variable if you don't want the result set begin on the first entry
 * @param Boolean $include_children This variable specifies whether we should include the "child forums" of the given $forum_ids in the results
 * @param String $sort_order It is mysql coding of the query order. This is given by the sort_order_query function (Default is t.topic_time DESC)
 * @param Boolean $allow_attachments (Default is true) Displays attachments (NOT INLINE IT WILL SHOW ALL ATTACHMENTS BUT INLINE WILL NOT BE PROCESSED)
 * @param Boolean $allow_ranks (Default is true) Display ranks
 * @param Boolean $allow_sigs (Default is true) Display signatures
 * @param Boolean $allow_avatar (Default is true) Display avatars
 * @return Array $posts An array holding all the posts and their data
 *
 * NOTES: If you want forum posts + children (subforum) posts. Check include_children as true and check false for $parent_only_ids.
 * If you want forum posts + children (subforum) posts + forum posts not including children posts. Check include_children as true, and input values for $forum_ids and $parent_only_ids
 * If you only want forum posts, DO NOT check $forum_ids as false and use $parent_only_ids. You must check $include_children as false, and simply input values for $forum_ids, and check $parent_only_ids as false.
 * Remember that $parent_only_ids only work when $forum_ids are working regardless of $include_children. So $forum_ids is always the first one you have to use.
 * The function will not output topics which are not approved.
 */
function get_news($forum_ids = array(), $parent_only_ids = array(), $limit = 10, $offset = 0, $include_children = false, $sort_order = 't.topic_time DESC', $allow_attachments = true, $allow_ranks = true, $allow_sigs = true, $allow_avatar = true)
{
   global $db, $phpbb_root_path, $phpEx;

   if (!is_array($forum_ids))
   {
     $forum_ids = array($forum_ids);
   }
   if (!is_array($parent_only_ids))
   {
     $parent_only_ids = array($parent_only_ids);   
   }

   // If required merge the children into the $forum_ids
   if ($include_children)
   {
     // This can get very heavy when specifing a big array $forum_ids
     $child_forums = array();
     foreach ($forum_ids as $parent)
     {
       $children = get_forum_branch($parent, 'children');
       foreach ($children as $child)
       {
         $child_forums[] = $child['forum_id'];
       }
     }
     // Merge
     $forum_ids = array_merge($forum_ids, $child_forums, $parent_only_ids);
   }

   // Remove duplicates
   $forum_ids = array_unique($forum_ids);

   $post_query = 'p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_id, t.forum_id, t.topic_title, t.topic_status, t.poll_start, t.topic_views, t.topic_replies_real, t.topic_type, t.topic_first_poster_name, t.topic_first_post_id, t.topic_last_post_time, u.user_id, u.user_colour';
   if($allow_ranks)
   {
     $post_query .= ',u.user_rank, u.user_posts';
   }
   if($allow_sigs)
   {
     $post_query .= ',u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield';
   }
   if($allow_avatar)
   {
     $post_query .= ',u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height';
   }

   // Now select the post data
   $post_sql_ary = array(
     'SELECT'   => $post_query,
     'FROM'      => array(
       POSTS_TABLE      => 'p',
       TOPICS_TABLE   => 't',
     ),
     'LEFT_JOIN'    => array(
       array(
         'FROM'    => array(USERS_TABLE => 'u'),
         'ON'    => 'u.user_id = p.poster_id',
       ),
     ),
     'WHERE'        => '(' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND p.post_id = t.topic_first_post_id AND t.topic_approved = 1)',
     'ORDER_BY'    => 't.topic_type DESC,' . $sort_order, #DELETE t.topic_type DESC if you do not want to preserve announcements and stickies.
   );
   $sql   = $db->sql_build_query('SELECT', $post_sql_ary);
   $result   = $db->sql_query_limit($sql, $limit, $offset);

   // Set an array with the posts
   $posts   = array();
   while ($post = $db->sql_fetchrow($result))
   {
     // Getting the Attachments
     if($allow_attachments && $post['post_attachment'])
     {
//       unset($attachment_urls, $attachment_ids, $attachment_names,$attachment_downloads, $attachment_comments, $attachment_filesize, $num_of_attachment_ids);
       $attachments_sql_ary = array(
         'SELECT'   => 'a.attach_id, a.real_filename, a.download_count, a.attach_comment, a.filesize',
         'FROM'      => array(
            ATTACHMENTS_TABLE      => 'a',
         ),
         'WHERE'        => '(a.post_msg_id = ' . $post['post_id'] . ' AND a.in_message = 0)',
         'ORDER_BY'    => 'a.attach_id DESC',
       );
       $attachments_sql   = $db->sql_build_query('SELECT', $attachments_sql_ary);
       $attachments_result = $db->sql_query($attachments_sql);

       $attachment_urls = $attachment_ids = $attachment_names = array();
       $attachment_downloads = $attachment_comments = $attachment_filesize = array();
       while ($row = $db->sql_fetchrow($attachments_result))
       {
            $attachment_ids[] = $row['attach_id'];
            $attachment_names[] = $row['real_filename'];
            $attachment_downloads[] = $row['download_count'];
            $attachment_comments[] = $row['attach_comment'];
            $attachment_filesize[] = $row['filesize'];
       }
       $db->sql_freeresult($attachments_result);

       $num_of_attachment_ids = count($attachment_ids);
       for($i=key($attachment_ids);$i<$num_of_attachment_ids;$i++)
       {
         $attachment_urls[$i] = $phpbb_root_path . 'download/file.' . $phpEx . '?id=' . $attachment_ids[$i];
       }
     }

     // Getting the Breadcrumbs
     unset($breadcrumb_ids);
     if($post['forum_id'] > 0)
     {
       $breadcrumb_ids_sql_ary = array(
         'SELECT'   => 'f.forum_id, f.forum_name',
         'FROM'      => array(
            FORUMS_TABLE      => 'f',
         ),
         'WHERE'    => '(f.left_id <= (SELECT left_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $post['forum_id'] . ') AND f.right_id >= (SELECT right_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $post['forum_id'] . '))',
       );
       $bread_crumb_ids_sql   = $db->sql_build_query('SELECT', $breadcrumb_ids_sql_ary);
       $bread_crumb_ids_result = $db->sql_query($bread_crumb_ids_sql);
       while ($row = $db->sql_fetchrow($bread_crumb_ids_result))
       {
            $breadcrumb_ids[$row['forum_name']] = $row['forum_id'];
       }
       $db->sql_freeresult($bread_crumb_ids_result);
     }

     $posts[] = array(
       // FOR POSTS
       'forum_id'            => $post['forum_id'],
       'post_id'            => $post['post_id'],
       'post_time'            => $post['post_time'],
       'post_text'            => $post['post_text'],
       // PARSING
       'bbcode_bitfield'      => $post['bbcode_bitfield'],
       'bbcode_uid'         => $post['bbcode_uid'],
       'enable_bbcode'         => $post['enable_bbcode'],
       'enable_smilies'      => $post['enable_smilies'],
       'enable_magic_url'      => $post['enable_magic_url'],
       // TOPIC DETAILS
       'topic_id'            => $post['topic_id'],
       'topic_title'         => $post['topic_title'],
       'topic_views'         => $post['topic_views'],
       'topic_replies_real'   => $post['topic_replies_real'],
       'topic_type'            => $post['topic_type'],
       'topic_first_post_id'    => $post['topic_first_post_id'],
       'topic_last_post_time'    => $post['topic_last_post_time'],
       'topic_status'    => $post['topic_status'],
       // POLL
       'poll_start'         => $post['poll_start'],
       // ATTACHMENTS
       'allow_attachments'      => $allow_attachments,
       'is_there_attachments'   => $post['post_attachment'],
       'attachments'          => (isset($attachment_urls) ? $attachment_urls : array() ),
       'attachment_names'       => (isset($attachment_names) ? $attachment_names : array() ),
       'attachment_downloads'    => (isset($attachment_downloads) ? $attachment_downloads : array() ),
       'attachment_comments'    => (isset($attachment_comments) ? $attachment_comments : array() ),
       'attachment_filesize'    => (isset($attachment_filesize) ? $attachment_filesize : array() ),
       'num_of_attachments'    => (isset($num_of_attachment_ids) ? $num_of_attachment_ids : 0 ),
       // BREADCRUMBS
       'breadcrumb_ids'       => $breadcrumb_ids,

       // FOR USER
       'user_id'            => $post['user_id'],
       'topic_first_poster_name'   => $post['topic_first_poster_name'],
       'user_colour'         => $post['user_colour'],
       // AVATAR
       'allow_avatar'          => $allow_avatar,
       'user_avatar'         => ( ($allow_avatar == true) ? $post['user_avatar'] : ''),
       'user_avatar_type'      => ( ($allow_avatar == true) ? $post['user_avatar_type'] : ''),
       'user_avatar_width'      => ( ($allow_avatar == true) ? $post['user_avatar_width'] : 0),
       'user_avatar_height'   => ( ($allow_avatar == true) ? $post['user_avatar_height'] : 0),
       // RANKS
       'allow_ranks'          => $allow_ranks,
       'user_rank_id'          => ( ($allow_ranks == true) ? $post['user_rank'] : -1),
       'user_posts'          => ( ($allow_ranks == true) ? $post['user_posts'] : 0),
       // SIGNATURES
       'allow_sigs'         => $allow_sigs,
       'user_sig'             => ( ($allow_sigs == true) ? $post['user_sig'] : ''),
       'user_sig_bbcode_uid'    => ( ($allow_sigs == true) ? $post['user_sig_bbcode_uid'] : ''),
       'user_sig_bbcode_bitfield'    => ( ($allow_sigs == true) ? $post['user_sig_bbcode_bitfield'] : ''),
     );
   }
   $db->sql_freeresult($result);

   // Return it
   return $posts;
}

?>

Filename: language/en/mods/news_articles.php
Code: Select all
<?php
/**
*
* news_articles [English]
*
* @package language
* @version $Id: news_articles.php 2009-07-15 22:10 $
* @copyright (c) 2009 UseLess
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
**/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

if (empty($lang) || !is_array($lang))
{
   $lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

// Movies
$lang = array_merge($lang, array(
   'LN_FORUM_NEWS'         => 'Latest News',
   'LN_BREADCRUMBS'      => 'Breadcrumbs',
   'LN_NUM_REPLIES'      => 'Number of Replies',
   'LN_NUM_VIEWS'         => 'Number of views from forum',
   'LN_POSTED_ON'         => 'Posted on',
   'LN_POSTED_BY'         => 'Posted by',
   'LN_RANK_TITLE'         => 'Rank Title',

   'LN_ATTACHMENTS'      => 'Attachments',
   'LN_POST_ATTACHMENTS'   => 'Post Attachments',
   'LN_IS_ATTACHMENTS'      => 'Is there attachments?',
   'LN_ATTACH_DISPLAY'      => 'Displayed',
   'LN_ATTACH_NOT_DISPLAY'   => 'Not Displayed',

   'LN_NUMBER_ATTACHMENTS'   => 'Number of Attachments',
   'LN_ATTACH_DOWNLOADS'   => 'Number of Downloads',
   'LN_ATTACH_COMMENTS'   => 'Comments',
   'LN_DOWNLOAD_EXPLAIN'   => 'Does not count downloads from "here"',
   
   'LN_DISCUSS_TOPIC'      => 'Discuss Topic',
));

?>

Filename: styles/prosilver/template/news_body.html
Code: Select all
<!-- INCLUDE overall_header.html -->

<!-- BEGIN postrow -->
   <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_IGNORE_POST --> online<!-- ENDIF -->">
      <div class="inner"><span class="corners-top"><span></span></span>

      <div class="postbody">

         <table cellspacing="0" cellpadding="0">
         <tr>
            <td align="center"><img src="{postrow.POST_ICON}" alt="{postrow.POST_ICON_ALT}" title="{postrow.POST_ICON_ALT" /></td>
            <td align="left" valign="middle" style="padding-left: 5px;"><h3><a <!-- IF postrow.S_UNREAD -->class="unread"<!-- ENDIF --> href="{postrow.U_POST_LINK}" title="{postrow.POST_SUBJECT}">{postrow.POST_SUBJECT}</a></h3></td>
            <td align="left" valign="middle" style="padding-left: 5px;">&bull; {L_POSTED_ON}: {postrow.POST_TIME} &bull; {L_POSTED_BY}: <a href="{postrow.POSTER_PROFILE}">{postrow.POST_AUTHOR}</a></td>
         </tr>
         </table>
         <div class="post_info">
            <em>{L_BREADCRUMBS}:</em> <a href="{U_INDEX}" accesskey="h">{L_INDEX}</a> <!-- BEGIN nav_links --> <strong>&#8249;</strong> <a href="{postrow.nav_links.U_VIEW_FORUM}">{postrow.nav_links.FORUM_NAME}</a><!-- END nav_links --><br />
         </div>

         <div class="content">{postrow.MESSAGE}</div>

         <!-- BEGIN attachments -->
         <br />
         <div class="attachbox">
         <em>{L_ATTACHMENTS}:</em><br />{L_NUM_ATTACHMENTS}: {attachments.NUM_ATTACHMENTS}
         <br /><a href="{attachments.URL_ATTACHMENT}">{attachments.NAME_ATTACHMENT}</a>
         <!-- IF attachments.HAS_COMMENTS --><br />{L_ATTACH_COMMENTS}: {attachments.ATTACHMENT_COMMENT}<!-- ENDIF -->
         <br />{L_ATTACH_DOWNLOADS}: {attachments.DOWNLOAD_COUNT} &bull; {L_FILESIZE}: {attachments.FILESIZE}
         </div>
         <!-- END attachments -->

         <!-- IF postrow.SIGNATURE --><div id="sig{postrow.POST_ID}" class="signature">{postrow.SIGNATURE}</div><!-- ENDIF -->
      </div>

      <dl class="postprofile" id="profile{postrow.POST_ID}">
         <dt>
            <!-- IF postrow.POSTER_AVATAR -->
               <!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />
            <!-- ENDIF -->
            <!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->
         </dt>

         <!-- IF postrow.RANK_TITLE or postrow.RANK_IMG --><dd>{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF -->{postrow.RANK_IMG}</dd><!-- ENDIF -->

         <dd>&nbsp;</dd>

         <dd><strong>{L_NUM_REPLIES}:</strong> {postrow.REPLY_COUNT}</dd>
         <dd><strong>{L_NUM_VIEWS}:</strong> {postrow.VIEW_COUNT}</dd>
         <dd><strong>{L_ATTACHMENTS}:</strong> {postrow.L_ATTACH_SHOWN}</dd>
         <dd><strong>{L_POST_ATTACHMENT}:</strong> <!-- IF postrow.HAS_ATTACHMENTS -->{L_YES}<!-- ELSE -->{L_NO}<!-- ENDIF --></dd>
      </dl>

      <div class="back2top"><a href="{postrow.U_POST_LINK}">{L_DISCUSS_TOPIC}</a> &nbsp; <a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a></div>

      <span class="corners-bottom"><span></span></span></div>
   </div>

<hr class="divider" />
<!-- END postrow -->

<!-- INCLUDE overall_footer.html -->

Changes 1
Made some other changes.
- removed all commented code
- removed the 'bytesize' function as an alternative already exists in phpBB
- placed functions at bottom of file
- added function to get name of file, incase it's not 'news.php' as it's used in the navlinks bit
- altered the template so the info is now on the right, default prosilver
- fixed lots of errors when DEBUG mode is on




@CMCDragonkai how can you include a trim characters function here?
User avatar
Neuropass
Registered User
 
Posts: 1067
Joined: Fri Apr 17, 2009 2:02 pm
Location: SciTE4AutoIt3

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Sun Aug 28, 2011 9:19 am

I'm not quite sure what you are asking for?

What are you intending to do?
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby Neuropass » Sun Aug 28, 2011 3:18 pm

I would like to shorten the characters of the posted news.
User avatar
Neuropass
Registered User
 
Posts: 1067
Joined: Fri Apr 17, 2009 2:02 pm
Location: SciTE4AutoIt3

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Sun Aug 28, 2011 5:31 pm

Then just use the PHP trim function on the final output.
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby Neuropass » Sun Aug 28, 2011 11:21 pm

sorry I'm, not even a beginner in php. could you point me in the right direction?
User avatar
Neuropass
Registered User
 
Posts: 1067
Joined: Fri Apr 17, 2009 2:02 pm
Location: SciTE4AutoIt3

Re: Show forum threads as news articles on html website? How

Postby CMCDragonkai » Mon Aug 29, 2011 5:25 am

If you're not comfortable with PHP, this is not the right mod for you. Search for ones that can be easily installed in the modification database.
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.
CMCDragonkai
Registered User
 
Posts: 483
Joined: Sat Jun 09, 2007 11:37 pm
Location: Australia.. and other parts of the world sometimes...

Re: Show forum threads as news articles on html website? How

Postby FoxReinhold » Tue Aug 30, 2011 4:02 am

Dragonkai,

I've been using this on my website for two years now in order to help my students (I'm a teacher). I was just doing the most recent update (recycling forums for the new year, etc.) and wanted to thank you for your work. If there is a paypal address I can use to throw a few bucks your way, PM it to me or e-mail me by clicking my name if you can (promise, not a spam bot :) )

I'm very much looking forward to you getting inline attachments to work, as that would be the icing on the cake. I'm working with another teacher this year, and I use this script for content management as well. While I'm rather computer literate and can figure out the id code of the attachment and then just use:

Code: Select all
[url=http://www.blahedyblah.com/forum/download/file.php?id=104]File Link Text Here[/url]


or

Code: Select all
[img]http://www.blahedyblah.com/forum/download/file.php?id=104[/img]


to get my attachments to show up on the front page and on subpages, she... is not :)

Anyway, thanks for all your hard work!
FoxReinhold
Registered User
 
Posts: 4
Joined: Tue Nov 11, 2008 7:43 pm
Name: Joshua Williams

Re: Show forum threads as news articles on html website? How

Postby TheGiftedApe » Mon Nov 07, 2011 7:13 pm

Hello I read thorugh many page of this thread trying to find the answer but I did not hopefully someone can help me.

I read this an am trying to use example#3
http://wiki.phpbb.com/Displaying_posts_ ... ied_topics

I tried to read through as many of the posts on the subject as I could but I did not find a solution, hopefully you can help.

Now I'm trying to display the most recent posts from a certain "news" section on the frontpage of my site like blog posts. I can get it to work fine if I use your "example 4" and the script download you provided i just copy paste and it fires right up. However I am trying to only display posts from the "news" section and not just general blabber. When I try to add in the code from example#3 I get an error.

The problem seems to lie here:
Code: Select all
'WHERE'     =>  str_replace( array('WHERE ', 'topic_id'), array('', 't.topic_id'), $topic_id_where) . '
                        AND t.topic_status <> ' . ITEM_MOVED . '
                         AND t.topic_approved = 1',

Which seems to be the only thing that differentiates example#3 from #4. My Question is, How do I define the place where It pulls the posts from!?? Say I have 3 forums on my site, General discussion area, Hidden for members only section, and the "News Posts" section, how do I tell it to only pull posts from "News Posts"????

as a secondary question, Which part of the code would I place in my <div> so it actually displays it on my newspage, which parts go where? header,body,etc. Can I just use a php include code to pull home.php into my main index.php site so it will display whatever is on home.php in the news section of my main page?


Or if someone could explain to me how to make this version: viewtopic.php?f=71&t=587812&p=12911336#p12911336
Pull from only one forum section and not all of them that would work just fine as well! thx - ape.
Last edited by TheGiftedApe on Mon Nov 07, 2011 7:39 pm, edited 1 time in total.
TheGiftedApe
Registered User
 
Posts: 9
Joined: Mon Nov 07, 2011 4:35 am

PreviousNext

Return to [3.0.x] MOD Writers Discussion

Who is online

Users browsing this forum: AjaxBB, Brf, omgili [Bot] and 11 guests