Welcome Guest, Not a member yet? Register   Sign In
Some help..
#1

[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
#2

[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'] = "";
#3

[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
#4

[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-gui...uting.html.
#5

[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
#6

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

[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
#8

[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??
#9

[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.. ?
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB