Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Module class in view
MaxG
August 2013
Hey,
When i want to use:
(...)
<?php foreach (\Tasks\Tasks::get_all_tasks() as $val){ ?>
<tr>
<td class="primary"><?php echo Lang::get('tasks.possible_tasks.'.$val["alias"].'.translation'); ?></td>
<td><?php echo $val["user"]; ?></td>
<td><?php echo date('Y-m-d', $val["date"]); ?></td>
<td><?php echo date('H:i:s', $val["date"]); ?></td>
<td><span class="label label-<?php if ($val["running"] == 1){ echo 'success">'.Lang::get('tasks.status.'.$val["running"]); }else{ echo 'important">'.Lang::get('tasks.status.'.$val["running"]);} ?> </span></td>
<td>hi</td>
</tr>
<?php } ?>
(...)
The class tasks in modules/tasks/classes/tasks.php is availible.
But I get the following error:
ErrorException [ Error ]: Class 'Tasks\Tasks' not found
hope you can help me! <3
greez
Syntaxlb
August 2013
Accepted Answer
Hi,
Your module is loaded ? ( \Module::load('tasks'); )
Or specify it in your config.php (always_load => module)
MaxG
August 2013
I have loaded the class from the modules config php always_load...
greez
Syntaxlb
August 2013
Accepted Answer
It's work great on my project.
U can access to your module function in a controller ?
MaxG
August 2013
<?php
namespace Tasks;
use Response;
use View;
use Uri;
use Logged_in;
class Controller_Tasks extends \Controller
{
public function before()
{
Logged_in::check();
}
public function action_overview()
{
$data['custom'] = FALSE;
$data['page'] = 'tasks_overview';
return Response::forge(View::forge('parts/main', $data, false));
}
}
modules/tasks/classes/tasks.php
When I want to use the Tasks-class from the view it fails with:
ErrorException [ Error ]: Class 'Tasks\Tasks' not found
Syntaxlb
August 2013
Accepted Answer
Can we see the content of your tasks.php file ?
You have "namespace Tasks;" at the top of your tasks.php file ?
Harro
August 2013
This class is called "Controller_Tasks", so a direct call would be \Tasks\Controller_Tasks ...
And calling a controller directly is a bad idea, so I would suggest looking at your architecture again.
MaxG
August 2013
Forgot the Namespace, thank you!!!
:)
greez
MaxG
August 2013
Forgot the Namespace! <3 Thank you!!
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
August 2013
MaxG
August 2013
Syntaxlb
August 2013