Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Corss Loading ViewModel Modules Not Work
  • Hello:)

    Probrem With Using "modules" And "viewModels", And "Cross Loading".


    (1) My modules were put here:

    # fuel/modules/blog/classes/controller/index.php
    # fuel/modules/blog/classes/view/index.php
    # fuel/modules/blog/views/index.php

    It's work fine.

    (2) I Added 1 view file for error page.

    # fuel/modules/errors/classes/view/err.php
    # fuel/modules/errors/views/err.php

     #viewmodel code:

     namespace Errors;
     class View_App extends \ViewModel {

      public function view(){ }
     
     }


    (3) My modules with VIEW Cross Load Code is here:

    # fuel/modules/blog/classes/view/index.php

     \Module::load('errors');
     return \View::forge('errors::err');

    It's work fine, too.


    (4) I wont to change VIEW Cross Load to VIEWMODEL Cross Load.
    But not work.

    # fuel/modules/blog/classes/view/index.php

     \Module::load('errors');
     return \ViewModel::forge('errors::err');

    ==> NG
    OutOfBoundsException [ Error ]: ViewModel "Blog\View_Errors::err" could not be found.

     \Module::load('errors');
     return \ViewModel::forge('err');

    ==> NG
    OutOfBoundsException [ Error ]: ViewModel "Blog\View_Err" could not be found.



    How to call cross viewmodel modules?
    Pleade help me...


  • Add test results.

     \Module::load('errors');
     print_R (\Module::loaded());

    ==> "Errors" load success.
     Array (
      [blog] => C:\fuel\app\modules\blog\
      [errors] => C:\fuel\app\modules\errors\
     )

    \Module::load('errors');
    \Errors\View_App::test_method();

     # fuel/modules/errors/views/err.php
     public static function(){ echo "TEST"; }

    ==> Work fine.


  • HarroHarro
    Accepted Answer
    You can't. The Viewmodel doesn't support hardcoded modules.

    And that is not on the roadmap either, calling cross-context is a bad idea, it creates tight coupling between modules, which negates the reason for making stuff modular in the first place.

    If you need something from another module, do an HMVC request to a module controller instead.
  • Harro Verton
    Thank you, I can shift my mind to " HMVC request".
    You're very kind :)

    If you can help me once more, please tell me.
    I wint to do like these:

    $widget = Request::forge('errors/app')->execute();

    I'm using modules and namespace.
    I searched what HMVC request with namespace, but I cannou find...

  • Harro Verton
    Very sorry, It's soluved.

    All is my mistake.
    thank you.

Howdy, Stranger!

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

In this Discussion