ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

HMVC problem loading views

November 11, 2010 7:20am

Subscribe [6]
  • #16 / Dec 08, 2010 7:06pm

    Timothy_

    100 posts

    Hello,

    Thanks for replying. Unfortunately this doesn’t work in any of my modules. Only View partials are affected. Modules themselves, when accessed directly, work correctly.

    It seems there is a fundamental problem with my HMVC setup, but I don’t see how as I followed the instructions to the letter.

    Could someone please help me debug this, I don’t know where to start.

    I am using CI 1.7.2

    Thanks,

    Tim

  • #17 / Dec 09, 2010 3:15am

    wiredesignz

    2882 posts

    @Timothy_, Yes I have checked and this code works with CI 1.7.2 also.

    Turn logging on in config.php and see if modules::run() generates an error.

    EDIT:
    Your application may also be failing inside a module due to other problems without visible errors being shown because modules::run() buffers the output.

  • #18 / Dec 16, 2010 7:29pm

    Timothy_

    100 posts

    @Timothy_, Yes I have checked and this code works with CI 1.7.2 also.

    Turn logging on in config.php and see if modules::run() generates an error.

    EDIT:
    Your application may also be failing inside a module due to other problems without visible errors being shown because modules::run() buffers the output.

    Sorry about the delay in getting back to you.

    No errors are displayed at all when the white screen of death is generated.

    Turning on debugging shows that all my views are loading correctly and the final output is sent to the browser with no problems.

    Why on earth is

    <?php echo modules::run('invoices'); ?>

    causing the white screen???

    There is nothing fancy about my installation.

    Here is my config autoload:

    $autoload['libraries'] = array('database', 'session', 'ion_auth', 'form_validation', 'template',);

    Removing the template library does not fix the problem.

    Tim

  • #19 / Dec 21, 2010 7:08pm

    sukrit

    1 posts

    Hi wiredesignz
    I got a big problem with HMVC partial view.

    I create a module named ‘form’ have 3 controllers
    and ‘test’ controller in application folder (Not in module)

    form     -> Display and setup form page
    ckeditor -> Ckeditor (a RichText Editor) display
    uploadify -> Uploadify (Flash base uploader) display

    First ‘test’ controller load view named ‘test_view’
    Here is ‘test_view’

    <?php echo html_begin();?>
    <?php echo display_form("testform");?>
    <?php echo html_end();?>

    html_begin() return HTML head content (Javascrip,css,meta etc.) and <body>
    display_form() work only called Modules::run(“form/display”); to display form
    html_end() return </body></html>

    and then form/display load view named ‘formpage’
    here is ‘formpage’

    <?php echo $form_open;?>
    
    <!--Begin validate errors-->
    <?php for($i=0 ;$i < count($errormsgs); $i++):?>
    <?php echo $errormsgs[$i];?>
    <?php endfor;?>
    <!--End validate errors-->
    
    <!--Begin text input-->
    <label><?php echo $form_normal_text_lb;?></label>
    
    <?php if($form_normal_text_err):?>
    <?php echo $form_normal_text_err;?>
    
    <?php endif;?>
    <input type='text' name='<?php echo $form_normal_text_nm;?>' value='<?php echo $form_normal_text_val;?>' <?php echo $form_normal_text_mod;?>/><br>
    <!--End text input-->
    
    <!--Begin richtext input-->
    <label><?php echo $form_text_lb;?></label>
    
    <?php if($form_text_err):?>
    <?php echo $form_text_err;?>
    
    <?php endif;?>
    <?php echo ckeditor($form_text_nm,$form_text_val);?>
    
    <!--End richtext input-->
    
    <!--Begin checkbox input-->
    <input type='checkbox' name='<?php echo $form_check_nm;?>' value='<?php echo $form_check_val;?>' <?php echo $form_check_mod;?>><?php echo $form_check_lb;?>
    
    <!--End checkbox input-->
    
    <!--Begin select selector-->
    <label><?php echo $form_selector_lb;?></label>
    
    <?php if($form_selector_err):?>
    <?php echo $form_selector_err;?>
    
    <?php endif;?>
    <select name='<?php echo $form_selector_nm;?>' <?php echo $form_selector_mod;?>>
    <?php foreach($form_selector_opt as $opt):?>
    <option value='<?php echo $opt->value;?>' <?php echo $opt->flag;?>><?php echo $opt->label;?></option>
    <?php endforeach;?>
    </select>
    
    <!--End select selector-->
    
    <!--Begin flash uploader-->
    <label><?php echo $form_file_lb;?></label>
    
    <?php if($form_file_err):?>
    <?php echo $form_file_err;?>
    
    <?php endif;?>
    <?php echo uploadify($form_file_nm);?>
    
    <!--End flash uploader-->
    
    <!--Display 'test_display'-->
    <?php echo $test_display_lb;?> : <?php echo $test_display_val;?>
    
    
    <input type='submit' value='<?php echo $submit_button;?>'>
    <?php echo $form_close;?>

    Now you can see
    uploadify(); and ckeditor(); theses function just call Modules::run(“uploadify/display”); and Modules::run(“ckeditor/display”);

    From the sample of code it should display like this(View source form browser)

    <!---html_begin()-->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
      <head>
       (Html header content,meta tag,script and css inclusion)
      </head>
      <body>
    <!---html_begin()-->
    <form ...>
       (input tag and other HTML content for the form)
       ...
       ..
       .
    </form…>
    <!---html_end()-->
    </body>
    </html>
    <!---html_end()-->

    But final output see like this..

    <form ...>
       (input tag and other HTML content for the form)
       ...
       ..
       .
    </form…>
    
    <!---FROM html_begin()-->
    <html>
      <head>
       (Html header content,meta tag,script and css inclusion)
      </head>
      <body>
    <!---FROM html_begin()-->
    
    <!---FROM html_end()-->
    </body>
    </html>
    <!---FROM html_end()-->

    I don’t know why and i search in forum but not found any thread about it.
    I wonder problem may come from calling Modules::Run() in Modules::Run().
    I mean first loading ‘test_view’ view cause Modules::Run(“form/display”) called
    and then form/display load ‘formpage’ view cause Modules::Run(“ckeditor/display”) Modules::Run(“uploadify/display”)called finally both ckeditor/display and ckeditor/display
    load its own view.

    How to fix this problem. Please help me. :down: :down: :down:
    Thank in advance!!! 

    PS. Sorry for my bad english. I’m Thai

  • #20 / Jan 10, 2011 6:36pm

    Josh Holloway

    41 posts

    Hi All,

    I’ve been playing around with Codeigniter and HMVC.

    I can confirm I also have the same issue as above.

    I have a template.php file which contains:

    <?php
    
    $this->load->view('includes/header');
    
    $this->load->view($content);
    
    $this->load->view('includes/footer');
    
    /* End of file template.php */

    Example controller:

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Articles extends MX_Controller {
        
        function __construct()
        {
            parent::__construct();
            $this->load->model('Articles_model');
        }
        
        //shows latest 5 Articles
        function index()
        {
            $data['content'] = ('articles');
            $data['title'] = ('Article');
            $data['articles'] = $this->Articles_model->fetchArticlesOrder('articles', 'date_created', '5');
            $this->load->view('includes/template', $data);
        }
        
        function articles_sidebar()
        {
            $data['articles'] = $this->Articles_model->fetchArticlesOrder('articles', 'date_created', '5');
            $this->load->view('articles_sidebar', $data);
        }
        
        function archives_sidebar()
        {
            $data['archives'] = $this->Articles_model->fetchArchives('articles', 'date_created', '5');
            $this->load->view('archives_sidebar', $data);
        }
    }
    
    /* End of file articles.php */

    The view for my index() function has a

    $this->load->view('sidebar');

    which is below:

    <!-- start sidebars -->
    <div id="sidebar" class="sidebar-large">
        <ul>
            <li>
                <h2>Search</h2>
    <p>            <ul><br />
                    <?php echo form_open('search');?><br />
                        <?php echo form_input('search_articles');?><br />
                        <?php echo form_submit('search_submit', 'Search!');?><br />
                    <?php echo form_close();?><br />
                </ul><br />
            </li><br />
        </ul><br />
    </div></p>
    
    <p><div id="sidebar1" class="sidebar"><br />
        <ul><br />
            <li><br />
                <?php echo modules::run('articles/articles_sidebar'); ?><br />
            </li><br />
            <li><br />
                <?php echo modules::run('articles/archives_sidebar'); ?><br />
            </li><br />
        </ul><br />
    </div><br />
    <!-- end sidebar 1 --><br />
    <div id="sidebar2" class="sidebar"><br />
        <ul><br />
            <li><br />
                <?php echo modules::run('categories/categories_sidebar'); ?><br />
            </li><br />
        </ul><br />
    </div><br />
    <!-- end sidebars -->

    Which contains the following:

    <?php echo modules::run('articles/archives_sidebar'); ?>

    The controller executes correctly but the page structure is lost.

    simply put, the view files are no longer called in the order of:

    <?php
    
    $this->load->view('includes/header');
    
    $this->load->view($content);
    
    $this->load->view('includes/footer');
    
    /* End of file template.php */

    Any advice/ assistance would be appreciated - I’m looking to learn CodeIgniter and hopefully be able to offer advice in the future 😊

  • #21 / Jul 23, 2011 7:04pm

    Came across this issue and gave me some difficulty. I didn’t realize the originating controller (application/controllers/*.*) needed to be modified to extend the MX_Controller as well as the controllers located in the modules folder. Now the partial views play nicely.

  • #22 / Aug 19, 2011 6:58am

    broncha

    9 posts

    Hi,

    I am getting this error when I extend the controller to MX_Controller
    Here is my controller controller

    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    
    class Front extends MX_Controller
    {
        public function __construct()
        {
            parent::__construct();
        }
        
        public function index()
        {
            $this->load->view('outletlocator/front/modmap');
        }
    }

    I get the following error
    Fatal error: Cannot redeclare class CI in C:\xampp\htdocs\sbi-web\application\third_party\MX\Base.php on line 57

    When I extend it to CI_Controller it works.
    Before, I was getting “File could not be located” error even when I extended it to CI_Controller, and this solved it.

    $this->load->view('module_name/view_name');
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases