CodeIgniter Forums
Some help.. - 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: Some help.. (/thread-6773.html)

Pages: 1 2 3 4


Some help.. - El Forum - 03-11-2008

[eluser]oriceon[/eluser]
Hello all, i`m new on coding sites with a framework.. I have a question: how could i acces in browser some functions from default controller (main) without access: http://www.site.com/main/myfunction.html .. I want to access http://www.site.com/myfunction.html but this one to came from main controller.

Thanks


Some help.. - El Forum - 03-11-2008

[eluser]zilverdistel[/eluser]
in the file system/application/config/routes.php, you have to change

Code:
$route['default_controller'] = "welcome";

to

Code:
$route['default_controller'] = "main";

if you want '.html' added to your urls, edit system/application/config/config.php. Look for the line

Code:
$config['url_suffix'] = "";



Some help.. - El Forum - 03-11-2008

[eluser]oriceon[/eluser]
I have that one and nothing happened that i want. :|

Code:
<?php

class Blog extends Controller {
    
    function __construct()
    {
        parent::Controller();
    }
    
    function index()
    {
        $data['title'] = 'My blog title';
        $data['heading'] = 'My blog heading';
        
        $this->load->helper('url');
        $this->load->view('blog_view', $data);
    }
    
    function lists($id)
    {
        echo 'aaaaa';
    }
}
?>


When i access http://localhost/site/ it load blog_view because blog controller is default, so is ok. If i access http://localhost/site/blog/lists.html it is ok, print me aaaa. Now, i want to access only http://localhost/site/lists.html without blog parameter (as a controler) because it is supposed to be default one...

So, how to? Thanks


Some help.. - El Forum - 03-11-2008

[eluser]zilverdistel[/eluser]
I see ... you might try something like this. I'm not sure if the regualar expression used is what you want, but as an example this can serve:

Code:
$route['/([a-z]+)/(\d+)'] = "blog/$1/$2";

it goes in application/config/routes.php, at the bottom of the file. There's a section in the user guide about this: http://ellislab.com/codeigniter/user-guide/general/routing.html.


Some help.. - El Forum - 03-12-2008

[eluser]oriceon[/eluser]
not workin, i trying alot of stuff and no result. Could you made a test and give me a good example? Thanks


Some help.. - El Forum - 03-12-2008

[eluser]zilverdistel[/eluser]
can you post the entries in your routes.php config file?


Some help.. - El Forum - 03-12-2008

[eluser]oriceon[/eluser]
Code:
$route['default_controller'] = "main";
$route['scaffolding_trigger'] = "";

$route['/([a-z]+)/(\d+)'] = "main/$1/$2";


At mine default controller is main.. i changet from blog into main. And in controller same.. Blog to Main


Some help.. - El Forum - 03-12-2008

[eluser]adamp1[/eluser]
I don't get why you want to exclude the controller name. By doing so and using routes with the regex above, you will only be able to access 1 controller for the entire site??


Some help.. - El Forum - 03-12-2008

[eluser]oriceon[/eluser]
I want to create some static pages and i don`t want to access: http://localhost/static/page-name.html .. i want
http://localhost/page-name.html and for that i see that i must create a controller .... then a index function.. and i don`t want that. It is another way.. ?


Some help.. - El Forum - 03-12-2008

[eluser]adamp1[/eluser]
You would be better off with this
Code:
$route['lists/(\d+)'] = "main/lists/$1";