Welcome Guest, Not a member yet? Register   Sign In
Begining CI / Frameworks in General
#2

[eluser]awpti[/eluser]
Howdy.

I have the same type of system.. Here's how it works for me:

/controlers/blog.php

Code:
class Blog extends Controller {

    private $awTitle = 'awpti.org - Home of geeking, PHP and SQL!';
    private $awHeader = 'awpti.org';
    private $awNewsLimit = 3;
    
    function Blog() {
        parent::Controller();
    }

    function index() {
        $data['Title'] = $this->awTitle;
        $data['Header'] = $this->awHeader;

        $query_news = 'SELECT * FROM awNews ORDER BY NewsID DESC LIMIT '.$this->awNewsLimit;
        $data['Query_News'] = $this->db->query($query_news);

        $this->load->view('blog/front', $data);
    }

    function about() {
        $data['Title'] = $this->awTitle.' (About)';
        $data['Header'] = $this->awHeader;

        $this->load->view('blog/about', $data);
    }

} //end class. Duh.

And.. /views/blog/front.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?= $Title; ?&gt;&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
    &lt;meta http-equiv="Content-Language" content="en-us" /&gt;
    &lt;meta http-equiv="imagetoolbar" content="no" /&gt;
    &lt;meta name="MSSmartTagsPreventParsing" content="true" /&gt;
    &lt;meta name="keywords" content="awpti, php, sql, geeking" /&gt;
    &lt;meta name="author" content="Geoff Winans (http://www.awpti.org/)" /&gt;
    &lt;style type="text/css" media="all"&gt;@import "/media/style/style.css";&lt;/style&gt;
    &lt;link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" /&gt;
&lt;/head&gt;

&lt;body&gt;


<div class="content">
    
    <div class="toph"></div>
    <div style="display: none;">&lt;?= $Header; ?&gt;</div>
    <div class="right">
        <div class="title">AWPTI.ORG</div>
        <div class="nav">
        <ul>
            <li><a href="/">HOME</a></li>
            <li><a href="/about/">ABOUT</a></li>
            <li><a href="http://gallery.awpti.org/">GALLERY</a></li>
        </ul>
        </div>

        <h2>Top Links:</h2>
         <ul>
            <li><a href="http://www.galerion.org">galerion.org</a></li>
            <li><a href="http://www.solucija.com">Solucija</a></li>
            <li><a href="http://www.newzbin.com">NewzBin</a></li>
            <li><a href="http://www.google.com/reader/">gReader</a></li>
            <li><a href="http://www.google.com/mail/">gMail</a></li>
         </ul>
        <hr />
        &lt;!--
        <h2>Search</h2>
        &lt;form action="#"&gt;
            &lt;input type="text" value="" class="text" /&gt;
            &lt;input type="submit" value="Go" class="searchbutton" /&gt;
        &lt;/form&gt;
        --&gt;
        <br /><br />
        <hr />
    
        <div class="footer_text">
        &copy; Copyright awpti.org<br />
        Design by: <a href="http://www.free-css-templates.com/" title="Free CSS Templates">David Herreman</a><br />
        &lt;!-- <a href="rss/">RSS Feed</a> | --&gt;<a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a> and <a href="http://validator.w3.org/check?uri=referer">XHTML</a> &lt;!-- | <a href="#">Login</a> --&gt;
        </div>
        
    </div>
    
    <div class="center">
&lt;?php
    foreach($Query_News->result() as $news) {
        echo '<h2>',$news->PostTitle,"</h2>\n";
        echo $news->Content."\n";
        echo '<p class="date">Posted by ',$news->PostBy,' <img src="/media/images/comment.gif" alt="comments" /> <a href="#">Comments (##)</a> <img src="/media/images/timeicon.gif" alt="" /> ',unix_to_human(mysql_to_unix($news->PostTime))."</p><br />\n";
    }
?&gt;
&lt;!--
        <div class="boxad">
            Box for ads or whatever. //Unused.
        </div>
--&gt;

    </div>
    
    
    <div class="footer"> </div>
</div>

&lt;/body&gt;
&lt;/html&gt;

Hope this blob of code helps. If you're looking for a "WHY" explanation, check out the 20 minute long blog video tutorial. It's explained fairly well.


Messages In This Thread
Begining CI / Frameworks in General - by El Forum - 07-03-2007, 10:41 PM
Begining CI / Frameworks in General - by El Forum - 07-03-2007, 11:50 PM
Begining CI / Frameworks in General - by El Forum - 07-04-2007, 01:24 PM
Begining CI / Frameworks in General - by El Forum - 07-04-2007, 06:01 PM
Begining CI / Frameworks in General - by El Forum - 07-04-2007, 06:32 PM
Begining CI / Frameworks in General - by El Forum - 07-04-2007, 06:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB