[ABD] News Forum

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
noltha
Registered User
Posts: 55
Joined: Thu Nov 15, 2007 9:11 am

Re: [BETA] News Forum

Post by noltha » Sun Jan 06, 2008 8:32 am

sure, here it is:

Code: Select all

<?php

// Start the phpbb 3 session
define( 'IN_PHPBB', true );
$phpbb_root_path = './../phpbb3/'; // change in your own root path.
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();
$auth->acl( $user->data );
$user->setup();

// Include the needed files
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/news.' . $phpEx);

// Instance the needed classes
$bbcode	= new bbcode();
$news		= new news();

// Is the rss feed called?
$rss = request_var ('view', 'news'); // $_GET['view']
if( strtolower($rss) === 'rss' )
{
	// Build the rss page
	$news->build_rss ();
}
else
{
	// Get the array with news data
	$news_data = $data = $news->get_news();
	
	/*
	echo'<pre>';
	print_r($news_data);
	echo'</pre>';
	*/
}
?>

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Sun Jan 06, 2008 11:05 am

You are using an old version of example.php, I thought that I changed that :?.
Make the changes as stated in this post. This is purely a very basic lay out. You need to style it in a way you like it :).
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

noltha
Registered User
Posts: 55
Joined: Thu Nov 15, 2007 9:11 am

Re: [BETA] News Forum

Post by noltha » Sun Jan 06, 2008 4:52 pm

ok - now it works..really thanks.

But it show only the first message of the forum(the news forum)..

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Sun Jan 06, 2008 6:21 pm

It should show every first post (per topic) from the news forum.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

xhriz
Registered User
Posts: 8
Joined: Sat Feb 12, 2005 10:01 am

Re: [BETA] News Forum

Post by xhriz » Sun Jan 06, 2008 6:33 pm

Hello,

I been waiting for someone to make a fetch all kindof mod. All i want is to be able to extract news to website and this mod should do it. My problem now is however that i get this error

Code: Select all

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' 
I cant write code like this, Im not that good but i figured out its because im running php4 and there are functions in this mod that require php5 functions. I dont know if its a big change to make it work for php4 or if its even possible.

Im running my own server with several phpbb2 forums, chats teamspeak servers and atm there is to much updating of the other things on the server for me to run php5 so that is not an option.

Im now making a new fansite for the game aion tower of eternity and this time i thought i go with phpbb3 for the first time, design is done just need to get the newsfeed on website to release it. Guess i should have gone with phpbb2 instead. I would be happy if it was possible to make it work for php4.

thx

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Sun Jan 06, 2008 9:42 pm

php4 compability is easy to fix. Open /includes/news.php, find:

Code: Select all

    /**
    * The constructor
    *
    * @access public
    */
    public function news()
    {
        global $config;
        
        // Make sure that we can use necessary phpBB objects
        global $db, $user, $phpbb_root_path, $phpEx, $bbcode;
        $this->db        = $db;
        $this->user    = $user;
        
        // Set the path to the board.
        $server_name = trim ($config['server_name']);
        $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
        $server_port = ($config['server_port'] <> 80) ? ':' . trim ($config['server_port']) . '' : '';
        $script_path = trim ($config['script_path']);
        $this->board_uri = $server_protocol . $server_name . $server_port;
        $this->board_uri .= ( $script_path != '' ) ? $script_path . '/' : '';
    } 
Replace-with:

Code: Select all

    /**
    * The constructor
    *
    * @access public
    */
    function news()
    {
        global $config;
        
        // Make sure that we can use necessary phpBB objects
        global $db, $user, $phpbb_root_path, $phpEx, $bbcode;
        $this->db        = $db;
        $this->user    = $user;
        
        // Set the path to the board.
        $server_name = trim ($config['server_name']);
        $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
        $server_port = ($config['server_port'] <> 80) ? ':' . trim ($config['server_port']) . '' : '';
        $script_path = trim ($config['script_path']);
        $this->board_uri = $server_protocol . $server_name . $server_port;
        $this->board_uri .= ( $script_path != '' ) ? $script_path . '/' : '';
    } 
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

