Welcome Guest, Not a member yet? Register   Sign In
General linking to pages
#1

[eluser]Unknown[/eluser]
I'm a new user to CI, and am loving it so far. Great Job Guys!

One question is nagging at me though, and I cannot find the answer in the doc's : If I wanted to have a hyperlink on one page that opens another page on my site, do I have to build a controller for it? Or is there some way to simply link to that page as with a normal anchor tag? I've tried using "redirect" but it won't work.

I guess what I'm asking is this - when using CI, are we "locked" into the MVC methodology, or can pages within the site be displayed using the "traditional" html method of linking?

Thanks!
#2

[eluser]Mangetsu[/eluser]
Well, every controller and containing functions can be accessed via URL, example http://www.your_domain.com/controller/method/params... So you can build your url in view and it should work, but you in some cases you'll have to adjust routes.php in config dir. In your view you have access to base_url() function that will give you your current url depending on your config, http://www.your_domain.com/. Just add it the rest of path to desired controller. If you'll have problems feel free to PM me.
#3

[eluser]davidMC1982[/eluser]
The default .htaccess basically sends all requests to index.php so, out of the box, you are restricted to using the framework. You have two options in this case:

1) Create controllers and methods to match your pages.
2) Create a "pages" controller as described here: http://ellislab.com/codeigniter/user-gui...pages.html

You can create custom routes to tidy things up.

If you're willing to experiment a bit, you could probably alter .htaccess to not rewrite requests to html files (the same way as css, image files etc work currently).




Theme © iAndrew 2016 - Forum software by © MyBB