hairynuggets
hairynuggets

Reputation: 3311

Switching to Codeigniter HMVC - Undefined functions?

I have setup a fresh install of codeigniter 2x and modular extensions (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home)

It is my first time using HMVC, the decision to move from MVC to HMVC was to give myself more control of my login, admin, and members areas.

I have created my first controller in HMVC like so....

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends MX_Controller {


    function __construct()
    {
        parent::__construct();  
        $this->load->model('Content_model');
    }


    public function index()
    {

        $this->load->view('includes/template'); 
    }
}

and a view like:

<?php echo doctype(); ?>

<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo $pagecontent['seo_title']; ?></title>
         <meta name="description" content="<?php echo $pagecontent['seo_description']; ?>" />
        <meta name="keywords" content="<?php echo $pagecontent['seo_keywords']; ?>" />
        <meta name='robots' content='all' />

        <link rel="icon" type="image/ico" href="<?php echo base_url("images/favicon.png"); ?>" />
        <?php echo link_tag('css/style.css'); ?>
 <script type="text/javascript"  language="javascipt" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
 <script type="text/javascript" language="javascript" src="<?php echo base_url("js/jquery.validate.min.js"); ?>"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url("js/main.js"); ?>"></script>


    </head>
    <body>
        <?php $this->load->view('includes/notify'); ?>

        <div id="topbar">
            <?php $this->load->view('includes/topbar'); ?>

When I try and view the page in my browser I get the following error:

Fatal error: Call to undefined function doctype() in C:\xampp\htdocs\mintfifty\application\modules\site\views\includes\template.php on line 1

The code has worked in all my previous codeigniter (mvc) projects but not (hmvc) why is it not working in HMVC? What am I doing wrong?

Upvotes: 0

Views: 1463

Answers (1)

Vikk
Vikk

Reputation: 3363

This issue is not likely to be caused by HMVC. doctype() function is defined in html helper and it seems that You have not loaded it (Unless you have auto-loaded it). Just load the html helper in your controller and it should work fine.

public function index()
{
    $this->load->helper('html');
    $this->load->view('includes/template'); 
}

Upvotes: 1

Related Questions