dr_nza
Registered User
Posts: 63
Joined: Fri Jul 07, 2006 2:34 am
Contact:

Re: [BETA] News Forum

Post by dr_nza » Sun Jan 06, 2008 11:09 pm

The specified file still opens with <?php.

I checked where I modified it for any errors made on my end but to no avail.

Any other ideas?

xhriz
Registered User
Posts: 8
Joined: Sat Feb 12, 2005 10:01 am

Re: [BETA] News Forum

Post by xhriz » Mon Jan 07, 2008 7:30 am

thx for php4 code, after some heavy reading in rest of post i got this working. I need some help though. Could someone help me with the code to get date and link to forum in example.php without rss?

well done, nice mod.

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Mon Jan 07, 2008 1:33 pm

dr_nza wrote:The specified file still opens with <?php.

I checked where I modified it for any errors made on my end but to no avail.

Any other ideas?
Can you post the first 20 lines of /language/en/acp/forums.php?
xhriz wrote:thx for php4 code, after some heavy reading in rest of post i got this working. I need some help though. Could someone help me with the code to get date and link to forum in example.php without rss?

well done, nice mod.
What do you mean? When you call the news page without view=rss in the url it won't show the rss page.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

xhriz
Registered User
Posts: 8
Joined: Sat Feb 12, 2005 10:01 am

Re: [BETA] News Forum

Post by xhriz » Mon Jan 07, 2008 5:42 pm

Sry ill explain better

here is my rss http://vent.thefatsoldier.com/settlers/ ... p?view=rss
here is my example without rss http://vent.thefatsoldier.com/settlers/example.php

I used the code earlier in the thread to get it to display the news but it was just an example without any code for extracting date and making a link to the post in forum to comment the news.

Code: Select all

$output = "<div>";
    foreach ($news_data as $key => $val)
    {
        $output .= "<h1>".censor_text ($news_data[$key]['subject'])."</h1>";
        /* Parse bbcode */
        if ($news_data[$key]['bitfield'])
        {
            $news_data[$key]['text'] = $bbcode->bbcode_second_pass($news_data[$key]['text'], $news_data[$key]['bbc_uid'], $news_data[$key]['bitfield']);
        }
        $news_data[$key]['text'] = bbcode_nl2br($news_data[$key]['text']);
        $news_data[$key]['text'] = smiley_text($news_data[$key]['text']);
    
        $output .= "<p>".$news_data[$key]['text']."</p>";
    }
    print($output . "</div>");    
I tried all day but i simply cant do it on my own so i was hoping someone could help out with the code for that then i can simply use my css file to get it to fit my website. Its the structure i need help with.

Its going into this http://vent.thefatsoldier.com/settlers/portal.php?tfs=9

Sry this is not helping the mod its simply a request.

spikechu
Registered User
Posts: 55
Joined: Fri May 05, 2006 3:20 am

Re: [BETA] News Forum

Post by spikechu » Tue Jan 08, 2008 4:24 am

ok so i read all the posts did all the updates and when i go to load example.php i get a blank white screen here is my code

Code: Select all

<?php

// Start the phpbb 3 session
define( 'IN_PHPBB', true );
$phpbb_root_path = './'; // change in your own root path.
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();
$auth->acl( $user->data );
$user->setup();

// Include the needed files
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/news.' . $phpEx);

// Instance the needed classes
$bbcode	= new bbcode();
$news		= new news();

// Is the rss feed called?
$rss = request_var ('view', 'news'); // $_GET['view']
if( strtolower($rss) === 'rss' )
{
	// Build the rss page
	$news->build_rss ();
}
else
{
// Get the array with news data
   $news_data = $news->get_news(true);

        $output = "<div>";
        foreach ($news_data as $key => $val)
        {
            $output .= "<h1>".censor_text ($news_data[$key]['subject'])."</h1>";
            /* Parse bbcode */
            if ($news_data[$key]['bitfield'])
            {
                $news_data[$key]['text'] = $bbcode->bbcode_second_pass($news_data[$key]['text'], $news_data[$key]['bbc_uid'], $news_data[$key]['bitfield']);
            }
            $news_data[$key]['text'] = bbcode_nl2br($news_data[$key]['text']);
            $news_data[$key]['text'] = smiley_text($news_data[$key]['text']);
        
            $output .= "<p>".$news_data[$key]['text']."</p>";
        }
        print($output . "</div>");  
    
	/*
	echo'<pre>';
	print_r($news_data);
	echo'</pre>';
	*/
}
?>

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Tue Jan 08, 2008 9:14 am

