While loop problem

Discuss the development of future releases of phpBB (phpBB 3.x minor releases) and MODing/Coding related questions.
Luuq
New member
New member
Posts: 5
Joined: 26 Jul 2009, 22:02

Re: While loop problem

Post by Luuq »

Hey,

how and where i have do add the id of the forums exactly?

Luuq
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: While loop problem

Post by Obsidian »

In the PHP file FILE: [ news.php ], there is a line which controls the forums that you want to search.

Code: Select all

$search_foras = array();  #| Add own fora IDs later.


Just fill in the array with the forum ID's that you want to search in.

Examples...
(One forum)

Code: Select all

$search_foras = array(2);  #| Add own fora IDs later.

(Multiple forums)

Code: Select all

$search_foras = array(1, 2, 3, 5, 7, 11, 13);  #| Add own fora IDs later.
Luuq
New member
New member
Posts: 5
Joined: 26 Jul 2009, 22:02

Re: While loop problem

Post by Luuq »

Hey,

thank you it works!

but now i have a error in the header.
you can see it here:

http://www.movieparkfans.de/news.php

i dont have any spaces before the <?php tag in /language/en/mods/lang_news_page.php

and i have a another question :D
how many news are displayed per page?

Luuq

sry for my english, im german :D
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: While loop problem

Post by Obsidian »

No problem, I can still understand you. :P

I don't see any errors in the header there, did you fix it?

To change the amount of results returned, you can change this:

Code: Select all

if(($results = get_fora_topics($search_foras, 3, true)) == false)


Change 3 to the number of results you want to show at maximum. :)
Luuq
New member
New member
Posts: 5
Joined: 26 Jul 2009, 22:02

Re: While loop problem

Post by Luuq »

hey,

the error seems to be gone :D

and the number of news per page works :D
thank you for the great mod.

luuq
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: While loop problem

Post by Obsidian »

No problem. I'm considering releasing it as an actual MOD sometime, after I get some stuff done. Need to make an ACP module for it and all that jazz. :)
Luuq
New member
New member
Posts: 5
Joined: 26 Jul 2009, 22:02

Re: While loop problem

Post by Luuq »

hey,

the error is back :D
he appears when there is no news which is to be displayed

you cann see it on my page :)

luuq
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: While loop problem

Post by Obsidian »

Luuq wrote:hey,

the error is back :D
he appears when there is no news which is to be displayed

you cann see it on my page :)

luuq


Ahh, gotcha. That's right, there was an issue with that. >_<

Try this as news.php, and change the forum ID's and result count at will.

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);
   
//! Assign credit.  Quite important for the ego.
   $template->assign_var('NEWS_PAGE_VERSION', 'phpBB News Page <strong title="' . $version_big . '">' . $version . '</strong> &copy; 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...
   else
   {
      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();      
?>
Luuq
New member
New member
Posts: 5
Joined: 26 Jul 2009, 22:02

Re: While loop problem

Post by Luuq »

It works, thank you. :)
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: While loop problem

Post by Obsidian »

Luuq wrote:It works, thank you. :)


Cheers, enjoy. Might want to keep an eye out if I ever do release the next beta with some new shiny toys in it. :lol:
Post Reply