2006-04-27, 03:13 AM
I've done alot of searching. But can't find an answer. Is there any way to get news post on the front page of Joomla and have it use the CSS file like the portal.php. You can see what i have so far HERE. Thanks!
require "./mybb/global.php";
<?php
$forumpath = "./forums/"; // Path to your forums root directory (with trailing slash)
$fid = "2"; // The forum ID to pull the annoucements from
$limit = "30"; // The amount of annoucements to show
require $forumpath."inc/config.php";
function bb_code(&$string){
$pattern = array(
//[ul]
'#\[list\](.*?)\[\/list\]#si',
//[*]
'#\[\*\](.*?)(\r\n|\r|\n|<br>|<br />|<br/>)#si',
//[url]
'#\[url\](.*?)\[\/(url)\]#si',
//[url=XXX]
'#\[url=("|"|\'|)(.*?)\\1\](.*?)\[\/url\]#si',
//[i],[u]
'#\[u\](.*?)\[/u\]#si',
'#\[i\](.*?)\[/i\]#si',
//[b]
'#\[b\](.*?)\[/b\]#si',
//[img]
'#\[img\](.*?)\[\/img\]#si',
// font size
'#\[size=("|"|\'|)([0-9\+\-]+)\\1\](.*?)\[\/size\]#si', '#(\r|\n|\r\n)#si');
$replacement = array(
//ul
"\t\t<ul>$1</ul>\r\n",
//li
"\t\t\t<li>$1</li>\r\n",
//a
'<a href="$1">$1</a>',
//a
'<a href="$2">$3</a>',
//i, u
'<u>$1</u>',
'<em>$1</em>',
//b
'<strong>$1</strong>',
//img
'<img src="$1" alt="User Posted Image" />',
//size
'<font size="\2">\3</font>', "<br />");
$string = preg_replace ($pattern, $replacement, stripslashes($string) ); $string = str_replace ('<br /><br />', "</p>\r\n\t\t<p>", $string);
}
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.dateline,t.replies,p.message,u.avatar FROM ".$config['table_prefix']."threads t LEFT JOIN ".$config['table_prefix']."posts p ON (t.tid = p.tid) LEFT JOIN ".$config['table_prefix']."users u ON (t.uid = u.uid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC LIMIT 0, ".$limit."") or die(mysql_error());
while ($news = mysql_fetch_array ($query)){
$date = gmdate ("jS F Y", $news['dateline']);
$time = gmdate ("h:i A", $news['dateline']);
//Parse BBCode
bb_code($news['message']);
if($news['replies'] == "1"){
$replytext = "reply";
} else {
$replytext = "replies";
}
if($news['avatar'] != ""){
if(substr($news['avatar'], 0, 7) != "http://")
{
$url = $forumpath;
}
$avatarbit = "<img style='float:left; margin:10px;'src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" />\r\n\t\t";
} else {
$avatarbit = "";
}
echo "\t<div class=\"news\">\r\n\t\t";
echo "<h2>".$news['subject']."</h2>\r\n\t\t";
echo $avatarbit."<p>".$news['message']."</p>\r\n\t\t<div style=\"clear:both;\"></div>\r\n\t";
echo "<div class='details'>(<a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['replies']." ".$replytext." </a>) | Posted by <a href=\"".$forumpath."member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."</div>\r\n\t\t";
echo "</div>\r\n";
echo "____________________________________________";
}
?>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td class="tborder">
<table border="0" cellspacing="$theme[borderwidth]" cellpadding="$theme[tablespace]" width="100%">
<tr>
<td class="thead"><strong>$lang->News Headline </strong></td>
</tr>
<tr>
<td class="trow1" align="left">
<p class="smalltext">news body</p>
<p class="smalltext">(0 replies ) | Posted by RogueDOC on 25th April 2006 at 05:24 AM <a href="index.php"></a><br />
</p></td>
</tr>
</table>
</td></tr></table>
<br />
require $forumpath."inc/config.php";
require "./path/global.php";