• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URL method

#1
[eluser]Dr. x[/eluser]
hi every one. am new here on codeigniter and glade for that, so many thanks for all it's team work.
am covert from already building script into MCV and i know hot to make the url same to "class/function/id" but i want to make small modification to the url to be as that
"class/function/constant_id" so the variable that will pass to the function is only $id not constant_id
i will appreciate for any help
and so sorry for my english
Best Regards

#2
[eluser]Dr. x[/eluser]
any help here please ??

#3
[eluser]n0xie[/eluser]
I don't really understand the question. Could you perhaps explain it with a few examples?

#4
[eluser]Dr. x[/eluser]
thank you n0xie for replay. the question is how to change the url method from shape to another shape
ex. : blog/view/id , so as i understand the controller is "blog" and the function will be "view($id)" and the parameter will pass to the function is id ="$id".
and i want it to be as blog/view/article_id and then "article_" will be constant for example :
blog/view/article_1 or blog/view/article_1234 so just the number "1234" which will pass to the function not "article_1234". i hope you got me, and sorry again for my English
best regards

#5
[eluser]n0xie[/eluser]
Aah you want to have this url?
Code:
blog/view/artice_$id

You could either do it with routes:
Code:
// application/config/routes.php
$route['blog/view/article_(:num)'] = "blog/view/$1";

OR just strip the 'article_' part from the passed parameter:
Code:
function view($id)
{
  $id = str_replace('article_','',$id);
}

#6
[eluser]Dr. x[/eluser]
woow thank you so much for help with that great idea.
can i ask you a question please ?
what if some one write missing character on the url ?are the url will give 404 or will redirect to the original one ?
for example let say i write the url at the browser as that : exmple.com/index.php/blog/view/aticl_1
are that will give 404 or will return the data of exmple.com/index.php/blog/view/article_1 ?
and are that url like will help on search engine or will be no effect ?
est Regards

#7
[eluser]Dr. x[/eluser]
mmm, i dont know why after i use the route the all pages give me blank page ! and if it remove the route line it work back! any suggest ?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.