Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am building a website powered by twitter's bootstrap. I have created a landing page with menus and text. The next thing I want to do is create a About page, but what is the easiest way to create a new page with the same layout. I don't think copy and pasting the layout would be a great idea.

I have used PHP includes and $_GET variables for this in the past but I wondered if there is a more elegant solution.

I hope this is the place for the question and I hope somebody can help me.

share|improve this question
add comment

3 Answers 3

up vote 0 down vote accepted

There are several ways to do what you want, here is one method that I used to use.

You have your landing page complete, so I assume you have a header with the navigation menus and other information on that page, you have some content in the middle of the page, and you have a footer at the bottom.

What you want to do is re-use the header and footer on all pages, and just change the content, so to do this, you could take all the code for your header and put that in a file and call it header.php. Next, do the same with your footer, again naming it footer.php. Finally, do the same thing with your content, calling it landing_page.php.

Now, in your landing_page.php is where you join all the files together:

<?
include('header.php');
...
output your content here
...
include('footer.php');
?>

Now you can reuse your header and footer in other templates (about.php, etc) without copying all the header and footer code in each template.

This is a very basic example, and there are lots of other techniques but this should get you pointed in the right direction.

For a much more in-depth approach take a look at The No Framework Framework.

share|improve this answer
    
is this the same as the "I have used PHP includes" part of the question ? –  sam Feb 27 '13 at 11:54
    
No it is not, I used to use $_GET[''] variables for the page numbers and then query a database for the correct page. For the basic static pages I went with phrac's solution. For the dynamic and interactive part of the website's I used my own version of a GET and DB query system. pastie.org/6347828 –  Elian ten Holder Feb 27 '13 at 14:12
add comment

Easiest method would to be use a CMS (Content Management System) there are many Bootstrap frameworks that are compiled and ready to use for many different content management systems. This makes adding content and various pages a breeze. It shouldn't be to hard to take what you have done already and input that into a pre-built framework for a CMS.

If you still rather use STATIC design then you can use Dreamweaver and save your design blank as a template which makes making new pages faster but its still not as easy as using a CMS. Take a look at saving time in Dreamweaver.

share|improve this answer
add comment

From a code maintenance point of view, PHP includes are the cleanest way I've come across; another option that I've tried in the past are Dreamweaver template files (think include files that are internal inside of Dreamweaver) but when you publish the file its pure HTML/CSS/JS.

share|improve this answer
    
I also used Dreamweaver template files in the past but the project I'm working on can't be Dreamweaver dependent. Thanks for your answer! –  Elian ten Holder Feb 27 '13 at 14:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.