Have you set a news forum? Are there posts in the news forum?
Can you post the html source of the page for me?
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
Spider M. Mann
Registered User
Posts: 73
Joined: Sat Dec 01, 2007 3:06 pm

Re: [BETA] News Forum

Post by Spider M. Mann » Fri Jan 11, 2008 6:02 am

Hi Erik,

Nice MOD. Works perfectly for me. However, I am having a bit of trouble implementing it on my particular setup. I have a static "home" page as a sort of pseudo portal, and would like to output the posts of a news forum to that page. It is setup as outlined here, with a separate HTML template in my styles template folder. I'm not sure exactly how I should call the array to the HTML page, and was curious if you could provide a bit of assistance.

Now, just to give you a little background, I've "hacked up" your example.php file in order to include the needed values and such in my existing "home" page, but have used the root/includes/news.php file exactly as packaged except for the necessary edits outlined in this thread. As I mentioned above, it works perfectly to output relatively un-formatted text, but I would like to stick it into a kind of "block" on the front page and apply the formatting used on the forum pages -- ostensibly making it universal for any style applied.

I'll provide the custom files I've created here, minus the root/includes/news.php, and you are welcome to use them for any examples or templates if you would like. Perhaps they will be of some use for someone.

root/home.php:

Code: Select all

<?php
/**
*
* @author Spider M. Mann
*
* @package phpBB3
* @version 1.0
* @copyright (c) 2008 Palehorse Information Services
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @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);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/news.' . $phpEx);

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

// specify styles and/or localisation
$user->setup('mods/home_en');

// Instance the needed classes
$bbcode    = new bbcode();
$news        = new news();

// Lets build a page ...
page_header($user->lang['L_HOME_TITLE']);

// This is the name of the template file in root/styles/template_name/template/
$template->set_filenames(array(
    'body' => 'home.html',
));

// Assign home page specific vars
$template->assign_vars(array(
    'S_LOGIN_ACTION'            => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
));

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);

// Completing the script and displaying the page.
page_footer();

?>
localization file from root/language/en/mods/home_en.php:

Code: Select all

<?php
/**
*
* groups [English]
*
* @author Spider M. Mann
*
* @package language
* @version 1.0
* @copyright (c) 2008 Palehorse Information Services
* @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

$lang = array_merge($lang, array(
    'L_HOME_TITLE'        => 'Home Page',
));

?>
And finally, the Home page in root/styles/template_name/template/home.html:

Code: Select all

<!-- INCLUDE overall_header.html -->

<div class="panel">
    <div class="inner"><span class="corners-top"><span></span></span><br />
    <div class="content">

        <p class="gen">This is the home page. Please edit appropriately.</p>
        <h2>Stuff</h2>
        <p class="gen">Stuff stuff stuff.</p>
        <br />

<!-- I WOULD LIKE TO INSERT THE NEWS ARRAY HERE -->

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

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
    <form method="post" action="{S_LOGIN_ACTION}" class="headerspace">

    <h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a>&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a></h3>
        <fieldset class="quick-login">
            <label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" />  
            <label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
            <!-- IF S_AUTOLOGIN_ENABLED -->
                | <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
            <!-- ENDIF -->
            <input type="submit" name="login" value="{L_LOGIN}" class="button2" />
        </fieldset>
    </form>
<!-- ENDIF -->

<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->  
As I'm sure you can tell, the home.php file is incomplete and is missing the output array and rss info, because I'm not sure exactly where to put it. I'm sure I'm close, but I can't seem to see the forest for the trees...
Thanks for any assistance you can give.
-Spider
Last edited by Spider M. Mann on Thu Jan 17, 2008 7:55 am, edited 2 times in total.

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: [BETA] News Forum

Post by Erik Frèrejean » Fri Jan 11, 2008 4:13 pm

Hi Spider,

This shouldn't be a very big problem to achieve. Try the following:

Open /root/home.php, Replace-all-with:

Code: Select all

<?php
/**
*
* @author Spider M. Mann
*
* @package phpBB3
* @version 1.0
* @copyright (c) 2008 Palehorse Information Services
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
// Fire things up :)
define ('IN_PHPBB', true);
$phpbb_root_path    = (defined ('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx                = substr (strrchr (__FILE__, '.'), 1);
include ($phpbb_root_path . 'common.'. $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/news.' . $phpEx);

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

// specify styles and/or localisation
$user->setup('mods/home_en');

// Instance the needed classes
$bbcode   = new bbcode();
$news      = new news();

// Lets build a page ...
page_header($user->lang['L_HOME_TITLE']);

// This is the name of the template file in root/styles/template_name/template/
$template->set_filenames(array(
        'body' => 'home.html',
));

// Assign home page specific vars
$template->assign_vars(array(
    'S_LOGIN_ACTION'         => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
));

// Let's do something with the news class
$news_data = $news->get_news(true);
foreach ($news_data as $key => $val)
{
    // Parse the post
    $news_subject    = censor_text ($news_data[$key]['subject']);
    
    if ($row['bbcode_bitfield'])
    {
        $bbcode->bbcode_second_pass($news_message, $news_data[$key]['bbc_uid'], $news_data[$key]['bitfield']);
    }
    $news_message    = bbcode_nl2br($news_message);
    $news_message    = smiley_text($news_message);
    
    // Assign the vars
    $template->assign_block_vars ('news_row', array (
        'TITLE'    => $news_subject,
        'POST'    => $message,
    ));
}

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);

// Completing the script and displaying the page.
page_footer();

?>
Open root/styles/template_name/template/home.html, Replace-all-with:

Code: Select all

<!-- INCLUDE overall_header.html -->

<div class="panel">
    <div class="inner"><span class="corners-top"><span></span></span><br />
    <div class="content">

        <p class="gen">This is the home page. Please edit appropriately.</p>
        <h2>Stuff</h2>
        <p class="gen">Stuff stuff stuff.</p>
        <br />

        <!-- BEGIN news_row -->
        <h3>{news_row.TITLE}</h3>
        <p>
            (news_row.POST}
        </p>
        <!-- END news_row -->

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

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
    <form method="post" action="{S_LOGIN_ACTION}" class="headerspace">

    <h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a>&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a></h3>
        <fieldset class="quick-login">
            <label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" /> 
            <label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
            <!-- IF S_AUTOLOGIN_ENABLED -->
                | <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
            <!-- ENDIF -->
            <input type="submit" name="login" value="{L_LOGIN}" class="button2" />
        </fieldset>
    </form>
<!-- ENDIF -->

<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->  
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
Spider M. Mann
Registered User
Posts: 73
Joined: Sat Dec 01, 2007 3:06 pm

Re: [BETA] News Forum

Post by Spider M. Mann » Fri Jan 11, 2008 7:40 pm

Thanks for the input, Erik! Looks good except for a couple minor things. First for anyone else using this, there is a minor typo in the root/styles/template_name/template/home.html file:

Find in root/styles/template_name/template/home.html:

Code: Select all

        <!-- BEGIN news_row -->
        <h3>{news_row.TITLE}</h3>
        <p>
            (news_row.POST}
        </p>
        <!-- END news_row -->  
Replace with:

Code: Select all

        <!-- BEGIN news_row -->
        <h3>{news_row.TITLE}</h3>
        <p>
            {news_row.POST}
        </p>
        <!-- END news_row -->  
(The opening bracket at news_row.POST was a parenthesis. No biggie.)

Next up, Erik, the Subject Title outputs correctly, but the message body is empty. I tried a couple little things, but I don't know enough about php variables to be of any help. No errors or anything, just no message text. Sorry to bother you with this minutia, but I'm so close I can hardly contain myself.

Thank you again for your hard work.
-Spider
Last edited by Spider M. Mann on Thu Jan 17, 2008 7:56 am, edited 1 time in total.

Locked

Return to “[3.0.x] Abandoned MODs”