Das neuste von Forum und News auf Extraseite

Probleme bei der regulären Arbeiten mit phpBB, Fragen zu Vorgehensweisen oder Funktionsweise sowie sonstige Fragen zu phpBB im Allgemeinen.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Benutzeravatar
tts
Mitglied
Beiträge: 177
Registriert: 19.05.2007 14:14
Kontaktdaten:

Das neuste von Forum und News auf Extraseite

Beitrag von tts »

Hi,

ich habe ein phpbb 2 board und die MOD phpbb easyCMS installiert.
Nun meine Frage, wie kann ich eine bestimmte Anzahl an neuen Beiträgen aus dem Forum und dem phpbb easyCMS (news) auf einer Extraseite darstellen.

Könnte man diese MOD's umbauen:

http://www.phpbb.de/moddb/at_a_glance
http://www.phpbb.de/moddb/recent_topics

Wie man diese Extraseite zur Startseite macht, was mein endgültiges Ziel ist, steht ja hier:

http://www.phpbb.de/viewtopic.php?t=148 ... +index+php

Für das CMS hab ich das gefunden:
http://www.phpbbhacks.com/download/2208
Leider basiert das auf Javacript, was den Nachteil hat, dass User die das deaktiviert haben, die News nicht sehen. Könnte man das umschreiben?

Danke schon mal im vorraus. :)
Nicht irgendein PC-Forum --> http://www.ttshooter.de
Guckst Du hier -> Video anschauen
Benutzeravatar
tts
Mitglied
Beiträge: 177
Registriert: 19.05.2007 14:14
Kontaktdaten:

Beitrag von tts »

Ich halte es für so wichtig, dass ich einen neuen Beitrag schreibe:

Ich habe es geschafft, die neusten NEWS und FORENBEITRÄGE auf eine Seite zu bringen. Jetzt nur noch das Template anpassen fertig.

Den Code könnte man auch noch optimieren, dabei könntet ihr mir ja behilflich sein:

Code: Alles auswählen

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/cms_auth.'.$phpEx);
include($phpbb_root_path . 'includes/cms_functions.'.$phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_cms.'.$phpEx);

get_cms_config();

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_HOME);
init_userprefs($userdata);
//
// End session management
//

//
// Parameters
//
$start = ( isset($HTTP_POST_VARS['start']) ) ? intval($HTTP_POST_VARS['start']) : ( ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0 );
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? htmlspecialchars($HTTP_POST_VARS['mode']) : ( ( isset($HTTP_GET_VARS['mode']) ) ? htmlspecialchars($HTTP_GET_VARS['mode']) : '' );
$article_id = ( isset($HTTP_POST_VARS['aid']) ) ? intval($HTTP_POST_VARS['aid']) : ( ( isset($HTTP_GET_VARS['aid']) ) ? intval($HTTP_GET_VARS['aid']) : 0 );
$chapter_id = ( isset($HTTP_POST_VARS['cid']) ) ? intval($HTTP_POST_VARS['cid']) : ( ( isset($HTTP_GET_VARS['cid']) ) ? intval($HTTP_GET_VARS['cid']) : 0 );


// Set vars to prevent naughtiness
$home = array();

//
// Load the appropriate home file
//

	$lang_file = 'lang_main';
	$l_title = $lang['Home'];

include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/' . $lang_file . '.' . $phpEx);

//
// Lets build a page ...
//

$page_title = $l_title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
	'body' => 'home.tpl')
);

$template->assign_vars(array(
	'L_ARTICLES' => $lang['Articles'],
	'L_AUTHOR' => $lang['Author'],
	'L_CHAPTER' => $lang['Chapter'],
	'L_COMMENTS' => $lang['Comments'],
	'L_RATING' => $lang['Rating'],
	'L_VIEWS' => $lang['Views'],
	'L_NO_ARTICLES' => $lang['No_articles'],
	'L_TIME' => $lang['Time'],

	'CHAPTER_NAME' => $chapter_info['chapter_name'],
	'CHAPTER_DESC' => $chapter_info['chapter_desc'],

	'U_VIEW_CHAPTER' => append_sid("cms_articles.$phpEx?cid=" . $chapter_info['chapter_id']),

	'S_AUTH_CAN' => $s_auth_can
	)
);

