Page 1 of 1

Page layouts - a question

Posted: Mon Jun 25, 2012 2:21 am
by OldRod
Dug out my old on-again/off-again PBBG that I've worked on for a while now and am re-doing it from the ground up using stuff I've learned since I last worked on it... making it cleaner, etc. Probably shelve it again soon, but it's going good for now :)

Anyway, I have a question. I currently have the browser window set up with a main content area in the center of the screen, and several DIV's around the sides and top/bottom. Whenever I add a new page, I have to copy in lots of 'includes' and things get messy real quick, before I even put in any actual content for that page.

Is that the way it is for you guys too? Or am I missing a simpler, cleaner way to do this without all the DIV includes?

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 2:52 am
by Jackolantern
If you don't want to go all the way with an MVC solution, you could try reversing the way you "include". When I first started making simple PHP include templates, I would cut up the template into several parts, and then start on each content page, adding all of the template includes, which did make it a mess. Then what I started doing is keeping all of my template in one base file. Then I would use Save As to rename to whole template into the name the final page would have, and create another script to represent the content of that page. Then I would only need 1 include to put the content into the middle of the page. That can help out if you really only have the content changing on each page. Essentially you are sucking the content into each individually named template page instead of trying to surround the content page with the template. It is a subtle difference, but if you are making pages like I used to, it can keep it much neater.

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 10:30 am
by OldRod
Sounds like that might work, thanks

I've looked at MVC a bit, but never tried working with it. I just want something to help keep the pages clean and organized. Looking at the code I wrote 1 or 2 years ago, I'm having problems following why I did what I did... and I did write comments :)

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 11:12 am
by vitinho444
OldRod i do like that too. But in the new page i got the div=igactive that is where the page will be displayed, then the includes of the menu, the advertisement and the player info. Its not very clean, but not very unclean :D

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 12:00 pm
by Chris
Sounds like you need a little MVC in your life.

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 1:02 pm
by OldRod
LOL, ok :)

Do you suggest learning MVC and trying it out on my own? Or using a framework like CodeIgniter?

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 1:14 pm
by Chris
One thing we often say is, don't write what has already been written. To start I'd get a copy of something that works and fiddle around with it until you understand the concept of MVC. Chances are you'll realize you won't need to write the framework yourself once you get used to working with one. Personally I like Codeigniter because it's what I started with, quite a lot of people use Zend, as it comes with loads of tools. You might want to give Zend a try.

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 1:14 pm
by OldRod
vitinho444 wrote:OldRod i do like that too. But in the new page i got the div=igactive that is where the page will be displayed, then the includes of the menu, the advertisement and the player info. Its not very clean, but not very unclean :D
I think part of my problem may be I try to do too much in the sidebars and they end up with lots of if-else blocks and get hard to read.

This code I'm working with is close to two years old and it's a real mess, which is most of the reason I gave up on it in the first place. I'm going to start from scratch and try to get it as clean as I can on the re-write and then move forward with new stuff. I feel comfortable with my concept and have lots of good ideas where the game can go... I just need it to be able to be workable

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 1:16 pm
by OldRod
Chris wrote:One thing we often say is, don't write what has already been written. To start I'd get a copy of something that works and fiddle around with it until you understand the concept of MVC. Chances are you'll realize you won't need to write the framework yourself once you get used to working with one.
That's kind of the way I feel too. I messed with Zend a couple years back and it just didn't feel good to me. CodeIgniter looks pretty good from what I've seen so far. Are there other/better ones that you'd recommend?

Re: Page layouts - a question

Posted: Mon Jun 25, 2012 1:20 pm
by Chris
OldRod wrote:
Chris wrote:One thing we often say is, don't write what has already been written. To start I'd get a copy of something that works and fiddle around with it until you understand the concept of MVC. Chances are you'll realize you won't need to write the framework yourself once you get used to working with one.
That's kind of the way I feel too. I messed with Zend a couple years back and it just didn't feel good to me. CodeIgniter looks pretty good from what I've seen so far. Are there other/better ones that you'd recommend?
The easiest to learn I've found is the .NET MVC, if you get a copy of Visual Studio and install MVC 3 or 4 on it I think you'll learn MVC the fastest.