While loop problem
Re: While loop problem
Okay, I *think* it was to have the system grab global announcements instead of normal topics, but I'm not sure I had it working.
-
- New member
- Posts: 23
- Joined: 06 Sep 2008, 14:59
Re: While loop problem
If you find out more and refine the code or mod or update it, please post here. Would be awesome to have a fully functional Announcement grabber.
Re: While loop problem
A little note. I killed the script and rebuild from scratch, here's what I came up with.
There's some template code somewhere around on my site...that, I'll get back to you on later. o_o;;
Code: Select all
<?php
/**
*
*===================================================================
*
* Functions File (get_fora_topics)
*-------------------------------------------------------------------
* Script info:
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @function get_fora_topics
*
* @description Grabs recent topics from entered forums and prepares to display their first posts in
* their entire form, with avatars, BBcode, smilies, and ranks.
*
*
* @param array (integer safe) $fora_ids (Fora to grab topics from. If just an integer, will be converted to an array.)
* @param integer $max_results (Maximum amount of results to return a run. )
* @param bool $show_links (Do we show the links to post comments or view them?)
*
* @return mixed Will return false if no posts found, or it will return one array with subarrays containing the post data results if it does.
* Contents of each array will only need to be run through a simple $template->assign_block_vars() call afterwards.
*
* @usage-example get_fora_topics(array(3), 5, true);
*/
function get_fora_topics($fora_ids, $max_results = 3, $show_links = true)
{
//! Globalize scope of vars.
global $user_cache, $db, $template, $phpbb_root_path, $phpEx, $config, $auth, $cache, $user;
#! Prerequisite for get_fora_topics()...include if it's not already included.
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
#! $user_cache globaled to allow re-use of function multiple times, and reduce strain by not having to reload cache.
//! Pre-run setup.
$bbcode_bitfield = '';
$fora_ids = (!is_array($fora_ids)) ? array($fora_ids) : $fora_ids;
/*
* Select all the required data, and even some unrequired data too, for the hell of it. >:D
* SQL query originally (c) 2008 Erik Frèrejean ( http://www.erikfrerejean.nl ).
* (Is borrowed but modified to suit our purposes. :))
*/
$sql_ary = array(
'SELECT' => 'p.post_id, p.poster_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.post_username,
t.topic_id, t.forum_id, t.topic_status, t.topic_title, t.topic_replies, t.topic_replies_real,
u.user_id, u.username, u.user_colour, u.user_sig, u.user_options, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield,
u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_rank, u.user_posts',
'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', $fora_ids) . ' AND p.post_id = t.topic_first_post_id)',
'ORDER_BY' => 't.topic_time DESC',
);
$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $max_results);
$i = 0; #! @ignore
#! Loop through the results and dump data.
while ($row = $db->sql_fetchrow($result))
{
if ($row == false)
{
return false; #! FAIL. No posts.
}
$return[$i] = array();
//! Define the global bbcode bitfield, will be used to load bbcodes
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
# Is a signature attached? Are we going to display it? React accordingly.
if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
{
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
}
//! Quickly dump the poster_id into another var for readability, and make a var for whether or not the poster was a guest.
$poster_id = $row['poster_id'];
$is_anon = ($poster_id == ANONYMOUS);
#! Emulating the viewtopic user cache system, to be nicer to PHP. :P
if(!isset($user_cache[$poster_id]))
{
$user_sig = '';
//! Signature parsing, only if needed.
if(!$is_anon && $row['user_sig'] && $row['enable_sig'] && $config['allow_sig'])
{
$user_sig = $row['user_sig'];
}
$user_cache[$poster_id] = array(
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
'sig' => $user_sig,
'sig_bbcode_uid' => (!$is_anon && !empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
'sig_bbcode_bitfield' => (!$is_anon && !empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
'username' => $row['username'],
'user_colour' => $row['user_colour'],
'rank_title' => '',
'rank_image' => '',
'rank_image_src' => '',
'profile' => ($is_anon) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id") : '',
);
//! Get poster rank if we've not gotten it for this user already, also.
get_user_rank($row['user_rank'], ((!$is_anon) ? $row['user_posts'] : false), $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
}
//! Prep to dump some vars intended for the template block system.
$post_data = array(
'COMMENT_COUNT' => $row['topic_replies'],
'S_IS_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'POST_SUBJECT' => censor_text($row['topic_title']),
'MESSAGE' => $row['post_text'],
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
'NEWS_ID' => $i,
'POST_ID' => $row['post_id'],
);
//! Put vars in our list for stuff we need for parsing sigs and posts.
$parse[$i] = array(
'enable_sig' => $row['enable_sig'],
'bbcode_bitfield' => $row['bbcode_bitfield'],
'bbcode_uid' => $row['bbcode_uid'],
'poster_id' => $poster_id,
'post_text' => $row['post_text'],
);
//! Pull existing like-minded permissions and merge to the $post_data array.
if($show_links == true)
{
$post_data = array_merge($post_data, array(
'U_READ_COMMENTS' => ($auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p={$row['post_id']}#p{$row['post_id']}") : false,
'U_POST_COMMENTS' => ($auth->acl_get('f_reply', $row['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f={$row['forum_id']}&t={$row['topic_id']}") : false,
));
}
$return[$i] = array_merge($return[$i], $post_data); #| Prepare for return, Cap'n! *munch*
$i++; #! @ignore
}
//! Parse the posts!
foreach($parse as $inc => $sub)
{
//! Instantiate BBCode if need be..
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
# End signature parsing, only if needed..
$poster_id = $sub['poster_id'];
if ($user_cache[$poster_id]['sig'] && $sub['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
{
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
}
$user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig_parsed'] = true;
}
//! Parse the message!
$message = censor_text($sub['post_text']);
if ($parse[$inc]['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $sub['bbcode_uid'], $sub['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
//! Quickly stuff the message into the mailbox before anyone notices. o_o;;
$return[$inc] = array_merge($return[$inc], array(
'MESSAGE' => smiley_text($message),
'SIGNATURE' => ($parse[$inc]['enable_sig'] && $user_cache[$poster_id]['sig']) ? $user_cache[$poster_id]['sig'] : '',
));
}
$db->sql_freeresult($result);
#! Finally, we're done. Let's return home.. ">.>
return $return;
} //end fn: get_fora_topics()
?>
There's some template code somewhere around on my site...that, I'll get back to you on later. o_o;;
-
- New member
- Posts: 23
- Joined: 06 Sep 2008, 14:59
Re: While loop problem
Hey, while you've been doing this, I've found two other people doing similar things..
I joined in the development of one them too.
[url=http://www.phpbb.com/community/viewtopic.php?f=71&t=587812&start=570#p8392375]Here's the one Eric made and I modified later on.[/url] (I noticed you use his query.. but we also got some new stuff.)
[url=http://www.phpbb.com/community/viewtopic.php?f=69&t=1402395&p=8459105#p8354535]And here's an actual mod I found by someone.[/url]
I wonder, if you are doing anything different? Perhaps we could optimize each others code or add functionality...
I joined in the development of one them too.
[url=http://www.phpbb.com/community/viewtopic.php?f=71&t=587812&start=570#p8392375]Here's the one Eric made and I modified later on.[/url] (I noticed you use his query.. but we also got some new stuff.)
[url=http://www.phpbb.com/community/viewtopic.php?f=69&t=1402395&p=8459105#p8354535]And here's an actual mod I found by someone.[/url]
I wonder, if you are doing anything different? Perhaps we could optimize each others code or add functionality...
Re: While loop problem
What I did was essentially make it return the results in an array for continuous reuse of the function without unsetting anything, really. It also properly parses signatures/posts from BBcode, and uses the user-cache method that phpBB uses in viewtopic to decrease memory use.
A nice touch is that I add links to the posting page and viewtopic for each news announcement if the user has permission to use the respective parts of phpBB.
I found the code for the complete setup of my News page, also.
Main file (news.php)
Functions file (includes/functions_getfora.php)
Language file (language/en/mods/lang_news_page.php)
Template file #1 (styles/prosilver/template/news_body.html)
Template file #2 (styles/prosilver/template/info_postbody.html)
Just remember to keep copyright information intact as per the GNU GPL v2.
That, and, this differs slightly from my [url=http://fail.infinityhouse.org/code.php]Repository[/url]'s copy, I found a typo or two copy-pasting it over. It's in the repository under /dev_projects/news_page/ for the curious, or if you want to download the files in there for correct tabbing.
A nice touch is that I add links to the posting page and viewtopic for each news announcement if the user has permission to use the respective parts of phpBB.
I found the code for the complete setup of my News page, also.
Main file (news.php)
Code: Select all
<?php ## Does it make you radiate? Does it break your heart in two?
/**
*
*===================================================================
*
* phpBB News Page -- Main File
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* Version info -
* @ignore
*/
$version = 'v1.0.0 B1';
$version_big = 'phpBB News Page Version 1.0.0, Beta 1';
/**
* @ignore
*/
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);
/**
* Start session management
*/
$user->session_begin();
//! Pull auths, and setup.
$auth->acl($user->data);
//! Load lang files.
$user->setup(array('mods/lang_news_page', 'viewtopic'));
include($phpbb_root_path . 'includes/functions_getfora.' . $phpEx);
$template->assign_var('S_NO_NAVBAR', true); //dev.Board thing, ignore
//! Assign credit. Quite important for the ego.
$template->assign_var('NEWS_PAGE_VERSION', 'phpBB News Page <strong title="' . $version_big . '">' . $version . '</strong> © 2008, 2009 <strong>Obsidian</strong>');
//! What foras are we looking at? Use fora IDs ONLY.
#! @note: Hardcoded for security...
$search_foras = array(); #| Add own fora IDs later.
if(($results = get_fora_topics($search_foras, 3, true)) == false)
{
#! Deactivated and replaced with a template var trigger.
//trigger_error('NO_NEWS_FOUND_FORA');
$template->assign_var('S_NO_NEWS', true);
}
//! We've got the results, now let's play with them...
foreach($results as $key => $data)
{
#| Expecting comment counts. So, let's format them.
$data['COMMENT_COUNT'] = sprintf($user->lang['VIEW_COMMENTS'], $data['COMMENT_COUNT']);
$template->assign_block_vars('newsrow', $data);
}
//! Shall we have an info post displayed as well? If fora ID is non-zero, we'll go ahead and grab it.
$info_post = 0;
if($info_post != 0)
{
if(($info = get_fora_topics($info_post, 1, false)) != false)
{
//! No comment count sprintf necessary...just assign_block_var.
#! Since we're only grabbing one row, we only /have/ one subarray...so we don't need to foreach, just specify it.
$template->assign_block_vars('inforow', $info[0]);
$template->assign_var('S_INCLUDE_INFO_POST', true);
}
}
page_header($user->lang['NEWS_PAGE']);
$template->set_filenames(array(
'body' => 'news_body.html'
));
page_footer();
?>
Functions file (includes/functions_getfora.php)
Code: Select all
<?php
/**
*
*===================================================================
*
* phpBB News Page -- Functions File (get_fora_topics)
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @function get_fora_topics
*
* @description Grabs recent topics from entered forums and prepares to display their first posts in
* their entire form, with avatars, BBcode, smilies, and ranks.
*
*
* @param array (integer safe) $fora_ids (Fora to grab topics from. If just an integer, will be converted to an array.)
* @param integer $max_results (Maximum amount of results to return a run. )
* @param bool $show_links (Do we show the links to post comments or view them?)
*
* @return mixed Will return false if no posts found, or it will return one array with subarrays containing the post data results if it does.
* Contents of each array will only need to be run through a simple $template->assign_block_vars() call afterwards.
*
* @usage-example get_fora_topics(array(3), 5, true);
*/
function get_fora_topics($fora_ids, $max_results = 3, $show_links = true)
{
//! Globalize scope of vars.
global $user_cache, $db, $template, $phpbb_root_path, $phpEx, $config, $auth, $cache, $user;
#! Prerequisite for get_fora_topics()...include if it's not already included.
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
#! $user_cache globaled to allow re-use of function multiple times, and reduce strain by not having to reload cache.
//! Pre-run setup.
$bbcode_bitfield = '';
$fora_ids = (!is_array($fora_ids)) ? array($fora_ids) : $fora_ids;
/*
* Select all the required data, and even some unrequired data too, for the hell of it. >:D
* SQL query originally (c) 2008 Erik Frèrejean ( http://www.erikfrerejean.nl ).
* (Is borrowed but modified to suit our purposes. :))
*/
$sql_ary = array(
'SELECT' => 'p.post_id, p.poster_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.post_username,
t.topic_id, t.forum_id, t.topic_status, t.topic_title, t.topic_replies, t.topic_replies_real,
u.user_id, u.username, u.user_colour, u.user_sig, u.user_options, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield,
u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_rank, u.user_posts',
'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', $fora_ids) . ' AND p.post_id = t.topic_first_post_id)',
'ORDER_BY' => 't.topic_time DESC',
);
$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $max_results);
$i = 0; #! @ignore
#! Loop through the results and dump data.
while ($row = $db->sql_fetchrow($result))
{
if ($row == false)
{
return false; #! FAIL. No posts.
}
$return[$i] = array();
//! Define the global bbcode bitfield, will be used to load bbcodes
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
# Is a signature attached? Are we going to display it? React accordingly.
if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
{
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
}
//! Quickly dump the poster_id into another var for readability, and make a var for whether or not the poster was a guest.
$poster_id = $row['poster_id'];
$is_anon = ($poster_id == ANONYMOUS);
#! Emulating the viewtopic user cache system, to be nicer to PHP. :P
if(!isset($user_cache[$poster_id]))
{
$user_sig = '';
//! Signature parsing, only if needed.
if(!$is_anon && $row['user_sig'] && $row['enable_sig'] && $config['enable_sig'])
{
$user_sig = $row['user_sig'];
}
$user_cache[$poster_id] = array(
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
'sig' => $user_sig,
'sig_bbcode_uid' => (!$is_anon && !empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
'sig_bbcode_bitfield' => (!$is_anon && !empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
'username' => $row['username'],
'user_colour' => $row['user_colour'],
'rank_title' => '',
'rank_image' => '',
'rank_image_src' => '',
'profile' => ($is_anon) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id") : '',
);
//! Get poster rank if we've not gotten it for this user already, also.
get_user_rank($row['user_rank'], ((!$is_anon) ? $row['user_posts'] : false), $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
}
//! Prep to dump some vars intended for the template block system.
$post_data = array(
'COMMENT_COUNT' => $row['topic_replies'],
'S_IS_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'POST_SUBJECT' => censor_text($row['topic_title']),
'MESSAGE' => $row['post_text'],
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
'NEWS_ID' => $i,
'POST_ID' => $row['post_id'],
);
//! Put vars in our list for stuff we need for parsing sigs and posts.
$parse[$i] = array(
'enable_sig' => $row['enable_sig'],
'bbcode_bitfield' => $row['bbcode_bitfield'],
'bbcode_uid' => $row['bbcode_uid'],
'poster_id' => $poster_id,
'post_text' => $row['post_text'],
);
//! Pull existing like-minded permissions and merge to the $post_data array.
if($show_links == true)
{
$post_data = array_merge($post_data, array(
'U_READ_COMMENTS' => ($auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p={$row['post_id']}#p{$row['post_id']}") : false,
'U_POST_COMMENTS' => ($auth->acl_get('f_reply', $row['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f={$row['forum_id']}&t={$row['topic_id']}") : false,
));
}
$return[$i] = array_merge($return[$i], $post_data); #| Prepare for return, Cap'n! *munch*
$i++; #! @ignore
}
//! Parse the posts!
foreach($parse as $inc => $sub)
{
//! Instantiate BBCode if need be..
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
# End signature parsing, only if needed..
$poster_id = $sub['poster_id'];
if ($user_cache[$poster_id]['sig'] && $sub['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
{
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
}
$user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig_parsed'] = true;
}
//! Parse the message!
$message = censor_text($sub['post_text']);
if ($parse[$inc]['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $sub['bbcode_uid'], $sub['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
//! Quickly stuff the message into the mailbox before anyone notices. o_o;;
$return[$inc] = array_merge($return[$inc], array(
'MESSAGE' => smiley_text($message),
'SIGNATURE' => ($parse[$inc]['enable_sig'] && $user_cache[$poster_id]['sig']) ? $user_cache[$poster_id]['sig'] : '',
));
}
$db->sql_freeresult($result);
#! Finally, we're done. Let's return home.. ">.>
return $return;
} //end fn: get_fora_topics()
?>
Language file (language/en/mods/lang_news_page.php)
Code: Select all
<?php
/**
*
*===================================================================
*
* phpBB News Page -- Language File
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* 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
$lang = array_merge($lang, array(
'VIEW_COMMENTS' => 'View comments (%s)',
'RECENT_FORA_NEWS' => 'Board News & Announcements',
'NO_NEWS_POSTS' => 'No news posts were found in the forums specified.',
'LOCKED_TO_COMMENTS' => 'Comment-locked',
'POST_COMMENT' => 'Post comment',
'WELCOME_SITE' => 'Welcome',
'NEWS_PAGE' => 'Site Home',
));
?>
Template file #1 (styles/prosilver/template/news_body.html)
Code: Select all
<!-- INCLUDE overall_header.html -->
<!-- IF S_INCLUDE_INFO_POST -->
<!-- INCLUDE info_postbody.html -->
<div class="clear"></div>
<!-- ENDIF -->
<h2>{L_RECENT_FORA_NEWS}</h2>
<!-- IF S_NO_NEWS -->
<div class="panel"><div class="inner"><span class="corners-top"><span></span></span>
{L_NO_NEWS_POSTS}
<span class="corners-bottom"><span></span></span></div></div>
<!-- ELSE -->
<!-- BEGIN newsrow -->
<div id="n{newsrow.NEWS_ID}" class="post <!-- IF newsrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="postbody">
<h3 <!-- IF newsrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><a href="#p{newsrow.POST_ID}">{newsrow.POST_SUBJECT}</a></h3>
<div class="content">{newsrow.MESSAGE}</div>
<!-- IF newsrow.SIGNATURE --><div id="sig{newsrow.NEWS_ID}" class="signature">{newsrow.SIGNATURE}</div><!-- ENDIF -->
</div>
<dl class="postprofile" id="profile{newsrow.POST_ID}">
<dt>
<!-- IF newsrow.POSTER_AVATAR -->
<!-- IF newsrow.U_POST_AUTHOR --><a href="{newsrow.U_POST_AUTHOR}">{newsrow.POSTER_AVATAR}</a><!-- ELSE -->{newsrow.POSTER_AVATAR}<!-- ENDIF --><br />
<!-- ENDIF -->
<!-- IF not newsrow.U_POST_AUTHOR --><strong>{newsrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{newsrow.POST_AUTHOR_FULL}<!-- ENDIF -->
</dt>
<!-- IF newsrow.RANK_TITLE or newsrow.RANK_IMG --><dd>{newsrow.RANK_TITLE}<!-- IF newsrow.RANK_TITLE and newsrow.RANK_IMG --><br /><!-- ENDIF -->{newsrow.RANK_IMG}</dd><!-- ENDIF -->
<dd> </dd>
</dl>
<div class="back2top">
<a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a>
<!-- IF newsrow.U_READ_COMMENTS --><a href="{newsrow.U_READ_COMMENTS}">{newsrow.COMMENT_COUNT}</a> • <!-- ENDIF -->
<!-- IF newsrow.U_POST_COMMENTS --><!-- IF newsrow.S_IS_LOCKED -->{L_LOCKED_TO_COMMENTS}<!-- ELSE --><a href="{newsrow.U_POST_COMMENTS}">{L_POST_COMMENT}</a><!-- ENDIF --> • <!-- ENDIF -->
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<hr class="divider" />
<!-- END newsrow -->
<!-- ENDIF -->
<div style="text-align: center; margin: 0 auto;">{NEWS_PAGE_VERSION}</div>
<!-- INCLUDE overall_footer.html -->
Template file #2 (styles/prosilver/template/info_postbody.html)
Code: Select all
<!-- BEGIN inforow -->
<h2>{inforow.POST_SUBJECT}</h2>
<div id="i" class="post <!-- IF inforow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="postbody">
<div class="content">{inforow.MESSAGE}</div>
<!-- IF inforow.SIGNATURE --><div id="sig-i{inforow.NEWS_ID}" class="signature">{inforow.SIGNATURE}</div><!-- ENDIF -->
</div>
<dl class="postprofile" id="profile{inforow.POST_ID}">
<dt>
<!-- IF inforow.POSTER_AVATAR -->
<!-- IF inforow.U_POST_AUTHOR --><a href="{inforow.U_POST_AUTHOR}">{inforow.POSTER_AVATAR}</a><!-- ELSE -->{inforow.POSTER_AVATAR}<!-- ENDIF --><br />
<!-- ENDIF -->
<!-- IF not inforow.U_POST_AUTHOR --><strong>{inforow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{inforow.POST_AUTHOR_FULL}<!-- ENDIF -->
</dt>
<!-- IF inforow.RANK_TITLE or inforow.RANK_IMG --><dd>{inforow.RANK_TITLE}<!-- IF inforow.RANK_TITLE and inforow.RANK_IMG --><br /><!-- ENDIF -->{inforow.RANK_IMG}</dd><!-- ENDIF -->
<dd> </dd>
</dl>
<div class="back2top">
<a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a>
<!-- IF inforow.U_READ_COMMENTS --> • <a href="{inforow.U_READ_COMMENTS}">{inforow.COMMENT_COUNT}</a><!-- ENDIF -->
<!-- IF inforow.U_POST_COMMENTS --> • <!-- IF inforow.S_IS_LOCKED -->{LOCKED_TO_COMMENTS}<!-- ELSE --><a href="{inforow.U_POST_COMMENTS}">{POST_COMMENT}</a><!-- ENDIF --><!-- ENDIF -->
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<hr class="divider" />
<!-- END inforow -->
Just remember to keep copyright information intact as per the GNU GPL v2.
That, and, this differs slightly from my [url=http://fail.infinityhouse.org/code.php]Repository[/url]'s copy, I found a typo or two copy-pasting it over. It's in the repository under /dev_projects/news_page/ for the curious, or if you want to download the files in there for correct tabbing.
-
- New member
- Posts: 23
- Joined: 06 Sep 2008, 14:59
Re: While loop problem
Have you been able to get polls and inline attachments working? Because right now that's what I'm working on, and I can't get it working.
Re: While loop problem
Actually, I just totally ignored the polls and attachments. I found them to be a bit unnecessary.
-
- New member
- Posts: 23
- Joined: 06 Sep 2008, 14:59
Re: While loop problem
Haha, sadly I need them.
I have been able to get normal attachments, my brain is telling me this wierd and wackyway to do inline attachments.. but I think its not very scalable at all.
If you ever manage to do it, don't hesitate to post it on this thread.
I have been able to get normal attachments, my brain is telling me this wierd and wackyway to do inline attachments.. but I think its not very scalable at all.
If you ever manage to do it, don't hesitate to post it on this thread.
Re: While loop problem
sTraTo wrote:What I did was essentially make it return the results in an array for continuous reuse of the function without unsetting anything, really. It also properly parses signatures/posts from BBcode, and uses the user-cache method that phpBB uses in viewtopic to decrease memory use.
A nice touch is that I add links to the posting page and viewtopic for each news announcement if the user has permission to use the respective parts of phpBB.
I found the code for the complete setup of my News page, also.
Main file (news.php)Code: Select all
<?php ## Does it make you radiate? Does it break your heart in two?
/**
*
*===================================================================
*
* phpBB News Page -- Main File
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* Version info -
* @ignore
*/
$version = 'v1.0.0 B1';
$version_big = 'phpBB News Page Version 1.0.0, Beta 1';
/**
* @ignore
*/
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);
/**
* Start session management
*/
$user->session_begin();
//! Pull auths, and setup.
$auth->acl($user->data);
//! Load lang files.
$user->setup(array('mods/lang_news_page', 'viewtopic'));
include($phpbb_root_path . 'includes/functions_getfora.' . $phpEx);
$template->assign_var('S_NO_NAVBAR', true); //dev.Board thing, ignore
//! Assign credit. Quite important for the ego.
$template->assign_var('NEWS_PAGE_VERSION', 'phpBB News Page <strong title="' . $version_big . '">' . $version . '</strong> © 2008, 2009 <strong>Obsidian</strong>');
//! What foras are we looking at? Use fora IDs ONLY.
#! @note: Hardcoded for security...
$search_foras = array(); #| Add own fora IDs later.
if(($results = get_fora_topics($search_foras, 3, true)) == false)
{
#! Deactivated and replaced with a template var trigger.
//trigger_error('NO_NEWS_FOUND_FORA');
$template->assign_var('S_NO_NEWS', true);
}
//! We've got the results, now let's play with them...
foreach($results as $key => $data)
{
#| Expecting comment counts. So, let's format them.
$data['COMMENT_COUNT'] = sprintf($user->lang['VIEW_COMMENTS'], $data['COMMENT_COUNT']);
$template->assign_block_vars('newsrow', $data);
}
//! Shall we have an info post displayed as well? If fora ID is non-zero, we'll go ahead and grab it.
$info_post = 0;
if($info_post != 0)
{
if(($info = get_fora_topics($info_post, 1, false)) != false)
{
//! No comment count sprintf necessary...just assign_block_var.
#! Since we're only grabbing one row, we only /have/ one subarray...so we don't need to foreach, just specify it.
$template->assign_block_vars('inforow', $info[0]);
$template->assign_var('S_INCLUDE_INFO_POST', true);
}
}
page_header($user->lang['NEWS_PAGE']);
$template->set_filenames(array(
'body' => 'news_body.html'
));
page_footer();
?>
Functions file (includes/functions_getfora.php)Code: Select all
<?php
/**
*
*===================================================================
*
* phpBB News Page -- Functions File (get_fora_topics)
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @function get_fora_topics
*
* @description Grabs recent topics from entered forums and prepares to display their first posts in
* their entire form, with avatars, BBcode, smilies, and ranks.
*
*
* @param array (integer safe) $fora_ids (Fora to grab topics from. If just an integer, will be converted to an array.)
* @param integer $max_results (Maximum amount of results to return a run. )
* @param bool $show_links (Do we show the links to post comments or view them?)
*
* @return mixed Will return false if no posts found, or it will return one array with subarrays containing the post data results if it does.
* Contents of each array will only need to be run through a simple $template->assign_block_vars() call afterwards.
*
* @usage-example get_fora_topics(array(3), 5, true);
*/
function get_fora_topics($fora_ids, $max_results = 3, $show_links = true)
{
//! Globalize scope of vars.
global $user_cache, $db, $template, $phpbb_root_path, $phpEx, $config, $auth, $cache, $user;
#! Prerequisite for get_fora_topics()...include if it's not already included.
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
#! $user_cache globaled to allow re-use of function multiple times, and reduce strain by not having to reload cache.
//! Pre-run setup.
$bbcode_bitfield = '';
$fora_ids = (!is_array($fora_ids)) ? array($fora_ids) : $fora_ids;
/*
* Select all the required data, and even some unrequired data too, for the hell of it. >:D
* SQL query originally (c) 2008 Erik Frèrejean ( http://www.erikfrerejean.nl ).
* (Is borrowed but modified to suit our purposes. :))
*/
$sql_ary = array(
'SELECT' => 'p.post_id, p.poster_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.post_username,
t.topic_id, t.forum_id, t.topic_status, t.topic_title, t.topic_replies, t.topic_replies_real,
u.user_id, u.username, u.user_colour, u.user_sig, u.user_options, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield,
u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_rank, u.user_posts',
'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', $fora_ids) . ' AND p.post_id = t.topic_first_post_id)',
'ORDER_BY' => 't.topic_time DESC',
);
$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $max_results);
$i = 0; #! @ignore
#! Loop through the results and dump data.
while ($row = $db->sql_fetchrow($result))
{
if ($row == false)
{
return false; #! FAIL. No posts.
}
$return[$i] = array();
//! Define the global bbcode bitfield, will be used to load bbcodes
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
# Is a signature attached? Are we going to display it? React accordingly.
if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
{
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
}
//! Quickly dump the poster_id into another var for readability, and make a var for whether or not the poster was a guest.
$poster_id = $row['poster_id'];
$is_anon = ($poster_id == ANONYMOUS);
#! Emulating the viewtopic user cache system, to be nicer to PHP. :P
if(!isset($user_cache[$poster_id]))
{
$user_sig = '';
//! Signature parsing, only if needed.
if(!$is_anon && $row['user_sig'] && $row['enable_sig'] && $config['enable_sig'])
{
$user_sig = $row['user_sig'];
}
$user_cache[$poster_id] = array(
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
'sig' => $user_sig,
'sig_bbcode_uid' => (!$is_anon && !empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
'sig_bbcode_bitfield' => (!$is_anon && !empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
'username' => $row['username'],
'user_colour' => $row['user_colour'],
'rank_title' => '',
'rank_image' => '',
'rank_image_src' => '',
'profile' => ($is_anon) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id") : '',
);
//! Get poster rank if we've not gotten it for this user already, also.
get_user_rank($row['user_rank'], ((!$is_anon) ? $row['user_posts'] : false), $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
}
//! Prep to dump some vars intended for the template block system.
$post_data = array(
'COMMENT_COUNT' => $row['topic_replies'],
'S_IS_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
'POST_SUBJECT' => censor_text($row['topic_title']),
'MESSAGE' => $row['post_text'],
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
'NEWS_ID' => $i,
'POST_ID' => $row['post_id'],
);
//! Put vars in our list for stuff we need for parsing sigs and posts.
$parse[$i] = array(
'enable_sig' => $row['enable_sig'],
'bbcode_bitfield' => $row['bbcode_bitfield'],
'bbcode_uid' => $row['bbcode_uid'],
'poster_id' => $poster_id,
'post_text' => $row['post_text'],
);
//! Pull existing like-minded permissions and merge to the $post_data array.
if($show_links == true)
{
$post_data = array_merge($post_data, array(
'U_READ_COMMENTS' => ($auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p={$row['post_id']}#p{$row['post_id']}") : false,
'U_POST_COMMENTS' => ($auth->acl_get('f_reply', $row['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f={$row['forum_id']}&t={$row['topic_id']}") : false,
));
}
$return[$i] = array_merge($return[$i], $post_data); #| Prepare for return, Cap'n! *munch*
$i++; #! @ignore
}
//! Parse the posts!
foreach($parse as $inc => $sub)
{
//! Instantiate BBCode if need be..
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
# End signature parsing, only if needed..
$poster_id = $sub['poster_id'];
if ($user_cache[$poster_id]['sig'] && $sub['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
{
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
}
$user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig_parsed'] = true;
}
//! Parse the message!
$message = censor_text($sub['post_text']);
if ($parse[$inc]['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $sub['bbcode_uid'], $sub['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
//! Quickly stuff the message into the mailbox before anyone notices. o_o;;
$return[$inc] = array_merge($return[$inc], array(
'MESSAGE' => smiley_text($message),
'SIGNATURE' => ($parse[$inc]['enable_sig'] && $user_cache[$poster_id]['sig']) ? $user_cache[$poster_id]['sig'] : '',
));
}
$db->sql_freeresult($result);
#! Finally, we're done. Let's return home.. ">.>
return $return;
} //end fn: get_fora_topics()
?>
Language file (language/en/mods/lang_news_page.php)Code: Select all
<?php
/**
*
*===================================================================
*
* phpBB News Page -- Language File
*-------------------------------------------------------------------
* Script info:
* Version: ( 1.0.0 - Beta 1 )
* Copyright: ( (c) 2008, 2009 - Obsidian )
* License: ( http://opensource.org/licenses/gpl-license.php | GNU Public License v2 )
* Package: ( phpBB3 )
*
*===================================================================
*
*/
/**
* 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
$lang = array_merge($lang, array(
'VIEW_COMMENTS' => 'View comments (%s)',
'RECENT_FORA_NEWS' => 'Board News & Announcements',
'NO_NEWS_POSTS' => 'No news posts were found in the forums specified.',
'LOCKED_TO_COMMENTS' => 'Comment-locked',
'POST_COMMENT' => 'Post comment',
'WELCOME_SITE' => 'Welcome',
'NEWS_PAGE' => 'Site Home',
));
?>
Template file #1 (styles/prosilver/template/news_body.html)Code: Select all
<!-- INCLUDE overall_header.html -->
<!-- IF S_INCLUDE_INFO_POST -->
<!-- INCLUDE info_postbody.html -->
<div class="clear"></div>
<!-- ENDIF -->
<h2>{L_RECENT_FORA_NEWS}</h2>
<!-- IF S_NO_NEWS -->
<div class="panel"><div class="inner"><span class="corners-top"><span></span></span>
{L_NO_NEWS_POSTS}
<span class="corners-bottom"><span></span></span></div></div>
<!-- ELSE -->
<!-- BEGIN newsrow -->
<div id="n{newsrow.NEWS_ID}" class="post <!-- IF newsrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="postbody">
<h3 <!-- IF newsrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><a href="#p{newsrow.POST_ID}">{newsrow.POST_SUBJECT}</a></h3>
<div class="content">{newsrow.MESSAGE}</div>
<!-- IF newsrow.SIGNATURE --><div id="sig{newsrow.NEWS_ID}" class="signature">{newsrow.SIGNATURE}</div><!-- ENDIF -->
</div>
<dl class="postprofile" id="profile{newsrow.POST_ID}">
<dt>
<!-- IF newsrow.POSTER_AVATAR -->
<!-- IF newsrow.U_POST_AUTHOR --><a href="{newsrow.U_POST_AUTHOR}">{newsrow.POSTER_AVATAR}</a><!-- ELSE -->{newsrow.POSTER_AVATAR}<!-- ENDIF --><br />
<!-- ENDIF -->
<!-- IF not newsrow.U_POST_AUTHOR --><strong>{newsrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{newsrow.POST_AUTHOR_FULL}<!-- ENDIF -->
</dt>
<!-- IF newsrow.RANK_TITLE or newsrow.RANK_IMG --><dd>{newsrow.RANK_TITLE}<!-- IF newsrow.RANK_TITLE and newsrow.RANK_IMG --><br /><!-- ENDIF -->{newsrow.RANK_IMG}</dd><!-- ENDIF -->
<dd> </dd>
</dl>
<div class="back2top">
<a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a>
<!-- IF newsrow.U_READ_COMMENTS --><a href="{newsrow.U_READ_COMMENTS}">{newsrow.COMMENT_COUNT}</a> • <!-- ENDIF -->
<!-- IF newsrow.U_POST_COMMENTS --><!-- IF newsrow.S_IS_LOCKED -->{L_LOCKED_TO_COMMENTS}<!-- ELSE --><a href="{newsrow.U_POST_COMMENTS}">{L_POST_COMMENT}</a><!-- ENDIF --> • <!-- ENDIF -->
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<hr class="divider" />
<!-- END newsrow -->
<!-- ENDIF -->
<div style="text-align: center; margin: 0 auto;">{NEWS_PAGE_VERSION}</div>
<!-- INCLUDE overall_footer.html -->
Template file #2 (styles/prosilver/template/info_postbody.html)Code: Select all
<!-- BEGIN inforow -->
<h2>{inforow.POST_SUBJECT}</h2>
<div id="i" class="post <!-- IF inforow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="postbody">
<div class="content">{inforow.MESSAGE}</div>
<!-- IF inforow.SIGNATURE --><div id="sig-i{inforow.NEWS_ID}" class="signature">{inforow.SIGNATURE}</div><!-- ENDIF -->
</div>
<dl class="postprofile" id="profile{inforow.POST_ID}">
<dt>
<!-- IF inforow.POSTER_AVATAR -->
<!-- IF inforow.U_POST_AUTHOR --><a href="{inforow.U_POST_AUTHOR}">{inforow.POSTER_AVATAR}</a><!-- ELSE -->{inforow.POSTER_AVATAR}<!-- ENDIF --><br />
<!-- ENDIF -->
<!-- IF not inforow.U_POST_AUTHOR --><strong>{inforow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{inforow.POST_AUTHOR_FULL}<!-- ENDIF -->
</dt>
<!-- IF inforow.RANK_TITLE or inforow.RANK_IMG --><dd>{inforow.RANK_TITLE}<!-- IF inforow.RANK_TITLE and inforow.RANK_IMG --><br /><!-- ENDIF -->{inforow.RANK_IMG}</dd><!-- ENDIF -->
<dd> </dd>
</dl>
<div class="back2top">
<a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a>
<!-- IF inforow.U_READ_COMMENTS --> • <a href="{inforow.U_READ_COMMENTS}">{inforow.COMMENT_COUNT}</a><!-- ENDIF -->
<!-- IF inforow.U_POST_COMMENTS --> • <!-- IF inforow.S_IS_LOCKED -->{LOCKED_TO_COMMENTS}<!-- ELSE --><a href="{inforow.U_POST_COMMENTS}">{POST_COMMENT}</a><!-- ENDIF --><!-- ENDIF -->
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<hr class="divider" />
<!-- END inforow -->
Just remember to keep copyright information intact as per the GNU GPL v2.
That, and, this differs slightly from my [url=http://fail.infinityhouse.org/code.php]Repository[/url]'s copy, I found a typo or two copy-pasting it over. It's in the repository under /dev_projects/news_page/ for the curious, or if you want to download the files in there for correct tabbing.
Hi! Can you help me with this mod? I do all, like in the instruction, but it give me error...
Code: Select all
SQL ERROR [ mysql4 ]
[0]
SQL
No values specified for SQL IN comparison
BACKTRACE
FILE: includes/db/dbal.php
LINE: 379
CALL: dbal->sql_error()
FILE: includes/functions_getfora.php
LINE: 80
CALL: dbal->sql_in_set()
FILE: news.php
LINE: 51
CALL: get_fora_topics()
P.S. If you want to get news.php as main board page, then open ".htaccess", and add...
Code: Select all
DirectoryIndex news.php index.php index.html index.htm
With dignity, daGrevis...
Re: While loop problem
You forgot to add in the forum id's to look for news topics in.
It's this line in news.php
It's this line in news.php
Code: Select all
$search_foras = array(); #| Add own fora IDs later.
Re: While loop problem
Oh, thanks, now it shows me news page and news, but top of all, i got this error...
Any ideas? Help me please!
Code: Select all
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3879: Cannot modify header information - headers already sent by (output started at /language/en/mods/lang_news_page.php:54)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3881: Cannot modify header information - headers already sent by (output started at /language/en/mods/lang_news_page.php:54)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3882: Cannot modify header information - headers already sent by (output started at /language/en/mods/lang_news_page.php:54)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3883: Cannot modify header information - headers already sent by (output started at /language/en/mods/lang_news_page.php:54)
Any ideas? Help me please!
With dignity, daGrevis...
Re: While loop problem
Remove any spaces before the <?php tag in /language/en/mods/lang_news_page.php
Stupid code boxes.. <_<
Stupid code boxes.. <_<
Re: While loop problem
sTraTo wrote:Stupid code boxes.. <_<
If only we knew someone that was an admin on here that [url=http://www.phpbb.com/community/viewtopic.php?t=1323065]could fix that[/url].
-
- New member
- Posts: 23
- Joined: 06 Sep 2008, 14:59
Re: While loop problem
That should be applied to official boards. Like put it on top priority, it isn't hard to do...
Re: While loop problem
Thanks, but i fix it by my self!
I need to remove spaces from language and getfora file after ?> line! Thans, very, veru useful and cool mod!
I need to remove spaces from language and getfora file after ?> line! Thans, very, veru useful and cool mod!
With dignity, daGrevis...