Welcome Guest, Not a member yet? Register   Sign In
Repeating, my own function, how?
#1

[eluser]Gewa[/eluser]
Hi, I am making a web-site , and I liked so much CI. Thank you guys for this excellent tool
Please advice such thing. In each controller, in constructor place I am putting such code



Code:
class Content extends Controller {



    function Content() {

        parent::Controller();
             $this->load->scaffolding('content');
          
       header("Content-Type: text/html; charset=UTF-8");
         $this->load->helper('date');



                          $lang= $this->config->item('language_abbr');

                          $query=$this->db->query("SELECT  * from `top_menu` ");

                            $data['top_menu']="";






                           if ($query->num_rows() > 0)
                     {
                          foreach ($query->result_array() as $row)
                        {



                             $data['top_menu'] .="<a href=\"/$lang".$row['link']."\" class=\"menusmall\">".$row[$lang]."</a>  |";
                            }
                         }







                     $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
                       $time = time();
                       $data['zhamanak']=mdate($datestring, $time);
                     $this->load->view('catalog_header',$data);


                         $data['cat_menu']="";
                     $query=$this->db->query("SELECT  * from `cats` WHERE `parent`='lokale' ORDER BY `order`ASC");

                           if ($query->num_rows() > 0)
                     {
                          foreach ($query->result_array() as $row)
                        {

                                if($row['image']==NULL){
                                    $row['image']="ar2.gif";

                                   }


                             $data['cat_menu'] .="<td height=\"30\" width=\"14%\">
                             <img src=\"/images/".$row['image']."\" align=\"absmiddle\">&nbsp;&nbsp;&nbsp;
                                           </td>
                                  <td height=\"20\" width=\"86%\">
                  <div align=\"left\"><a href=\"/$lang/catalog/category/".$row['alias'] ."\"><span class=\"cat\">".$row[$lang]."</span></a><br>
                  </div>
                </td>  </tr><tr> ";
                            }
                         }


               $this->load->view('catalog_menu',$data);




    }

Which displays Header, Left Peace of web-site with left menu....
Can you tell me the way, how can I make header() function or something like $this->bla-bla->header() that can i put once, instead of this huge code each time?
Where to create this function, and where to put... thanks


Messages In This Thread
Repeating, my own function, how? - by El Forum - 05-13-2008, 09:52 AM
Repeating, my own function, how? - by El Forum - 05-13-2008, 11:08 AM
Repeating, my own function, how? - by El Forum - 05-15-2008, 07:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB