Welcome Guest, Not a member yet? Register   Sign In
Organizing the Site!
#1

[eluser]Drew Barontini[/eluser]
Alright, so I've been going through the tutorials/videos/user guide and other various informational components for CI. I've built a login, a contact form, and an image uploader. These are just some random various apps I wanted to build to install into a dynamic database driven portfolio site I'm making for myself with a main page (news/blog, dynamic header image), an about page, a portfolio page (dynamically load the images, description, and link), and a contact page. I want these to be backed by a basic CMS just to update the news/blog, as well as the images, description, and link in the portfolio section.

My question is this; I'm confused as to organizing the pages within the controller, view, etc.. I just have form.php, upload.php, and contact.php as controllers. Then I have their related forms and success pages in the view file. How do I organize these into pages on the website. Can I create subfolders within the controllers section named contact, portfolio, etc.. and also do this in the model/view folders. If this is how you organize it, how do you link to these pages and is the url affected?

Also, how would a CMS work with subsequent directories for those files. I planned on doing a login page that would be separate from the site only for me to update, insert, edit, and delete tables. I would have a home_admin with links to a news/blog_admin, contact_admin, portfolio_admin, and about_admin to update the databases. So those would be in the model? How would I organize those folders?

Sorry for the newbie question, but I'm confused as to organizing an entire site onto the framework and how to link, and how to integrate the CMS into that organization.

If anyone can point me in the right direction, or offer advice, that'd be tremendous.

Thank you!
#2

[eluser]Pascal Kriete[/eluser]
Quite a read, I hope I can cover most of it Smile .

First off welcome to CI. You seem to have done a terrific amount of homework.

You can create subfolders for your controllers. Realize, however that this will add another segment to your url, and you're limited to a depth of one. In the same way you can create subfolders in the views folder. For views, you then have to pass in the folder/viewname (these can be nested as deep as you like) . I have actually never tried it with models, but I assume it's possible.

For a very large site you might want to consider one of the community modular extensions, such as Matchbox or HMVC (should both be on the first page of the ignited code section).

One change I personally make every time, is change the router to allow me to omit the directory if the directory and controller name are the same. I can fork over that code if you're interested Wink .

To simulate the backend, I put an admin controller into each folder where I will need one.

My views folders have the same names as the controller folders, with an admin subfolder where needed. I also always have a folder for 'global' view elements.

And just to illustrate:
[pre]
controllers (f)
images (f)
images.php ©
upload.php ©
admin.php ©
views (f)
images (f)
someview (v)
admin (f)
someadminview (v)
[/pre]
#3

[eluser]Drew Barontini[/eluser]
Thank you. I apologize for the novel I wrote, but I just wanted to be clear and provide an in-depth explanation.

If you get a chance, I'd love to see the code you were mentioning.

To see if I'm clear, can I do the following:

Taking the same portfolio site example. 4 pages of the site Home - Portfolio - About - Contact

I will have the main controller folder consisting of index.php, portfolio.php, about.php, contact.php, and admin.php (login)

Then in the views file I can have subfolders for the 4 main site names corresponding with the same name as the controller files (home, portfolio, about, contact). In these 4 folders, I will have the view files necessary to display each page, as well as the admin views, and if any of those admin views or any other views are global, I will place them in the main view file folder. I guess I should just make an admin folder folder for all the admin views as well.

Can I do it this way?

I'll look into the modular extensions for when building much larger sites that require far more files.

Thanks again. Inparo
#4

[eluser]Pascal Kriete[/eluser]
You've got it pretty much spot on. Of course, everyone has their own methods. I've attached two screenshots.
#5

[eluser]Pascal Kriete[/eluser]
And since it didn't let me attach the zip, the extended Router can be found here.
#6

[eluser]Drew Barontini[/eluser]
Thanks, Inparo! That looks great and helps a lot. I'm going to continue developing the components and working on this site. I think giving myself a project will force me to learn more and I just prefer to jump right into it. Thanks again.
#7

[eluser]Drew Barontini[/eluser]
I've added a contact folder to the views folder and I loaded it like this but it didn't work



Code:
$this->load->view('contact/contact_view');


How do I link it properly?
#8

[eluser]Pascal Kriete[/eluser]
Should work just like that.
#9

[eluser]Drew Barontini[/eluser]
It's not working when it's being linked that way and I'm not sure why...any ideas?
#10

[eluser]Pascal Kriete[/eluser]
Not without seeing any code. Are you sure the path is correct. views->contact->contact_view.php




Theme © iAndrew 2016 - Forum software by © MyBB