Unable to find url trying to "include" path, but the url is correct! |
[eluser]Rubiz'[/eluser]
Well, I'm very happy to have meeting a framewrok like Code Igniter!! Thnx God a good friend told me about it, and helped me with the first steps. Now I'm having a problem with trying "include" header/footer in my pages. I have searched some posts with similar problems but couldn't find something for solving my problem. So... This is the way I'm trying make something like include: Code: <? echo $this->load->view(base_url().'essenciais/header.php', '', false); ?> Code: An Error Was Encountered But... my page is there, this is correct path... Someone can help this lost path to find itself? Remembering, the function call is in the view page... not in the controller page.
[eluser]Skulls[/eluser]
is your header.php file in the ci structure... in the views folder? if it is there .. and in the subfolder essenciais you need to load it with Code: $this->load->view('essencialis/header'); if that file is outside the views folder... although you should keep it there, you can load the file by calling Code: $this->load->file('path/to/file');
[eluser]Rubiz'[/eluser]
Well, I'm addapting slowly to the code igniter coding thinking... Now I see I have to use something like require() inside the controller. So I did that: Code: function index() The code I want require is like this: Code: <h1>Admin name</h1> The header now is without style and the username returns me "1"... Someone have an ideo for solution?
[eluser]Rubiz'[/eluser]
Well Skulls, I havent read your post befor posting, I can load several views and send it all for the same page? What I want to do is something as simple as include 'path.php'; I'm seriously thinkig why I couldnt do this yet, its something so easy...
[eluser]alexsancho[/eluser]
Code: function index()
[eluser]tonanbarbarian[/eluser]
The problem with what you were originally trying to do was because you were using base_url. Code: <? echo $this->load->view(base_url().'essenciais/header.php', '', false); ?> Code: <? echo $this->load->view('essenciais/header.php', '', false); ?> Using base_url was inserting the full URL of your website into the path, rather than the file location. I have a post here http://ellislab.com/forums/viewthread/66997/#329953 where I talk about partials or elements. You can use the renderElements code I have provided to load sub views from within a view, rather than doing it in the controller Also sounds like you could do with a layout library check out http://ellislab.com/forums/viewthread/67521/#332687 this post that has a couple of links to layout libraries Using the layout library you can wrap the main content of your views in an overall layout hope these help |
Welcome Guest, Not a member yet? Register Sign In |