It's workin fine now.
I used the same variable name twice
On 26 Feb., 18:51, "Arndtinho" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> how can I use my own helper in an app?
> I have a main_controller, an course_model, an course_helper and a
> global_layout.
>
> Controller: main_controller.php:
> class MainController extends AppController {
>
> var $name = 'Main';
> var $layout = 'global';
> var $helpers= array( 'Course' );
>
> function index() {
>
> $courses = new Course();
> $GLOBALS['courses'] = $courses->findAll();
> }
>
> }
>
> Model: course.php:
> class Course extends AppModel {
>
> var $name = 'Course';
>
> }
>
> Helper: course.php:
> class CourseHelper extends Helper {
>
> function getCourseName( $course_id ) {
>
> # add the code for finding the course name in table course_descr
> return 'Test';
> }
>
> }
>
> View-Layout: global.thtml:
> <table style="margin-left: 10px;">
>
> <?php foreach ( $GLOBALS['courses'] as $course ): ?>
>
> <tr><td><?= $course->getCourseName( $course['Course']
> ['course_descr_id'] ); ?></td></tr>
>
> <?php endforeach; ?>
> </table>
>
> If I start the app I get this error:
> Fatal error: Call to undefined function getCourseName() on a non-
> object
>
> Why this doesn't work?
>
> Arndtinho
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---