Welcome Guest, Not a member yet? Register   Sign In
how is add subject blog to url with _remap and .htaccess? (dynamic)
#2

[eluser]osci[/eluser]
This is my way of remap in this scenario
In remap I check for existence of title - no spaces or dissallowed chars, use url_title(), and if error show 404.

Code:
function __construct()
   {
      parent::__construct();
      $this->load->model('page_model');
   }

   public function _remap($method, $params = array())
   {
      switch ($method)
      {  //I disallow ie do_ in the start of the title, to have other routes to controller
         case 'do_stuff':
         case 'do_other':
            if (method_exists($this, $method))
            {
               return call_user_func_array(array($this, $method), $params);
            }
            break;
         case 'index':
            return $this->index('home'); //my default page slug
         default:
            $query = $this->page_model->get_content($method)->row();
            if ($query)
            {
               return $this->index($method);
            }
            break;
      }
      show_404();
   }

   function index($slug)
   {
      $query = $this->page_model->get_content($slug)->row();
      if (!$query) {show_404();}
      // rest of code here
   }


Messages In This Thread
how is add subject blog to url with _remap and .htaccess? (dynamic) - by El Forum - 06-11-2011, 05:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB