passing variable to view, kohana 3.3 not working, Undefined variable: -


i have stupid question... why if pass e variable view browser return me undefined variable: ? clone first method (for ads, same procedure). ads work, , category not work, stupid, why? show little application

my controller:

<?php defined('syspath') or die('no direct script access.');  class controller_ads extends controller_template {      public $template = 'template';      // function indes ads     public function action_index()     {         $ads = orm::factory('ads')->find_all(); // load object inside ads table          $view = new view('ads/index');  // load view/ads/index.php         $view->set('ads', $ads);        // set 'ads' object view          $this->template->set('content', $view);     }      // view single ads     public function action_single()     {         $id = $this->request->param('id');         $record = orm::factory('ads')         ->where('id_ads', '=', $id)         ->find();          $view = new view('ads/single');         $view->set('ads', $record);                   $this->template->set('content', $view);     }      public function action_category()     {         $category = orm::factory('category')->find_all();           $view = new view('ads/index');           $view->set('category', $category);                $this->template->set('content', $view);     }  } // end ads 

my interest view (ads/index.php)

    <?php foreach ($ads $obj) : ?>         <h3><?php echo html::anchor('/ads/single/'.$obj->id_ads, $obj->title_ads); ?></h3>         <p><?php echo $obj->description_ads; ?></p>         <p>autore: <?php echo $obj->author_ads; ?> || creato il <?php echo $obj->date_ads; ?> || categoria: <?php echo html::anchor('#', $obj->category->category_name); ?></p>     <?php endforeach; ?> <?php foreach ($category $obj) : ?>     <?php echo $obj->id; ?> <?php endforeach; ?> 

the error in browser

errorexception [ notice ]: undefined variable: category 

why category ?? , not ads?

only 1 of action functions gets run, means in action_index() $ads variable being set not $category. , in action_category() $category variable being set not $ads.

if expect use of variables, should make ads/category.php view , use in action_category() function, , remove references $ads in view.

also seem expecting action_category() function running, based on error seeing, running action_index(). check routes find out why.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -