• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any one help please??

#1
[eluser]Amrit01[/eluser]
I am new to CI and I am just working on my new website with CI . And I got a stopped in one place .I use the same tuts in CI user guide to create a static pages.And as in the user guide in routes.php there we have to make this change to view that static pages from database
Code:
$route['(:any)'] = "page/view/$1";

But is there any other way to load this "page/view/$1" .Because (:any) won't let me go to other controller and i don't want to route them manually.Please sir help me to escape from this problem.

#2
[eluser]PhilTem[/eluser]
There are multiple ways, some of them are better/easier/worse/...

1) Add a route before the (:any) route for every controller you want to access which shall not be static
2) Create a "bootstrap" controller which will replace the "page/view/$1" controller to handle all requests. Inside this you will check first if there is a controller (file) in application/controllers for the first URI-segment. If you found one, load the class (be careful, this one must not extend CI_Controller or MY_Controller since you will get all classes double loaded and will loose data) and see if there is a method equivalent to the second URI-segment. Then you execute this method and return its content. On the other hand, if you didn't find the method, do show_404();. For classes/files/first URI-segment not found as file, try to find the content either in a view file or inside the database (whichever way you store you static content)
3) There was actually a third possibility which I have, however, forgotten Tongue

I personally like method 2 most but it requires some different code to work (since your controllers shall not extend MY_/CI_Controller but still need to be able to access every component of CI (key word get_instance().


Need further help? Send me an email/PM!

#3
[eluser]Amrit01[/eluser]
Sir will you please elaborate more with some example code match with user guide static page tuts.Thanks in advance

#4
[eluser]solid9[/eluser]
Okay can you tell us what you are doing.
Can you give the scenario, tell us the story.

#5
[eluser]Amrit01[/eluser]
I am just trying to built a website based in Codeigniter framework..Sir

#6
[eluser]solid9[/eluser]
@Amrit01

Okay I think you are confusing yourself.
I suggest you learn first to use the Controller, Model and View.

Do you have the basic idea how this three parts work?
If not then we suggest you read the Documentation regarding these three topic.

#7
[eluser]solid9[/eluser]
Here read this,

http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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