Welcome Guest, Not a member yet? Register   Sign In
Load a page like "$_REQUEST"
#11

[eluser]Raffaele[/eluser]
[quote author="robfromnewy" date="1292597754"]What URL are you using?[/quote]

I've tried both:
ci/index.php
ci/index.php/MyPage
#12

[eluser]Rob @ iFetch[/eluser]
That's why, you'll need to use ci/index.php/page/MyPage (if you're *only* going to be using this one page controller, you could change the route to be

$route['(:any)'] = "page/index/$1";

The downside to this is that it will redirect/route *ALL* requests, so it would make it more difficult to add other functions to the site down the track.
#13

[eluser]Raffaele[/eluser]
I got it now but I am missing some pieces here.
I don't know how to set Controllers and Views and links to follow your suggestions.
#14

[eluser]Rob @ iFetch[/eluser]
OK, so you've got a controller `Page`, with its index function that loads whatever the 1st/2nd URI segment is as a view?

In that case, you just need to have the page in a php file that corresponds inside the view folder.

I.E. If you have a URL /ci/index.php/contact_us, you'll need to have a contact_us.php file in the `application/views` folder that contains the HTML of the page.

The best way to construct your links is with the URL Helper's (http://ellislab.com/codeigniter/user-gui...elper.html) site_url function. So, to link to the contact_us page, you would use: <a href="&lt;?=site_url()?&gt;contact_us">
#15

[eluser]Raffaele[/eluser]
And in this case, what about the routes ?
#16

[eluser]LuckyFella73[/eluser]
Hi Raffael,

first of all welcome to the CI community!

Reading your posts it seems to me that you didn't spend much time reading the user guide Wink
I recommend you to take some time and start with:
http://ellislab.com/codeigniter/user-gui.../urls.html
http://ellislab.com/codeigniter/user-gui...llers.html
http://ellislab.com/codeigniter/user-gui...views.html

Please don't get me wrong - I just think you try to use the CI framework in a way
that it's not suppost to (not really). If you set up your site like you started to, you'll
pass many advantages the ci framework provides and you will have to do more workarounds
than using the features.

Regarding your last question: at the bottom of the CI userguide/urls page you will
find the answers how to set up your links. be sure to enable query-strings in your config.php
#17

[eluser]Raffaele[/eluser]
Ok, something started working but I don't know if in the right way ... Here's the situation:

Routes:
Code:
$route['(:any)'] = "home/index/$1";

Controller Home:
Code:
function index()
    {
    $this->load->view('homepage');
    }

HomePage View:
Code:
if($this->uri->segment(1)!= "")
    $this->load->view($this->uri->segment(1));
else
    $this->load->view('homeContent');

Menu Link:

Code:
<a href="&lt;?=site_url()?&gt;/maurizio">

the problem is here (I think), because "maurizio" is a view and not the controller that shows this view... is it correct ? If I put the controller, it says the page doesn't exists (but it does).

anyway the purpose is accomplished. It shows what I want, BUT I'd like the MVC process to be correct, not just that the page is displayed.
#18

[eluser]Raffaele[/eluser]
Hi LuckyFella,
thank you. I know I should have spent some more time reading the User Guide but you know.. but I wanted to start as fast as I could, and I wanted to know how much efforts I would have had to spend to change the structure of my website and make it an MVC.
Reading something I saw that I should change the approach with what I have so far, and I've started doing it to see where I go to.
You're right when you say that I'm trying to use the fw in a wrong way, but I just wanted to know if it was possible to adapt my website to it without changing too many things.

Thanks for your help Wink
#19

[eluser]LuckyFella73[/eluser]
Glad to hear that Raffaele! I know sometimes you just
want to get a project finished .. And I*m sure there would
be a way to adapt your old site in a simular way but I
think you would regret that later Wink

In case you get stuck somewhere just ask here around this
forums.




Theme © iAndrew 2016 - Forum software by © MyBB