if( !$chapter_id )
{
	$template->assign_block_vars('showchapter', array());

	$sql = "SELECT * FROM " . CMS_CHAPTERS_TABLE . " ORDER BY chapter_id";
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not retrieve chapter information', '', __LINE__, __FILE__, $sql);
	}

	$chapter_data = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$chapter_data[] = $row;
	}

	$db->sql_freeresult($result);

	$is_auth_ary = array();
	$is_auth_ary = cms_auth(AUTH_LIST_ALL, $userdata);

	$chapter_sql = '';
	for( $i = 0; $i < count($chapter_data); $i++ )
	{
		$this_chapter_id = $chapter_data[$i]['chapter_id'];
		if( $is_auth_ary[$this_chapter_id]['a_view'] && $is_auth_ary[$this_chapter_id]['a_read'] )
		{
			$chapter_sql .= ( ( $chapter_sql != '' ) ? ', ' : '' ) . $this_chapter_id;
		}
	}

	if( $chapter_sql != '' )
	{
		$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND a.article_pending = 0';
		$sql = "SELECT a.*, at.*, c.chapter_name, u.username
				FROM " . CMS_ARTICLES_TABLE . " a, " . CMS_ARTICLES_TEXT_TABLE . " at, " . CMS_CHAPTERS_TABLE . " c, " . USERS_TABLE . " u
				WHERE at.article_id = a.article_id
					AND u.user_id = a.user_id
					AND c.chapter_id = a.chapter_id
					AND c.chapter_id IN ($chapter_sql)
					$pending_sql
				ORDER BY time DESC
				LIMIT 0, " . $cms_config['articles_on_list'];
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not retrieve most recent articles information', '', __LINE__, __FILE__, $sql);
		}

		$article_row = array();
		while( $row = $db->sql_fetchrow($result) )
		{
			$article_row[] = $row;
		}

		$db->sql_freeresult($result);
	}
}
else
{
	if( !$is_auth['a_view'] && !$is_auth['a_read'] )
	{
		message_die(GENERAL_MESSAGE, 'No_such_chapter_id');
	}

	//
	// Fetch the articles
	//
	$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND article_pending = 0';
	$sql = "SELECT COUNT(*) AS total
			FROM " . CMS_ARTICLES_TABLE . "
			WHERE chapter_id = $chapter_id
				$pending_sql";
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not retrieve articles total information', '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

	$total_articles = $row['total'];

	$pagination = '';
	if( $total_articles > 0 )
	{
		$template->assign_vars(array(
			'PAGINATION' => generate_pagination("cms_articles.$phpEx?cid=$chapter_id", $total_articles, $cms_config['articles_per_page'], $start),
			'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($cms_config['articles_per_page']) ) + 1 ), ceil( $total_articles / intval($cms_config['articles_per_page']) ))
			)
		);
	}
	else
	{
		$template->assign_block_vars('switch_no_articles', array());
	}


	$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND a.article_pending = 0';
	$sql = "SELECT a.*, at.* , u.username
			FROM " . CMS_ARTICLES_TABLE . " a, " . CMS_ARTICLES_TEXT_TABLE . " at, " . USERS_TABLE . " u
			WHERE a.chapter_id = $chapter_id
				AND at.article_id = a.article_id
				AND u.user_id = a.user_id
				$pending_sql
			ORDER BY time DESC
			LIMIT $start, " . $cms_config['articles_per_page'];
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not retrieve articles information', '', __LINE__, __FILE__, $sql);
	}

	$article_row = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$article_row[] = $row;
	}

	$db->sql_freeresult($result);
}


for( $i = 0; $i < count($article_row); $i++ )
{
	$row_class = ( $i % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
	$row_color = ( $i % 2 ) ? $theme['td_color1'] : $theme['td_color2'];

	$article_title = $article_row[$i]['article_title'];
	if ( count($orig_word) )
	{
		$article_title = preg_replace($orig_word, $replacement_word, $article_title);
	}

	$article_icon = '';
	for( $j = 0; $j < count($icon_row); $j++ )
	{
		if( $icon_row[$j]['icon_id'] == $article_row[$i]['article_icon'] )
		{
			$article_icon = '<img src="' . $cms_config['icons_path'] . '/' . $icon_row[$j]['icon_href'] . '" width="19" height="19" alt="" border="0" hspace="3" />';
		}
	}

	//
	// Set the username
	// If user is anonymous and has a username, set it as well
	//
	$s_author = ( $article_row[$i]['user_id'] == ANONYMOUS ) ? $lang['Guest'] : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=" . $article_row[$i]['user_id']) . '">' . $article_row[$i]['username'] . '</a>';
	if( $article_row[$i]['user_id'] == ANONYMOUS )
	{
		if( $article_row[$i]['article_username'] != '' )
		{
			$s_author = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $article_row[$i]['article_username']) : $article_row[$i]['article_username'];
		}
	}


	$template->assign_block_vars('articlerow', array(
		'ROW_CLASS' => $row_class,
		'ROW_COLOR' => '#' . $row_color,

		'ARTICLE_TITLE' => $article_title,
		'ARTICLE_VIEWS' => intval($article_row[$i]['article_views']),
		'ARTICLE_COMMENTS' => intval($article_row[$i]['article_comments']),
		'ARTICLE_ICON' => $article_icon,
		'ARTICLE_RATING' => calc_rating('article', $article_row[$i]['article_id'], true),
		'POST_TIME' => create_date($board_config['default_dateformat'], $article_row[$i]['time'], $board_config['board_timezone']),

		'U_VIEW_ARTICLE' => append_sid("cms_view_article.$phpEx?aid=" . $article_row[$i]['article_id']),

		'S_AUTHOR' => $s_author
		)
	);

	if( !$chapter_id )
	{
		$template->assign_block_vars('articlerow.showchapter', array(
			'CHAPTER_NAME' => $article_row[$i]['chapter_name'],

			'U_VIEW_CHAPTER' => append_sid("cms_articles.$phpEx?cid=" . $article_row[$i]['chapter_id'])
			)
		);
	}
}



make_jumpbox('viewforum.'.$phpEx);

include($phpbb_root_path .'recent.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
EDIT 21:28 : Das ist das Ergebnis: http://www.tts.kilu3.de/forum/home.php
Nicht irgendein PC-Forum --> http://www.ttshooter.de
Guckst Du hier -> Video anschauen
Antworten

Zurück zu „phpBB 2.0: Administration, Benutzung und Betrieb“