标题和页脚没有出现

时间:2014-02-24 02:34:09

标签: php templates php-include

因此,通过一些帮助,我能够在本地启动并运行我的第一个mvc框架。现在我已经把它放在服务器上了,我没有运气。我认为这是一个配置问题,但我似乎无法弄明白。

Here's a Gif of what it should look like on the server but this is running it locally.

当我直接进入远程路径时为什么没有出现?即:


的config.php

<?php

    include_once 'load.php';

    // Local
    // define ('URL_ROOT', 'http://localhost/');

    // Remote
    define ('URL_ROOT', 'http://tomcat.cit.ipui.edu/alecory/Spring-2014/Assignment%202/');

    // define ('URI', $_SERVER['REQUEST_URI']);
    // Outputs for:
    //    Local  = /register                                        
    //    Remote = /alecory/Spring-2014/CIT-31300/Assignment%202/views/register.php
    define('URI', '/register'); // <= this is where I could set it myself and 
                                    # it would reroute the URL from
                                    # /Assignment%202/views/register.php   To         
                                    # /Assignment%202/ 
                                    # (only showing /Assignment%202/ in the URL)

    define ('DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
    //    Local  = /Applications/MAMP/htdocs/CIT-31300/Assignment 2
    //    Remote = /var/www/                       

?>

Controller.php这样

<?php 

/**
* Controller
* 
* Description: Basically tells the system what to do and in what order
*/
class Controller
{
    public $load;
    public $model;

    function __construct()
    {
        // Make
        $this->load  = new Load();
        $this->model = new Model();

        // Set the $page = current view/page
        $page = ltrim(URI, '/');

        // Set default page to index
        if (empty($page))
        {
            $page = 'index';
        }

        // Load the Pages
        if (method_exists($this, $page))
        {
            // die(get_include_path());
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->$page();
            require_once DOC_ROOT . '/views/inc/footer.php';
        } 
        else
        {
            require_once DOC_ROOT . '/views/inc/header.php';
            $this->notFound();
            require_once DOC_ROOT . '/views/inc/footer.php';
        }

    }

    // Functions to load the various views
    function index()
    {
        // $data = $this->model->my_user_info();
        $this->load->view('myview.php', $data); 
    }

    // function header()
    // {
    //  $this->load->view('header.php', $data);
    // }

    // function footer()
    // {
    //  $this->load->view('footer.php' $data);
    // }

    function login()
    {
        $this->load->view('login.php', $data); 
    }

    function register()
    {
        $this->load->view('register.php', $data);
    }

    function notFound()
    {
        die('not found');
    }
}

?>

0 个答案:

没有答案