Welcome Guest, Not a member yet? Register   Sign In
URL problem
#1

[eluser]Josssi[/eluser]
Hi people Smile,

now I have problem with correct URL creating. When my url is after base_url composed of 2 elements, for example ..../forum/note...and I click in my menu on HOME, my new URL have to be ...../home...Problem is, that the first URL element stays an is created new URL like .../forum/home.

Have you somebody some advice for me how to make it correct please?

PS:"Rewrite module i have turned on."
#2

[eluser]InsiteFX[/eluser]
Try adding this to your ./application/config/routes.php file
Code:
$route['home'] = 'forum/home';
#3

[eluser]Josssi[/eluser]
this i have done, but it is problem by url, where is last parameter generated dynamicali as ID for example, there I cant to give all ID to route, its not effectial reason...
#4

[eluser]InsiteFX[/eluser]
You did not state that you wanted to pass parameters to it!
Code:
$route['home/(:any)'] = 'forum/home/$1';
#5

[eluser]Josssi[/eluser]
Thank you for reaction, but it still isnt this right what I need Smile. There is my concrete problem. Under link user/edit/.$user->id I get view with URL .../user/edit/number of id...So this thirt param isnt everytime static, but variable...Which user is logged in, this could edit his profile. In config root so i cant set just

Code:
$route['home/(:any)'] = 'forum/home/$1';

On the right site I need to set not concrete thirt param of url. Something like:

Code:
$route['home/(:any)'] = 'forum/home/(:whatever)';

It was supreme if I could in config root file use function, which returns ID of logged user, but it isnt possible, or isnt it?
#6

[eluser]InsiteFX[/eluser]
Well if you have a users login system then you should be able to store the users id in a session variable.

The other way you could do it would be to use the _remap() method.

#7

[eluser]Josssi[/eluser]
Sorry, but I am donk of remap. I read guide, I am trying to use them, but failed every time. How can I use it in my case? How has to look anchor with remap, to I achieve this same as with
Code:
echo 'anchor('user/edit/'.$user->id,'Edit profile');
???
#8

[eluser]InsiteFX[/eluser]
You can also try to use this:
Code:
$id = $this->uri->segment(n)

CodeIgniter Users Guide - URI Class
#9

[eluser]Josssi[/eluser]
Thanks, it helps me for this time. I set:
Code:
$route['(:num)']= 'user/edit';
My user/edit function needed input param $user_id, now it need any param, and this part I solved this way:
Code:
function edit()
     {
{
if ($this->uri->segment(1) === false)
{
     redirect('user');
} else {
            $user_id = $this->uri->segment(1);
}
      .....
}

Now it helped me, but now I have next problem, I need to solve something similar once more. As I have in other topic written already, I have got table of products, where name each of them will as a link. This links will be designed this way:
Code:
echo 'anchor(product/edit/product_id)';
Clearly product_id is relevant number. I need to solve it same as in the first case, but now it isnt possible. Now I cant set root:
Code:
$route['(:num)']= 'product/edit';
and there is big question how to solve it now.

PS:"Just reminging, my uri address cant have more than one segment afther base_url, because when entering new uri, overwritten ist just last segment and the first one -i dont know whay- stays old, it is overwritten not:/"




Theme © iAndrew 2016 - Forum software by © MyBB