function index routing ??? don't know there. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: function index routing ??? don't know there. (/showthread.php?tid=54690) |
function index routing ??? don't know there. - El Forum - 09-20-2012 [eluser]Alex Florea[/eluser] Hi. I am begginer in CI. I have this code for controler pages.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Pages extends CI_Controller { public function __construct() { parent::__construct(); } function index() { redirect(base_url()); } function eveniments() { $data['evenimente'] = $this->pages_model->get_eveniments(); $this->template->page_view($data); } function agenda_culturala() { $data['agenda_culturala'] = $this->pages_model->get_agenda_culturala(); $this->template->page_view($data); } } ?> and this code for models page_model.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Pages_model extends CI_Model { function get_menu() { $query = $this->db->get('menu'); return $query->result_array(); } function get_agenda_culturala() { $this->db->order_by('id','desc'); $this->db->where('is_enable','1'); $query = $this->db->get('agenda_culturala'); return $query->result_array(); } function get_eveniments() { $this->db->where('is_enable','1'); $query = $this->db->get('evenimente'); return $query->result_array(); } } ?> in library i use template.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Template { function page_view ($data) { $CI =& get_instance(); ... $CI->load->view('rightblock-evenimente_view',$data); ... $CI->load->view('rightblock-agenda-culturala_view',$data); ... } } ?> in config.php i have: $config['base_url'] = 'http://www.StarMagazin.md/'; and routers.php : $route['default_controller'] = "pages"; $route['404_override'] = ''; Now, in browser (firefox for ex.) i have this error: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. If i put this: $data['evenimente'] = $this->pages_model->get_eveniments(); $this->template->page_view($data); and this: $data['agenda_culturala'] = $this->pages_model->get_agenda_culturala(); $this->template->page_view($data); inside function index and delet redirect(base_url()); it work but only first of this. .htaccess RewriteEngine on RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js) RewriteRule ^(.*)$ /index.php?/$1 [L] Can somebady help me. Sorry for my english. function index routing ??? don't know there. - El Forum - 09-20-2012 [eluser]Alex Florea[/eluser] I resolve my problem. I change my code and now work. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Pages extends CI_Controller { public function __construct() { parent::__construct(); } function index() { $data['agenda_culturala'] = $this->pages_model->get_agenda_culturala(); $data['evenimente'] = $this->pages_model->get_eveniments(); $this->template->page_view($data); } } ?> |