CodeIgniter Forums
Function not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Function not working (/thread-11767.html)



Function not working - El Forum - 09-22-2008

[eluser]phalkan[/eluser]
Hi
I followed the video tutorial and set up a CI site. When I use the link to the next function, www.mysite.com/index.php/blog/comments/ it does not run the comments function function comments()
{
echo 'testing...';
}

It runs the default function index().

I have set up route default to the blog controller.

Any help would be appreciated.

Thanks


Function not working - El Forum - 09-22-2008

[eluser]David Cassidy[/eluser]
It may be of some help if you include the contents of your Controller and your routes.php file. It sounds like your route may be overriding your page requests. It is hard to tell however, with so little to go on.


Function not working - El Forum - 09-24-2008

[eluser]phalkan[/eluser]
Here is my products controller
<?php

class Products extends Controller {

function Products()
{
parent::Controller();

$this->load->helper('url');
$this->load->helper('form');

}

function index()
{

$this->load->model('categorymodel','', TRUE);
$data['categories']=$this->categorymodel->getCategories();
$this->load->view('category_view',$data);

}

function getCategory()
{
echo 'category testing...';

}

this is what I have set up in my routes page $route['default_controller'] = "products";

When I click on a link it puts in the url http://localhost/mysite/index.php/products/getCategory which is supposed to run the getCategory() function in the products controller and echo "category testing...", it does not.
Any idea why not?

Thanks for any help.


Function not working - El Forum - 09-24-2008

[eluser]phalkan[/eluser]
I found my problem. my URI PROTOCOL
$config['uri_protocol'] = "AUTO";
Was commented out. I un-commented and it works.

Sorry if any one was thinking about this much.

And thanks Dave_C for responding.