Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can ViewModel object use function set_global() ?
  • Hello, I want to confirm if function set_global is also able to use on ViewModel?

    Because when I change my view object to ViewModel, the function set_global return error.

    Here is the code :

    $this->template->set_global('post', $post, false);

    returns error : 

    ErrorException [ Fatal Error ]:
    Call to undefined method Admin\View_Template::set_global()


    I need help. Thank you so much.
  • HarroHarro
    Accepted Answer
    The Viewmodel itself does not support set_global(). A Viewmodel is a class, global scope should be avoided (even when using views, it's a bad idea and points to design flaws).

    If you insist, you can use get_view() to get the Viewmodel's View object, and call set_global() on that.
  • Yes I too feel that set_global is should not be used,

    but it's strange that I see the practice is used on generated admin page from oil, that's why I think this is recommended from the developer.
  • You have a point, the generation code is now 3 years old, and in need of an overhaul.

    Since Fuel v2 will get a completely rewritten oil environment, we felt we shouldn't spend much time on the existing code.

Howdy, Stranger!

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

In this Discussion