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?
Page layouts - a question
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Page layouts - a question
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.
The indelible lord of tl;dr
Re: Page layouts - a question
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
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
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: Page layouts - a question
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
Re: Page layouts - a question
Sounds like you need a little MVC in your life.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Re: Page layouts - a question
LOL, ok
Do you suggest learning MVC and trying it out on my own? Or using a framework like CodeIgniter?
Do you suggest learning MVC and trying it out on my own? Or using a framework like CodeIgniter?
Re: Page layouts - a question
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.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Re: Page layouts - a question
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.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
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
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?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.
Re: Page layouts - a question
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.OldRod wrote: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?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.
Fighting for peace is declaring war on war. If you want peace be peaceful.