Seite 2 von 2

Verfasst: 20.10.2008 14:11
von FatFreddy
Versuch es mal hiermit:

Code: Alles auswählen

<?php
// ############         Edit below         ########################################
$topic_length = '20';   // length of topic title
$topic_limit = '10';   // limit of displayed topics
$special_forums = '1';   // specify forums ('0' = no; '1' = yes)
$forum_ids = '74';      // IDs of forums; separate them with a comma
// ############         Edit above         #######################################


// ############## output ##############
$domain_top = '<h2>Domain Verkauf</h2><ul>';
// ############## output ##############

$where_forums = ( $special_forums == '0' ) ? '' : ' AND forum_id IN ('. $forum_ids .') ';
$sql = 'SELECT topic_title, forum_id, topic_id
	FROM ' . TOPICS_TABLE . '
	WHERE topic_status <> ' . ITEM_MOVED . '
		AND topic_approved = 1 
		AND topic_type = ' . POST_NORMAL . '
		AND topic_moved_id = 0
		' . $where_forums . '
	ORDER BY topic_time DESC';

$result = $db->sql_query_limit($sql, $topic_limit);

if( !$result )
{
   die('SQL Statement Error: '. mysql_error());
   exit();
}

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

for( $i = 0; $i < count($line); $i++ )
{
   $forum_id = $line[$i]['forum_id'];
   $forum_url = $root_path .'viewforum.php?f='. $forum_id;
   $topic_id = $line[$i]['topic_id'];
   $topic_url = $root_path .'viewtopic.php?t='. $topic_id;

   $topic_title = ( strlen($line[$i]['topic_title']) < $topic_length ) ? $line[$i]['topic_title'] : substr(stripslashes($line[$i]['topic_title']), 0, $topic_length) .'...';

   // ############## output ##############
$domain_top = $domain_top .'<li><a href="'. $topic_url .'">'. $topic_title .'</a></li>';

   // ############## output ##############
}
$db->sql_freeresult($result);
$domain_top = $domain_top .'</ul>';

$template->assign_vars(array(
      'DOMAIN_VERKAUF'      => $domain_top)
   );

?>
Habe mir auch erlaubt, die SQL-Abfrage noch etwas zu vereinfachen. ;)

EDIT: Wenn Du mehrere von diesen Blöcken anzeigen willst, könnt man das Ganze noch in eine eigene Funktion packen und dies einfach für jeden darzustellenden Block aufrufen.

FatFreddy

Verfasst: 20.10.2008 14:56
von webrunde
Wow, Spitze! [ externes Bild ]

Funktioniert einwandfrei!
Zu bewundern unter www.domainforum.info

Ja, da werden mindestens zwei davon eingebaut, also wenn man da eine Funktion daraus macht, ist es doch schon ein richtiges Mod. :wink:

Ansonsten würde ich das ganze unter einem zweiten Namen duplizieren.

PS
Ich sehe nirgends solche Forumlayouts mit Sidebar, wieso denn eigentlich?