Problem to extend Fuel Libraries : Fuel_blocks

edited November 2014 in Feature Requests
Hi, i encoutered a problem to extend the class Fuel_blocks. Sorry if it's perhaps more a CI lack of knowledge than Fuel.

I've create in /my_site/fuel/modules/fuel/libraries/MY_blocks.php

MY_blocks.php is someting like

class MY_blocks extends Fuel_blocks {

public $blocks_folder = '_blocks';
protected $module = 'blocks';


public function __construct() {
print('construct called !!!'); // ok work fine construct is called
}


public function render($params, $vars = array(), $check_db = TRUE, $scope = NULL)
{

$this->CI->load->library('parser'); // first problem

etc etc .... the actual render function of Fuel_blocks that i want to customize
------------------
}




}


I Call it this way in a static view

$CI->load->library('MY_blocks');
$CI->my_blocks->render(array('view' => 'block_generic', 'mode' => 'view'));
I have this error :
Fatal error: Call to a member function library() on a non-object in /My_Site/fuel/modules/fuel/libraries/MY_blocks.php on line 103

line 103 is $this->CI->load->library('parser'); , if I comment this one I have other error with line like $this->CI ...

I've read this topic but don't seems so easy for me
http://forum.getfuelcms.com/discussion/1809/how-to-extend-fuel-libraries/p1

Thx for any help, nice day

Comments

  • edited 9:28PM
    Where are you calling that code? If it's in a controller, you can substitute $CI with $this since $CI is just a reference to the controller object. FUEL automatically provides that variable to view files and blocks so you'll often see that in code examples if the code is being used there instead of a controller.
  • edited 9:28PM
    Sorry for inconvenience, i can even reproduce the bug !!

    in a static view i have

    $CI->load->library('MY_Fuel_blocks');
    echo $CI->my_fuel_blocks->render(array('view' => 'a_block', 'mode' => 'view'));

    and Works fine, i think i've just forgot the echo and actually want to die :))
    Sorry again, good week end
Sign In or Register to comment.