Welcome Guest, Not a member yet? Register   Sign In
Unable to link images
#11

[eluser]Iván Argulo[/eluser]
Well, I think we're missing something...

If you redirect to welcome2.php, you would get a 404 error, because you need a controller called welcome2.php, and, AFAIK, it's not possible.

So, you'll need the following structure:

application/controlers/welcome2.php
application/views/welcome2.php

And then, you'll have to redirect to site_url('welcome2') **NOTE** without extension .php.

Are you used to the MVC approach? Please, put here your controllers and views, so we can see them and find the error.
#12

[eluser]sirfak[/eluser]
Hi
Do you mean to say that for every view file i need to create a controller?
Thanks
sirfak
#13

[eluser]Iván Argulo[/eluser]
Well, there are different ways to do that. You could have just one controller and there call different views. For example:

Code:
if ($something)
    $this->load->view('view_one');
else
    $this->load->view('view_two');

On the other hand, a more common situation is to have several controllers and several views. But the most important thing you have to know is that the main part of your application is the controller. So, you can't load a "page" (quoted, because is not really a page) if you don't have a controller.

For example, a controller called application/controllers/first_page.php will produce a page with URL localhost/your_app/index.php/first_page (without the extension .php).

Did you understand?
#14

[eluser]sirfak[/eluser]
HI
Yeah. I understood that point.
But the scenario here is that I have 3-4 links on my home page say "about me", "contact" etc.
From the home page there is no if-else condition applicable here so how do i link to those links
Thanks
sirfak
#15

[eluser]Iván Argulo[/eluser]
You must create a controller for each section, called about_us, contact, home and so on. Then, in each controller, you call the view that contains your page.

Then, you must create your links, using:

Code:
<a href="&lt;?php echo site_url('contact'); ?&gt;">Contact</a>

or

Code:
&lt;?php echo anchor('contact', 'Contact'); ?&gt;
#16

[eluser]sirfak[/eluser]
Thanks man
sirfak




Theme © iAndrew 2016 - Forum software by © MyBB