Hi there Is there a php template similar to Dreamweaver for websites? I have learnt how to use include but still got a long way with php but was wondering if I can just use one template for the base to create many php pages like Dreamweaver. By the way, this was the best include php format I could come up with and it works too thanks to other people who recommended it to me . <?php $title='About'; include('includes/header1.php'); ?> Insert all your regular HTML here- without the Echo's <?php include('includes/footer1.php'); ?> Code (markup): Many thanks in advance CHEERS
You could use dream weaver, if thats what you like and just copy and paste the HTML code generated by dream weaver into your header and footer
Difference between include_once() and include() is that include_once() allows you to include a file only once in the document. In your case, include_once() is the best option.
Well, the problem with include_once is that it's very heavy, in other words slow. All you need is include as long as you know your not going to accidentally include it again.
What you posted works fine. Yes you could use PHP to create a complete site like that. And you can do alot more. It looks like a pretty good idea to help you learn PHP and to build sites.
There are some very powerful things you can do with php, it's just being creative. What I do is very complex, but I'll show you the concept: You make a template.php file: <html> <body> <div id="Header"> <?= Header() ?> </div> <div id="Content"> <?= Content() ?> </div> <div id="Footer"> <?= Footer() ?> </div> </body> </html> HTML: and then attach that file inside a script like this: function Content(){ //fetch content depending on GET vars } fucntion Header() { // Header in here } fucntion Footer() { // Footer in here } // include template inlcude 'template.php'; PHP: And the content file would look like this <?php $title = ''; $css .= ''; ?> Content Here <?php PHP: This way, you don't have to include files on each content page you make I use OOP so it's a lot different but thats the basic concept.
Wow!! Thanks everyone, Clinton thats a bit complex for me but really don't mind learning it as long as it works, saves a lot of time and easier for creating many more php pages. Instead of having to copy and paste on every page when you can edit that one template page. CHEERS
Hey Clint Am I able to learn how to do this template that you can do? I was looking at your concept and man I still didn't get. I tried it and was confusing myself for ages lol. Would appreciate anyones help on this one. Many thanks in advance CHEERS
I'll give a full explanation in a little while. One thing I forgot to tell you about is the advantage of output buffering in this case. I'm going to write a blog post about this, so give me a few hours and I'll have a full explanation on the topic. I think more people need to know how to do this, however understanding it is hard for newer coders. I'll post in a little while because I'm a little tied up at the moment.
Thanks Clint Learning and doing it correct is what I enjoy the most. I guess the only confusing part is when an example is given then where do I put that piece of code or what does it look like lol. This happen to me when I was trying to learn how to use include in the php file. I was overwhelme when I got it to work but it took me agaes even though the example look so simple. The only problem was adding which code goes where and what does the full code look like that confuse me the most. Looking forward to seeing you blog. CHEERS
I have a new post up Right here This explains the method I was trying to show you a few days ago. Hope it helps.
Thanks for that clinton, that was an interesting read! I am trying to learn OOP at the moment, I would definiatly read that too.