Welcome Guest, Not a member yet? Register   Sign In
invoke controll from view?
#8

[eluser]diego6616[/eluser]
in news.php (controller):

Code:
function index()
    {
        $this->load->model('NewsModel','newsObj');
        $result['news'] = $this->newsObj->getNews(); // function to retrieve the news
        $result['controller'] = &$this; // pass a reference to $this, that in this context represents the current controller's instance (and the main CI "god" object as well).
        $this->load->view('news', $result);
    }

in view ‘news.php’

Code:
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
foreach ($news as $row)
{
    if($controller->your_method($row->date)) {
      echo $row->chvNewsTitle;
      echo br(1);
    }  
}

I assume your date function will return true if the date is on the expected range, false otherwise.
Hope it helps.


Messages In This Thread
invoke controll from view? - by El Forum - 03-07-2011, 05:28 AM
invoke controll from view? - by El Forum - 03-07-2011, 07:06 AM
invoke controll from view? - by El Forum - 03-07-2011, 07:07 AM
invoke controll from view? - by El Forum - 03-07-2011, 08:02 AM
invoke controll from view? - by El Forum - 03-07-2011, 08:10 AM
invoke controll from view? - by El Forum - 03-07-2011, 03:37 PM
invoke controll from view? - by El Forum - 03-07-2011, 09:22 PM
invoke controll from view? - by El Forum - 03-08-2011, 12:47 AM
invoke controll from view? - by El Forum - 03-08-2011, 12:54 AM
invoke controll from view? - by El Forum - 03-08-2011, 01:47 AM
invoke controll from view? - by El Forum - 03-10-2011, 10:58 PM
invoke controll from view? - by El Forum - 03-11-2011, 08:15 AM
invoke controll from view? - by El Forum - 03-11-2011, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB