Welcome Guest, Not a member yet? Register   Sign In
I have a question about codeigniter
#11

[eluser]Mike DeFelice[/eluser]
Hmm I'm not too sure to be honest, I am running CI 1.7.3 maybe you are running 2.0?

Fixed
Change the

Code:
$route[':any'] = "welcome/index/$1";

to

Code:
$route['(:any)'] = "welcome/index/$1";
#12

[eluser]FinalDestiny[/eluser]
Thanks
#13

[eluser]FinalDestiny[/eluser]
LATER EDIT: SOLVED, I used the $config['uri_segment']. Anyways, if you can give me some suggestions for code optimization...thanks

I have this controller:
Code:
<?php
class Cupe extends Controller {
    function Cupe()
    {
        parent::Controller();
    }
    function index()
    {
        $this->propuse();
    }
    function propuse()
    {
        $config['base_url'] = base_url() . 'cupe/propuse/yahoo-pool';
        $this->db->select('id');
        $config['total_rows'] = $this->db->get('competitions')->num_rows();
        $config['per_page'] = '5';
        $config['first_link'] = '1';
        $config['last_link'] = $config['total_rows'];
        $this->pagination->initialize($config);
        $data = array(
                'page'        => 'competition',
                'title'        => 'Vezi competitiile propuse'
                );
        $this->load->view('includes/template', $data);
    }
}

The problem is: every page I select, the first page always stays with <strong>. If I put the base_url as cupe/propuse, it works fine, but if I have the 3rd segment or 4th segment in the url, it doesn't work.

Any ideas? Thank you!

Also, is the code I just posted ok? Should I use models or smth? I'm still new with CodeIgniter framework and I want to know as much as possible about optimizing the code.
#14

[eluser]natefons[/eluser]
[quote author="Mike DeFelice" date="1293773369"]Yup it sure is possible, you just need to pass some parameters to the function.

For instance

function blog($title,$tags = '', $sort = '') {
show view, do stuff
}

then you can check if the fields are not false and go from there

$tags = $this->uri->segment(#) (returns false if it doesnt exist)
$sort = $this->uri->segment(#)


if($tags !== FALSE && $tags == 'tags') {
do something
}
hope this helps![/quote]
why do you do this?

to my understanding, since the function has arguments, it will be auto passed from the uri:
example.com/blog/title/tags/sort

will auto pass those arguments in already.... so
example.com/blog/test/tagalo/sortup
will make:
title:test
tag:taglo
sortConfusedortup


i do not believe you need to recheck using:
$tags = $this->uri->segment(#);




Theme © iAndrew 2016 - Forum software by © MyBB