• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[resolved]Function in controller

#1
[eluser]isabelle[/eluser]
Hy everybody,

On my way to learn code igniter and the mvc coding, i have my really first problem.

I don't paste the model, but this one gets the datas of a website.
In that datas there are the tags, the keywords in fact. (example: http://leweb2.be/Mandellia.html)
These ones are separated by commas and i need to explode them via a function made for that.
I tried to define it in the controller but when i call that function in the view, i have that error:

Code:
Fatal error: Call to undefined function explode_term() in C:\wamp\www\eclipse\annuaire\system\application\views\fiche_view.php on line 56

Is that the moment when i need to create my own libraries?

Thanks in advance for your help,

CONTROLLER

Code:
class Fiche extends Controller{
        function fiche(){
            parent::Controller();
            $this->load->helper('url', 'database');
        }
        function index(){
            $id_website=$this->uri->segment(3);
            
            $this->load->model('fiche_model');
            $data['query']=$this->fiche_model->get_fiche($id_website);
            
            $this->load->view('fiche_view', $data);
        }
        
        function explode_term($terms){
            $list = explode(",", $terms);
            echo count($list);
        }    
    }

VIEW
Code:
<?php
        foreach($query->result() as $row):
            echo '<h1>'.$row->app_name.'</h1>';
            echo '<p><span class="pink">Description :'.$row->app_short_description.'</span><br /><br />';
            echo '<span class="pink">Url :</span> <a href="'.$row->app_url.'" title="'.$row->app_short_description.'">'.$row->app_url.'</a><br /><br />';
            echo '<span class="pink">Description :</span><small>'.$row->app_description.'</small></p><br />';
            echo '<small><span class="pink">Mots-clé :</span><a href="" title="">'.explode_term($row->tags);'</a> |</small></div>';
        endforeach;
    ?&gt;


Messages In This Thread
[resolved]Function in controller - by El Forum - 10-22-2007, 06:25 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 06:32 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 06:35 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 06:48 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 06:59 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 07:08 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 07:11 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 07:11 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 07:31 AM
[resolved]Function in controller - by El Forum - 10-22-2007, 08:06 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.