El Forum
10-12-2008, 11:46 AM
[eluser]rt30000[/eluser]
I've spent some time trying to get this project halfway working to show my issues better than I can translate:
Here is the test URL: CI Project Link
As you can see, I just cannot figure out URLs or URIs. I have to use "index.php/page/index/4" (where 4 is the $id of the page to display) rather than a more friendly url. You can click through the pages, all the top level ones are there. The home page, because it has no $id (just goes straight to default controller "page") throws two errors. Ideally, I would like more clear urls and remove the index.php. I tried using .htaccess but I think my server is not accepting it. Is that the first step I need to solve?
I really appreciate any help you can lend me...this is my first stab at MVC. Everything on those pages is based off a single template (with sub views), a model and the Page controller. I think i'm beginning to understand the basic concept.
Here is my controller just in case it helps.
THANKS! rob
I've spent some time trying to get this project halfway working to show my issues better than I can translate:
Here is the test URL: CI Project Link
As you can see, I just cannot figure out URLs or URIs. I have to use "index.php/page/index/4" (where 4 is the $id of the page to display) rather than a more friendly url. You can click through the pages, all the top level ones are there. The home page, because it has no $id (just goes straight to default controller "page") throws two errors. Ideally, I would like more clear urls and remove the index.php. I tried using .htaccess but I think my server is not accepting it. Is that the first step I need to solve?
I really appreciate any help you can lend me...this is my first stab at MVC. Everything on those pages is based off a single template (with sub views), a model and the Page controller. I think i'm beginning to understand the basic concept.
Here is my controller just in case it helps.
Code:
<?php
class Page extends Controller {
function Page()
{
parent::Controller();
$this->load->model('page_model');
}
function index($id)
{
/* Determine which page this is by using supplied id... */
if (!$id) $id=1;
/* Load necessary data for template */
$template = $this->_setup_page($id);
/* Load master page view and pass along required template parameters ($template) */
$this->load->view('master_view', $template);
}
function _setup_page($id)
{
$page_data = $this->page_model->get_page($id);
$site_data = $this->page_model->get_site_info();
$template['page_title'] = $page_data['page_title'];
$template['body_class'] = $page_data['body_class'];
if ($page_data['header_img'] <> '') {$template['header_img'] = base_url().'public/img/'.$page_data['header_img'];} else {$template['header_img'] = '';}
$template['background_img'] = base_url().'public/img/'.$page_data['background_img'];
$template['page_headline'] = $page_data['headline'];
$template['page_headline_img'] = base_url().'public/img/'.$page_data['page_headline_img'];
$template['page_content'] = $page_data['page_content'];
$template['footer'] = $site_data['footer'];
$template['display_featured_prod'] = $page_data['display_featured_product'];
return $template;
}
}
/* End of file page.php */
/* Location: ./system/application/controllers/page.php */
THANKS! rob