Welcome Guest, Not a member yet? Register   Sign In
modules::run in view problem
#1

[eluser]Webjema[/eluser]
Hello.
About 2 hours looking for a solution, but without result (wiki and forum studied).

So, I have module [app/modules/mainpage/controllers/mainpage.php]

Code:
class Mainpage extends MX_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $this->load->view('mainpage_page');
    }
}

please note:
class Mainpage extends MX_Controller

The view [app/modules/mainpage/views/mainpage_page.php]

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Welcome&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;

<h1>Mainpage</h1>

&lt;?php echo modules::run('welcome/welcome'); ?&gt;

&lt;/body&gt;
&lt;/html&gt;

And I have module [app/modules/welcome/controllers/welcome.php] with view [app/modules/welcome/views/welcome_page.php]

But my page has only "<h1>Mainpage</h1>" output. No welcome view inside. No errors.
What is wrong?
I tried:

Code:
&lt;?php echo modules::run('welcome/welcome'); ?&gt;
&lt;?php echo modules::run('welcome/welcome/index'); ?&gt;
&lt;?php echo modules::run('welcome/welcome/index', 1); ?&gt;
&lt;?php echo Modules::run('welcome/welcome'); ?&gt;

No results.

In browser http://domain.com/welcome/welcome works fine.

Please, help run it.
#2

[eluser]osci[/eluser]
Code:
modules::run('welcome');

//or for another method

modules::run('welcome/another');
#3

[eluser]wiredesignz[/eluser]
The module controller must extend MX_Controller if you use HMVC features. Calls to run a controller which has the same name as it's module only requires the name once ie: modules::run('welcome').
#4

[eluser]Webjema[/eluser]
Thank you!
Code:
modules::run('welcome');
works!
#5

[eluser]osci[/eluser]
[quote author="Webjema" date="1308366993"]Thank you!
Code:
modules::run('welcome');
works![/quote]

wiredesignz explained why though. You should read his post carefully to understand and not just say works.
#6

[eluser]Webjema[/eluser]
BUT
I tried run another big module and no results.
How I can debug this process (modules::run)?
It is silent Sad
#7

[eluser]Webjema[/eluser]
[quote author="osci" date="1308367283"]

wiredesignz explained why though. You should read his post carefully to understand and not just say works.[/quote]

I've do =)

My first post. I have made focus on "extends MX_Controller". And I've understand about the same name of controller and module.
I've missed something?
#8

[eluser]osci[/eluser]
for a start enable error reporting (enabled by default in reactor if development mode)
go in config.php and set logtreshold='2'
run your code
check your application/log files for errors

If you want more set a debugger like xdebug (google for how to) and watch.

Edit:
Quote:I’ve missed something?
Maybe it has to do with my local time and me being tired. No offence.
#9

[eluser]Webjema[/eluser]
[quote author="osci" date="1308367615"]for a start enable error reporting (enabled by default in reactor if development mode)
go in config.php and set logtreshold='2'
run your code
check your application/log files for errors
[/quote]

Great!
So logs:

Code:
DEBUG - 2011-06-18 01:30:03 --&gt; File loaded: app_ci_folder/modules/welcome/views/welcome_message.php
!!!! ERROR - 2011-06-18 01:30:03 --&gt; Module controller failed to run: account/sign_in
DEBUG - 2011-06-18 01:30:03 --&gt; File loaded: app_ci_folder/modules/mainpage/views/mainpage_page.php
DEBUG - 2011-06-18 01:30:03 --&gt; Final output sent to browser
DEBUG - 2011-06-18 01:30:03 --&gt; Total execution time: 0.4575
DEBUG - 2011-06-18 01:30:03 --&gt; Config Class Initialized
DEBUG - 2011-06-18 01:30:03 --&gt; Hooks Class Initialized
DEBUG - 2011-06-18 01:30:03 --&gt; Utf8 Class Initialized
DEBUG - 2011-06-18 01:30:03 --&gt; UTF-8 Support Enabled
DEBUG - 2011-06-18 01:30:03 --&gt; URI Class Initialized
DEBUG - 2011-06-18 01:30:03 --&gt; Router Class Initialized
!!!! ERROR - 2011-06-18 01:30:03 --&gt; 404 Page Not Found --&gt;

The problem:
domain.com/account/sign_in - works.
But calling
Code:
&lt;?php echo modules::run('account/sign_in'); ?&gt;
does not work.
Some restrictions for called modules?
Why Module controller failed to run: account/sign_in ?
#10

[eluser]osci[/eluser]
Is account extending MX?
Is your loader correct?
Do you have a custom MY_Loader?

you can always use in your code
Code:
log_message('debug','Your message');
wherever you want to notice something, like if it reaches the function, a value you want to check etc.




Theme © iAndrew 2016 - Forum software by © MyBB