Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Loading Module Views to Controller
  • Just a general question about loading views from modules into the controller: If I have a module Example that has a controller:
    class Controller_Example extends \Controller_Template {
    
        public $template = 'example/index';
    
        public function action_index() {
            $this->template->testimonials = Model_Example::get_list();
            $this->template->content = \View::factory('example/index');
        }
    
    }
    

    and
    class Model_Example extends \Model {
    
        protected static $table = 'mytable';
    
        public static function get_list($count = 100)  {
            $result = \Fuel\Core\DB::select('title','content')->from(static::$table)->limit($count)->order_by('title', 'asc')->execute();
            return $result->as_array();
        }
    
    }
    

    When i call this module controller from my main controller I have to use html_entity_decode on the result in the view. Is this correct or am I making a mistake on these calls? Thanks for the help.
    public function action_index()  {
            $data = array( );
            $data[ 'success' ] = Request::factory( 'example/example/index/')->execute();
            $this->response->body = View::factory( 'welcome/index', $data );
    }
    
  • Fuel encodes on output, not on input. So everything you send to your views will be encoded unless you tell it not to.
    public function action_index() { 
        $this->response->body = View::factory( 'welcome/index'); 
        $this->response->body->set('success', Request::factory( 'example/example/index/')->execute(), false);
    }
    
  • Thanks WanWizard, worked like a charm.

Howdy, Stranger!

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

In this Discussion