Welcome Guest, Not a member yet? Register   Sign In
Loading wrong views in twiggy!
#1

(This post was last modified: 07-24-2015, 04:13 AM by weblogics.)

I'm running codeigniter latest version, with twiggy installed and HMVC. I've had this issue before with no answers and was hoping that someone else could get a view on this in order to get to a resolution. I've tried to contact the guy who developed the twiggy plugin with no results.

When loading partials from other modules twiggy is using the path to my theme folder from the partial I'm trying to load from a category module and not my blog module. This results in the category create.html.twig template being loaded when calling my blog create.html.twig template.

PHP Code:
$this->twiggy->set('categories'Modules::run('category/category_manage/dropdown'));
$this->twiggy->display(); 

I'm expecting the result to return the view from my category module to my blog module and allow this to be included to keep things DRY in my controllers and views.

The dropdown function in my categories controller is:

PHP Code:
$this->twiggy->set('categories'$this->category_model->dropdown('id''name'));
$this->twiggy->display('dropdown'); 

Please note I have also tried:

PHP Code:
$this->twiggy->set('categories'$this->category_model->dropdown('id''name'));
return 
$this->twiggy->render('dropdown'); 

and:

PHP Code:
$this->twiggy->set('categories'$this->category_model->dropdown('id''name'));
$this->twiggy->template('dropdown')->render(); 

With no success

Debugging shows this message whilst calling 'blog/create':

Unable to find template "blog/create.html.twig" (looked into: application/../modules/category/themes/admin, application/themes/admin).

Which suggests the wrong theme location is being targetted when it should be looking in the current module 'blog' in 'themes/admin/blog/create.html.twig'

On further investigation it seems to be this line in the twiggy library:

PHP Code:
if(method_exists($this->CI->router'fetch_module'))
        {
            
$this->_module $this->CI->router->fetch_module();  // <----- This seems to be where the module is set / overwritten in the twiggy library

            // Only if the current page is served from a module do we need to add extra template locations.
            
if(!empty($this->_module))
            {
                
$module_locations Modules::$locations;

                foreach(
$module_locations as $loc => $offset)
                {
                    
/* Only add the template location if the same exists, otherwise
                    you'll need always a directory for your templates, even your module
                    won't use templates */
                    
if ( is_dir($loc $this->_module '/' $this->_config['themes_base_dir'] . $theme) )
                        
$this->_template_locations[] = $loc $this->_module '/' $this->_config['themes_base_dir'] . $theme;
                }
            }
        } 

This piece of code is causing the module to be overridden if you run Modules::run() inside another module, can anyone see a way around this as I would like to use modules to keep things DRY and import views into other modules whilst rendering the full template out.

Any help would be apprecitated.
Reply


Messages In This Thread
Loading wrong views in twiggy! - by weblogics - 07-24-2015, 04:00 AM
RE: Loading wrong views in twiggy! - by mwhitney - 07-24-2015, 06:39 AM
RE: Loading wrong views in twiggy! - by weblogics - 07-24-2015, 08:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB