Welcome Guest, Not a member yet? Register   Sign In
passing uri segment straight to index?
#1

[eluser]lexusgs430[/eluser]
Hi,

Im trying to figure out how to use the index function as the main function to display data. (probably a bad description so just check out example.)

Code:
<?php

if (! defined('BASEPATH')) exit('No direct script access');

class Style extends Controller {

    //php 5 constructor
    function __construct() {
        parent::Controller();
    }
    
    function index() {
        $data['page_title'] = 'Style';
        $itemstyleSku = $this->uri->segment(3);
        $data['results'] = $this->items_model->get_style_skus($itemstyleSku);
        $data['main_content'] = 'style';

        $this->load->view('includes/template', $data);
        
    }
    
    function item() {
        $data['page_title'] = 'Style';
        $itemstyleSku = $this->uri->segment(3);
        
        $data['items'] = $this->items_model->get_style_skus($itemstyleSku);
        $data['main_content'] = 'style';

        $this->load->view('includes/template', $data);
        
    }
    
}

So basically, on another page, I have

Code:
$itemLink = anchor("style/item/".$itemSku, 'Link');

referencing it.

Youll note in the above index function, I have same code as in item function. That is because for some reason I cannot ever get the index functions to display the data so I must be doing something wrong. Ive tried it without the __construct, and a bunch of different things but ya, soon as I take out the item segment and try referencing the index function directly like so:
$itemLink = anchor("style/".$itemSku, 'Link');
I get 404 page not found error. Which is weird because I would think it would at least load the view file seeing as how both the index function and item function are referencing the same view?

Anyways, any clarification would be much appreciated.

Thanks


Messages In This Thread
passing uri segment straight to index? - by El Forum - 06-21-2010, 12:45 PM
passing uri segment straight to index? - by El Forum - 06-21-2010, 01:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB