开发者

Multiple Web Pages in CodeIgniter

开发者 https://www.devze.com 2023-01-05 16:12 出处:网络
I am having trouble simply making multiple pages with CodeIgniter. For example, I am trying to make a simple About page with codeigniter. So I create an about.php controller and an about_view.php view

I am having trouble simply making multiple pages with CodeIgniter. For example, I am trying to make a simple About page with codeigniter. So I create an about.php controller and an about_view.php view file. However if I were to try and make a link from the home page to "http://miketrottman.com/about" it will go nowhere. I am sure I am fundamentally missing something but I have read and watched example videos I am just spinning my wheels on this project at this point. Here is my home.php controller, let me know if I should post any other code. My site is http://miketrottman.com. I am new to the CodeIgniter scene an any help is much appreciated!

home.php in Controller directory '

class Home extends Controller {

function Home()
{
    parent::Controller();
}

function index()
{
    //Load Extensions
    $this->load->database();
    $this->load->library('session');

    //Include these basics everytime the home page is loaded
    $data['pageTitle'] = "Trottman's Blog";
    $data['title'] = "Trottman's Blog Title";
    $data['heading'] = "Trottman's Blog Heading";

    //Load Proper CSS for users browser
    $data['css'] = $this->getCSS();

    //Load the Blog Model
    $this->load->model('blog_model');
开发者_如何学Go
    //Load the Blog Entries
    $data['blog'] = $this->blog_model->getBlogEntries();

    $data['blog_comments'] = $this->blog_model->getBlogCommentEntries();

    //

    //Load all of this information into the home_view Page
    $this->load->view('home_view', $data);
}

function getCSS()
{
    //Load user_agent library to pull user's browser information
    $this->load->library('user_agent');
    //Agent is now the users browser
    $agent = $this->agent->browser();
    //According to the users browser, this is what the CSS should be
    if ($agent == 'Internet Explorer')
    {
        $cssFile = "ieStyle.css";
    }
    else
    {
        $cssFile = "style.css";
    }

    return $cssFile;
}

}?> '


And I am dumb, my whole problem was I was trying to go to /about and what I should have been doing is http://miketrottman.com/index.php/about because I have yet to remove the index.php in my URIs. So I guess, thanks Stack overflow for creating an outlet for my ignorance, perhaps others can learn from my mistake then!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号