Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

What if I want more products categories on Build a PHP Application instead of just shirts ?

Hi everyone, I'll try my best to explain my question. I went through all the "Build and Enhance a PHP Application" course and I understood most of it. In the end of the project we had a SHIRTS folder, containing two other files: index.php and shirt.php. The shirt.php file will display only one specific shirt's detail, but I would also like to use it as a template for other products I'd like to add to the website, like for example pants! Should I create a PANTS folder and inside of it just do another index.php and a pants.php file, where I would copy all the code, or is there a way I could have a file, called for example product.php, outside of the folders that every other category like (shirts, pants, underwear etc.) could access ?

Also, the index file inside shirts.php includes all the products from an include file called products.php ... Is it better organised if I have different products.php file like example: shirts_products.php ; pants_products.php; or should I just include all products inside only one include file and just use a conditional later to decide what products to display in each page according to the "sku" for example.

Tried my best to make my question clear, thanks in advance!

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Johny;

Great questions. From a realistic standpoint, if you are going to be adding more products to the Shirts 4 Mike site, perhaps to create a Clothing 4 Mike site in which you offer pants, hats, socks, etc. One should really be looking at integrating a database with the site. Randy does a good job of explaining the MVC model and, in my opinion, to take the Shirts 4 Mike site to the next level integrating it into an MVC framework would be in order.

I would recommend taking a look at the Laravel Basics course for a great course on building MVC modeled sites utilizing the Laravel Framework (PHP), or any of the Ruby on Rails courses offered in the the Ruby language section here at Treehouse.

Happy coding,

Ken

Ken, Thanks for your answer. I'll definitely check out those courses !