Welcome Guest, Not a member yet? Register   Sign In
url routing, friendly url
#1

my route file has route['(:any)'] = “web/index/$1″ to bring URL friendly: localhost/my-slug-url, it works good (am using slugs from database), but my dashboard class does not work if I use the route['(:any)'] the problem is that how can I access the dashboard class “dashboard” (has functions add/remove/edit)

I want to make url : localhost/this-is-my-domain without using route ? the simple I can let you feel my issue is about … and even I can access other class and controller.
Reply
#2

Try this:

$route['default_controller'] = 'web';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

//everything goes to web/index besides dashboard, another_controller etc
$route['^(?!dashboard|another_controller).[A-Za-z0-9_/-]+'] = "web/index";
Reply
#3

(10-23-2015, 04:41 AM)mario Wrote: Try this:

$route['default_controller'] = 'web';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

//everything goes to web/index besides dashboard, another_controller etc
$route['^(?!dashboard|another_controller).[A-Za-z0-9_/-]+'] = "web/index";
Reply
#4

Thanks a lot mario, thanks once again for the good help, It work all the way I required,

Is it a good way to do the slug in this way ?


$segment = $this->uri->segment(1);

$get_link = $this->admin_user->slug($segment);

$id = $get_link[0]['link_id'];





if(intval($id) > 0) {

$this->details($id);

} else {

$this->$id();

}
Reply
#5

It depends what you want to do in your application and what seofriedly you want.

Slug can be like 'animals-african-elephant' and this way you can use $segment = $this->uri->segment(1) but if you want urls like this 'animals/african/elephant' you should use uri_string() function from Url Helper library.
Also you can use get method to send params with slug like 'animals/african/elephant?page=1&sort=name' and then get data like $this->input->get('page');

You should check if array index exist in this line: $id = $get_link[0]['link_id'];
Reply
#6

(10-26-2015, 12:53 AM)really thankful to you, that route resolve my issue clearly, would you add me to your skype: waqaspuri mario Wrote: It depends what you want to do in your application and what seofriedly you want.

Slug can be like 'animals-african-elephant' and this way you can use $segment = $this->uri->segment(1) but if you want urls like this 'animals/african/elephant' you should use uri_string() function from Url Helper library.
Also you can use get method to send params with slug like 'animals/african/elephant?page=1&sort=name' and then get data like $this->input->get('page');

You should check if array index exist in this line: $id = $get_link[0]['link_id'];
Reply




Theme © iAndrew 2016 - Forum software by © MyBB