Welcome Guest, Not a member yet? Register   Sign In
Best place to have your view files?
#1

I have no idea, but for some reason when I started my project [btw, my first project] I placed my view files inside a folder in the views folder, and now I have problems with routing:

- application
-----views
--------myviewfiles
-----------aboutus.php
-----------contactus.php

Shall I move them into the views folder or its ok to leave it as it is? Thanks
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply
#2

You can place your views in subdirectories without problems. This isn't the cause for your routing problems.

See http://www.codeigniter.com/userguide3/ge...irectories
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

I do not understand your problem. If you have structure like so, you just call it by

PHP Code:
$this->load->view('myviewfiles/aboutus'); 

I do not see any problem with routing, because routing is related to controller, not a view.

If you did not, read the documentation. Good luck.
Reply
#4

Thanks guys, yes I'm calling them that way, it works no problem on my localhost, but when I go live Im having problems therefore I was wondering if I should move them to views.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply
#5

Hey lexxtoronto ,
Can you elaborate what problem are you having with routing?
We are not able to relate routing with the views folder.
Reply
#6

(05-31-2015, 10:03 AM)lexxtoronto Wrote: Thanks guys, yes I'm calling them that way, it works no problem on my localhost, but when I go live Im having problems therefore I was wondering if I should move them to views.

Make sure the case of the filenames matches the way you call them in the code, especially if you are using Windows to develop your application and Linux (or anything but Windows) for the server. Additionally, check the permissions on the files to make sure your application can load them. Windows tends to be very forgiving on the case of filenames (because the filesystems commonly used on Windows are case-insensitive by default), but can be just as difficult (or even moreso) when dealing with permissions.

Personally, when I have some level of control on my server, or when I can ask my server's admins to do so, I add the user I use for uploading files to a group with the account used by the web server to run my application (usually www-data). Then I assign the appropriate permissions for the files/directories to that group, and they're less likely to be messed up when I add/update files (plus I don't have to give any more access than necessary to the outside world).
Reply
#7

Thank you
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply
#8

place your view files anywhere in views folder. categorize the files into sub directory is a good practice.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB