Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Phil Sturgeon Codeigniter Template Library port to Fuel
  • I have created a template package from Phil Sturgeon Codeigniter Library. git://github.com/stevemo/fuel-template.git Feedback is welcome and appreciated.
  • I'm working on a package that will provide full theme, template and widget support, including support for chrome for both widgets and template area's. It will also allow you to query the template from the template, for example to check if there are widgets defined for an area (so you can switch between 2 and 3 column layouts for example). It will also allow you to overload app or module views in your template, in case a template needs to visually alter the output of a controller. The idea is to create a flexible templating system that works a bit (from the functional level) as Joomla's.
  • Hi, @stevemo - thanks a lot for the example.. it helps me (and i think the other people, too) to understand how is it working in fuel.
    I tested with the last stable version 1.0.1.
    @WanWizard - sounds nice :) but the overload from modules view is as i'm looking right already integrated with themes - or what do you mean? Also the 2 or 3 column layout.. i think the current implementation of layouts is good enough or what do you mean with it? ---
    EDIT - 2011-10-19 - Test implementation
    Here a working demo with fuelphp 1.1 and the template library Module Tutorial (Optional): the simple module tutorial from:
    * http://samitrimal.com.np/2011/07/19/creating-the-a-module-in-fuelphp
    Source (Required): FuelPHP with template library:
    * https://github.com/stevemo/Fuel-Template-example Modificated Files from the Tutorial (Required):
    * http://db.tt/IlWD35vR
    Maybe it helps someone :) And to use the template library in the views, you can use this code
    <?php echo \Template::forge()->build('view_file'); ?>
    
    --- EDIT - 20.10.2011
    I tested the overwrite functionality for the title and it doesn't work as defined in the original template library.
    Is there any solution? Thanks alot!

    Greets
    Marcus
  • Hi, I tested the template package and there are some errors and I was a bit unsure about the implementation.
    I become the following error message when I try to implement the welcome controller
    ErrorException [ Error ]: Call to undefined method Fuel\Core\View::forge()
    PKGPATH/template/classes/template.php @ line 98
    
    93            $that = new static();
    94            $config = \Config::get('template', array());
    95            $config = \Arr::merge($config, $custom);
    96
    97            $that->initialize($config);
    98            $that->view = \View::forge();
    99
    100            static::$_instance = $that;
    101        }
    102
    103        return static::$_instance;
    
    

    when I change the \View::forge() to \View::factory() i become the following error message:
    ErrorException [ Error ]: Call to undefined method stdClass::body()
    DOCROOT/index.php @ line 47
    
    42$response = Request::factory()->execute()->response();
    43
    44// This will add the execution time and memory usage to the output.
    45// Comment this out if you don't use it.
    46$bm = Profiler::app_total();
    47$response->body(str_replace(array('&#123;exec_time}', '&#123;mem_usage}'), array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)), $response->body()));
    48
    49$response->send(true);
    50
    51// Fire off the shutdown event
    52Event::shutdown();
    
    
    Now i don't know whats the problem.. maybe you can help me... my welcome.php is the following:
    class Controller_Welcome extends Template &#123; 
        
         
            
        public function __construct() &#123;
            $this->template = Template::forge();
        } 
            
        
            
            /** 
             * The index action. 
             * 
             * @access public 
             * @return void 
             */ 
        
        public function action_index() &#123; 
            $this->response->body = $this->template->build('welcome/index'); 
            
        }
    
    Also i modified the __construct() function in /fuel/packages/template/classes/template.php from
    final private function __construct() &#123;}
    

    to
    private function __construct() &#123;}
    

    This was needed to "overwrite" the function with my welcome.php I don't know other method to implement the
    $this->template = Template::forge();
    

    And sorry about that, but the documentation in your git was not very useful ... :-(
    But thanks a lot for sharing and your help.
    Greets from Germany
    Marcus
  • Hi Germany Marcus, The doc should be ready someday ;-) I have put a working example on my github. It will be easier like this them putting lot's of code here! https://github.com/stevemo/Fuel-Template-example p.s. Forgot to mention that the package is intended to work with fuel 1.1 DEV

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion