MyBB Community Forums

Full Version: My Index and News page. (resievil.com)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On the request of kruzzen here is my code for my index page, and news page Angel

Its just a copy+paste of my code, so edit it to suit your needs, and to fit your template.
Design is pretty straight forward, so should be easy enough to understand.


Index ¬
<?php
    $fid1 = 4; //enter your fid for the announcements block
    $limit1 = 5; //enter how many announcements you want to show
    $fid2 = 5; //enter your fid for the news block
    $limit2 = 5; //enter how much news to be shown
    $forumpath = './'; //enter your forum path
    chdir($forumpath);
    define("IN_MYBB", 1);
    require './global.php';
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="Resievil.com" />
<meta name="copyright" content="Copyright Resievil. &copy; resievil.com" />
<meta name="description" content="The official homepage for Resievil, a free, fun community fansite for Resident Evil." />
<meta name="keywords" content="resievil,fansite,resievil.com,forum,community,resident,evil,news,rss,video,degeneration,resident evil 5" />
<link href="twoColHybLtHdr.css" rel="stylesheet" type="text/css" />
<title>Resident Evil Fansite - Index</title>
</head>
<body>
<div id="container1">
  <div id="topheader1"> </div>
  <div id="header1"> </div>
  <div class="div_menu">
    <ul class="ul_menu">
      <li><a id="a_selected" href="index.php">Home</a></li>
      <li><a  href="news.php">News</a></li>
      <li><a  href="forum.php">Forum</a></li>
      <li><a  href="video.php">Videos</a></li>
      <?php if($mybb->user['uid'] > 0) {
                        echo "";
                        }
                        else
                        {
                        echo "<li><a  href='./member.php?action=register'>Register!</a></li>";
                        }
                        ?>
    </ul>
  </div>
  <div class="clear"></div>
  <div id="sidebar1">
    <div id="leftbg1">
      <?php
if($mybb->user['uid'] > 0) {
echo "User Box";
}
else
{
echo "Login Box";
}
?>
    </div>
    <div id="left1">
      <div id="text">
        <?php

if($mybb->user['avatar'] != "") 
{
echo "<a href='/member.php?action=profile&uid=". $mybb->user['uid']."'><img style='border: none;' src='".$mybb->user['avatar']."'/></a><br /><br />";
}

if($mybb->user['uid'] > 0) 
{
echo "<a href='./usercp.php'>User Control Panel</a><br />
      <a href='./private.php'>Private Messages</a><br />
      <a href='./search.php?action=getdaily'>Today's Posts</a><br />
      <a href='./search.php?action=getnew'>New Posts</a><br />
      <a href='./member.php?action=logout&amp;logoutkey=".$mybb->user['logoutkey']."'>Logout</a>";

} 
else 
{

    echo "<form action='./member.php' method='post'>
    <input type=\"hidden\" name=\"my_post_key\" value=\"$mybb->post_code\" />
    Username: <input type='text' name='username' size='18' maxlength='30' /><br />
    Password: <input type='password' name='password' size='18' />
    <input type='hidden' name='action' value='do_login'>
    <input type='hidden' name='url' value='./index.php' />
    <input type='submit' class='submit' name='submit' value='Login' /></form><br><a href='./member.php?action=register'>Not Registered?</a>";
}
?>
      </div>
    </div>
    <div id="leftbg1" style="margin-top: 10px;">Side Menu</div>
    <div id="left1">
      <div id="text"> <strong>Latest Threads</strong>
        <hr/>
        <br />
        <?php
        echo "{$threadlist}";
         ?>
        <br />
        <strong>Ads</strong>
        <hr/>
        <br />
        <a target="_blank" href="http://clubjn.com/forum/">Club JN</a> </div>
        <br />
        <SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=resievil.com'></SCRIPT>
        <br />
        <br />
    </div>
  </div>
  <div id="mainContent1">
    <div id="content1" style="float: right; width: 39%">
      <div id="centbg1">Trailers</div>
      <div id="text">
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="gtembed" width="100%" height="392">	<param name="allowScriptAccess" value="sameDomain" /> 	<param name="allowFullScreen" value="true" /> <param name="movie" value="http://www.gametrailers.com/remote_wrap.php?mid=43481"/> <param name="quality" value="high" /> <embed src="http://www.gametrailers.com/remote_wrap.php?mid=43481" swLiveConnect="true" name="gtembed" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="392"></embed> </object>
        <br />
        <strong>Resident Evil 5 - Trailer</strong> </div>
    </div>
    <div id="content1" style="width: 60%; float: left;">
      <div id="centbg1"><a href="../forumdisplay.php?fid=4" style="color: #ffffff;">Announcements</a></div>
      <div style="padding-top: 5px; padding-right:5px;" align="right"><a href="./syndication.php?fid=4&limit=15"><img style="border: medium none;" src="./images/rss.gif"></img></a></div>
      <div id="text">
        <?php
    
    $query = $db->simple_select('threads', '*', "fid='{$fid1}' ORDER BY tid DESC LIMIT {$limit1}");
    if($db->num_rows($query) > 0)
    {
        while($row = $db->fetch_array($query))
        {
            $query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
            $row2 = $db->fetch_array($query2);
            
            $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
            $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => 'yes', 
                            'filter_badwords' => 'yes', 
                            'allow_mycode' => 'yes', 
                            'allow_smilies' => 'yes',
                            'nl2br' => 'yes', 
                            'me_username' => 'yes',
                            'allow_imgcode' => '1'
                            );
            $message = $parser->parse_message($row2['message'], $options);
            
            echo("<br /><strong><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a></strong> - 
                Posted: {$date} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br /><hr><br />");
            echo("{$message}");
            echo("<div align='right'><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">Comments</a> - (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)</div><hr /><br />");
        }
    }
    else
    {
        echo 'Nothing to display.';
    }

?>
      </div>
    </div>
    <div id="content1" style="margin-bottom: 25px; margin-top: 15px; width: 100%; float: left;">
      <div id="centbg1"><a href="../forumdisplay.php?fid=5" style="color: #ffffff;">News</a></div>
      <div style="padding-top: 5px; padding-right:5px;" align="right"><a href="./syndication.php?fid=5&limit=15"><img style="border: medium none;" src="./images/rss.gif"></img></a></div>
      <div id="text">
        <?php
    
    $query = $db->simple_select('threads', '*', "fid='{$fid2}' ORDER BY tid DESC LIMIT {$limit2}");
    if($db->num_rows($query) > 0)
    {
        while($row = $db->fetch_array($query))
        {
            $query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
            $row2 = $db->fetch_array($query2);
            
            $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
            $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => 'no', 
                            'filter_badwords' => 'yes', 
                            'allow_mycode' => 'yes', 
                            'allow_smilies' => 'yes', 
                            'nl2br' => 'yes', 
                            'me_username' => 'yes',
                            'allow_imgcode' => '1'
                            );
            $message = $parser->parse_message($row2['message'], $options);
            
            echo("<br /><strong><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a></strong> - 
                Posted: {$date} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br /><hr><br />");
            echo("{$message}");
            echo("<div align='right'><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">Comments</a> - (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)</div><hr /><br />");
        }
    }
    else
    {
        echo 'Nothing to display.';
    }

?>
      </div>
    </div>
    <br />
  </div>
  <br class="clearfloat1" />
  <div id="footer1">
    <div style="color: #f5f5f5; line-height: 23px; text-align: right; padding-right: 10px;" id="footerbg1"><strong>Copyright © 2008/09 - Resievil.com</strong></div>
  </div>
</div>
</body>
</html>

News¬

<?php
    $fid = 5; //enter your fid for the announcements block
    $perpage = 10; //enter the number of news to display before pagination kicks in.
    $forumpath = './'; //enter your forum path
    chdir($forumpath);
    define("IN_MYBB", 1);
    require './global.php';
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="Resievil.com" />
<meta name="copyright" content="Copyright Resievil. &copy; resievil.com" />
<meta name="description" content="The official homepage for Resievil, a free, fun community fansite for Resident Evil." />
<meta name="keywords" content="resievil,fansite,resievil.com,forum,community,resident,evil,news,rss,video,degeneration,resident evil 5" />
<link href="twoColHybLtHdr.css" rel="stylesheet" type="text/css" />
<title>Resident Evil Fansite - News</title>
</head>
<body>
<div id="container1">
  <div id="topheader1"> </div>
  <div id="header1"> </div>
  <div class="div_menu">
    <ul class="ul_menu">
      <li><a  href="index.php">Home</a></li>
      <li><a id="a_selected" href="news.php">News</a></li>
      <li><a  href="forum.php">Forum</a></li>
      <li><a  href="video.php">Videos</a></li>
      <?php if($mybb->user['uid'] > 0) {
                        echo "";
                        }
                        else
                        {
                        echo "<li><a  href='./member.php?action=register'>Register!</a></li>";
                        }
                        ?>
    </ul>
  </div>
  <div class="clear"></div>
  <div id="sidebar1">
    <div id="leftbg1">
      <?php
if($mybb->user['uid'] > 0) {
echo "User Box";
}
else
{
echo "Login Box";
}
?>
    </div>
    <div id="left1">
      <div id="text">
        <?php

if($mybb->user['avatar'] != "") {
echo "<a href='/member.php?action=profile&uid=". $mybb->user['uid']."'><img style='border: none;' src='".$mybb->user['avatar']."'/></a><br /><br />";

}

if($mybb->user['uid'] < 0) 
{
echo "<a href='/member.php?action=profile&uid=". $mybb->user['uid']."'>[Your Avatar]</a><br /><br />";
}

if($mybb->user['uid'] > 0) {
echo "<a href='./usercp.php'>User Control Panel</a><br />
      <a href='./private.php'>Private Messages</a><br />
      <a href='./search.php?action=getdaily'>Today's Posts</a><br />
      <a href='./search.php?action=getnew'>New Posts</a><br />
      <a href='./member.php?action=logout&amp;logoutkey=".$mybb->user['logoutkey']."'>Logout</a>";

} 
else 
{

    echo "<form action='./member.php' method='post'>
    <input type=\"hidden\" name=\"my_post_key\" value=\"$mybb->post_code\" />
    Username: <input type='text' name='username' size='18' maxlength='30' /><br />
    Password: <input type='password' name='password' size='18' />
    <input type='hidden' name='action' value='do_login'>
    <input type='hidden' name='url' value='./index.php' />
    <input type='submit' class='submit' name='submit' value='Login' /></form><br><a href='./member.php?action=register'>Not Registered?</a>";
}
?>
      </div>
    </div>
    <div id="leftbg1" style="margin-top: 10px;">Side Menu</div>
    <div id="left1">
      <div id="text"> <strong>Latest Threads</strong>
        <hr/>
        <br />
        <?php
        echo "{$threadlist}";
         ?>
        <br />
        <strong>Ads</strong>
        <hr/>
        <br />
        <a target="_blank" href="http://clubjn.com/forum/">Club JN</a> </div>
        <br />
        <SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=resievil.com'></SCRIPT>
        <br />
        <br />
    </div>
  </div>
  <div id="mainContent1">
    <div id="content1">
      <div id="centbg1"><a href="../forumdisplay.php?fid=5" style="color: #ffffff;">News</a></div>
      <div style="padding-top: 5px; padding-right:5px;" align="right"><a href="./syndication.php?fid=5&limit=15"><img style="border: medium none;" src="./images/rss.gif"></img></a></div>
      <div id="text">
        <?php
    // INCOMING
    $page = intval($mybb->input['page']);

    // COUNT RECORDS
    $query = $db->simple_select("threads", "COUNT(*) AS threads", "fid='{$fid}'");
    $num = $db->fetch_field($query, "threads");

    // PAGING ( MULTI )
    if($page)
    {
        $start = ($page - 1) * $perpage;
    }
    else
    {
        $start = 0;
        $page = 1;
    }
    $multipage = multipage($num, $perpage, $page, $filename."?");

    // GET THREADS
    $query = $db->simple_select("threads", "*", "fid='{$fid}' ORDER BY tid DESC LIMIT $start,$perpage");
        if($db->num_rows($query) > 0)
        {
            while($row = $db->fetch_array($query))
            {
                   $query2 = $db->simple_select('posts', '*', "tid='{$row['tid']}' LIMIT 1");
                $row2 = $db->fetch_array($query2);
            
                   $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
                $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => 'yes', 
                            'filter_badwords' => 'yes', 
                            'allow_mycode' => 'yes', 
                            'allow_smilies' => 'yes', 
                            'nl2br' => 'yes', 
                            'me_username' => 'yes',
                            'allow_imgcode' => '1'
                            );
            $message = $parser->parse_message($row2['message'], $options);
            
                    echo("<br /><strong><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a></strong> - 
                      Posted: {$date} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br /><hr><br />");
                    echo("{$message}");
                    echo("<div align='right'><a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">Comments</a> - (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)</div><hr /><br />");
            }
        echo "<div style=\"float:right\">{$multipage}</div>";
        }
        else
       {
            echo "Nothing to display.";
        }
?>
      </div>
    </div>
    <br />
  </div>
  <br class="clearfloat1" />
  <div id="footer1">
    <div style="color: #f5f5f5; line-height: 23px; text-align: right; padding-right: 10px;" id="footerbg1"><strong>Copyright © 2008/09 - Resievil.com</strong></div>
  </div>
</div>
</body>
</html>
Thank you very much my friend Smile
np Kruzzen, I'm happy to help Smile