Welcome Guest, Not a member yet? Register   Sign In
Double Loading of pages issue
#1

[eluser]mephi[/eluser]
Hello,

I'm facing an issue and I can't find the problem to it.

I'm working on a CMS which for Frontend needs to have several types of url's (pages, ports/port-slug,port-slug/excursion-slug and of course normal controllers if exists).

My code is working for the first 3 url types (except controllers) but that's ok for now.

My problem is that when I'm loading a page, no matter of what type of url, in the firebug it shows that the page is loaded twice somehow, second having a # symbol at the end.

I have no clue that is this about, but for sure is not something right.

Doe anyone has a clue what can be the issue ?

I'm using HMVC struncture and Phil's Template library for layouts.
in my routes.php I have the following settings:
Code:
$route['default_controller'] = "pages";
$route['404_override'] = '';
$route['^(:any)'] = "pages/index";

This is my Pages Controller (default one)
Code:
class Pages extends Frontend_Controller {
public function index($slug = '',$slug1 = '')
{
  $args = $this->uri->segment_array();
  $slug = isset($args[1]) ? $args[1] : '';
  $slug1 = isset($args[2]) ? $args[2] : '';
  // is homepage
  if (empty($slug))
  {
   $page = $this->pages_model->get_page('',array('is_homepage'=>'yes'));
   if ($page && $page->num_rows() == 1)
   {
    $page_details = $page->row();
    $data['content'] = $page_details->description;
    $data['meta_keywords'] = $page_details->meta_keywords;
    $data['meta_description'] = $page_details->meta_description;
    $data['title'] = $page_details->title;
    $data['page-template'] = $page_details->page_template;//'page-404';
    
    $this->_show_output($data);
   }
   else
   {
    $this->_show404_output();
   }
  }
  else
  // if we are looking for ports
  if ($slug == 'ports')
  {
   // if no port is selected, redirect to PORTS assigned page
   if ($slug1 == '')
   {
    $page = $this->pages_model->get_page('',array('id'=>$site_settings->ports_page_id));
    if ($page && $page->num_rows() == 1)
    {
     $page_details = $page->row();
     redirect($page_details->slug);
    }
    else
    {
     $this->_show404_output();
    }
   } else
   // slug1 is set, search for a port in db
   if ($slug1 != ''){
    $page = $this->ports_model->get_port('',array('slug'=>$slug1));
    if ($page && $page->num_rows() == 1)
    {
     $page_details = $page->row();
     //redirect($page_details->slug);
     $data['content'] = $page_details->description;
     $data['meta_keywords'] = $page_details->meta_keywords;
     $data['meta_description'] = $page_details->meta_description;
     $data['title'] = $page_details->name;
     $data['page-template'] = $page_details->page_template;//'page-404';
    
     $this->_show_output($data);
    }
    else
    {
     $this->_show404_output();
    }
   }
  }
  else
  // check for pages
  if ($slug != '' && $slug1 == '')
  {
   $page = $this->pages_model->get_page('',array('slug'=>$slug));
   if ($page && $page->num_rows() == 1)
   {
    $page_details = $page->row();
    // test if is homepage remove slug and redirect to base_url
    if ($page_details->is_homepage == 'yes')
     redirect('');
  
    $data['content'] = $page_details->description;
    $data['meta_keywords'] = $page_details->meta_keywords;
    $data['meta_description'] = $page_details->meta_description;
    $data['title'] = $page_details->title;
    $data['page-template'] = $page_details->page_template;//'page-404';
    
    $this->_show_output($data);
   }
   else
   {
    $this->_show404_output();
   }
  }
  else
  // must be excursion  
  if ($slug != '' && $slug1 !=''){
   $page = $this->excursions_model->get_excursion('',array('slug'=>$slug1));
   if ($page && $page->num_rows() == 1) {
    $page_details = $page->row();
    $data['content'] = $page_details->description;
    $data['meta_keywords'] = $page_details->meta_keywords;
    $data['meta_description'] = $page_details->meta_description;
    $data['title'] = $page_details->title;
    $data['page-template'] = $page_details->page_template;//'page-404';
    
    $this->_show_output($data);
    
   }
   else
   {
    $this->_show404_output();
   }
  }
  
}

function _show404_output()
{
  $page_template = 'page-404';
  $data['content'] = '';
  $data['title'] = 'Error 404, Page not found!';
  $this->output->set_status_header('404');
  
  $this->template->build('pages/pages/'.$page_template, $data);
}

function _show_output($data){
  
  if (!empty($data['title'])) $this->template->title($data['title']);
  $page_template = 'page';
  if (!empty($data['page-template'])) $page_template = $data['page-template'];
  
  $this->template->build('pages/pages/'.$page_template, $data);
}
}
#2

[eluser]InsiteFX[/eluser]
Note: Routes will run in the order they are defined. Higher routes will always take precedence over lower ones.
#3

[eluser]mephi[/eluser]
You locked me with your reply man :|

This is my complete list or routing rules. What's the issue?

Code:
$route['default_controller'] = "pages/index";
$route['404_override'] = '';

$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/admin/$2';
$route['admin/login'] = 'auth/login';
$route['admin/logout'] = 'auth/logout';
$route['admin/([a-zA-Z_-]+)'] = '$1/admin/index';

$route['^(:any)'] = "pages/index";
#4

[eluser]mephi[/eluser]
Hey guys, I just found the problem ... it is not from my routing settings which are working great.

The twice loading of pages was caused by the jquery nivoslider packed file. (I have a slider on the page)

I changed from compressed to uncompressed file and seems the issue is solved.




Theme © iAndrew 2016 - Forum software by © MyBB