![]() |
include a header page in all pages in php
1 Attachment(s)
First lets have a look at what we are going to do , the aim of this article is to make a header page that can be included in all pages without any problem . so lets have a look at the final output of this article :- Figure 1.1 So how this thing work? Here is a abit of explanation about where is the header.php page and the 1.php page where we will include the header.php page to the 1.php page. Figure 1.2 Part 1 :- The header.php page code is as follow :- PHP Code:
Part 2 :- The 1.php code is as follow :- PHP Code:
The key trick is on this line where you include the header.php in 1.php :- HTML Code:
<tr>Figure 1.3 Its pretty simple technique to include the header to all the pages that you design , i think all the codes above explained how to include the header page in all pages. attachment is included for all the other details like the css file and the images. regards alssadi. like this post if its helpful ;) |
Re: include a header page in all pages in php
You could also go modern and create a template system that before compile requires it to be added or auto adds it to the top of every template. This approach is hard coded and is not something to consider in an real world marketable product. You could also make a class the holds render info per page that auto adds it in at the top of the array list. Although its something that could be used in modern contexts its very primitive and does not conform with the standard software design of dynamic content with only functionality being hard coded but extendable. You could also make a function that adds some dynamics to your solution where all you'd need to do is create an associative array or another method for include info. Good idea just to primitive and not very useful in the modern era of per page include loading and template systems.
|
Re: include a header page in all pages in php
i think everyone got his own way of creating templates, different era different type of coding ;) , but anyway thanks for the comment.
|
Re: include a header page in all pages in php
i agree with the template sytstem
but i wont think that a simple user who wanna create his own peaceful website would ever think of using one of these template systems :D |
Re: include a header page in all pages in php
I think ManzZup got the idea out of this post ;)
|
Re: include a header page in all pages in php
There is more then one method, however the more dynamic the site is the easier it is to extend it and customize it. For example you could create a folder and name it skins. Then each sub folder would be a skin. Create a function to read that directory and then you can load a full skin that way with a log file that tells it render order etc... Its simple, easy to make, and allows for different for partials of different template being loaded into a page.
|
| All times are GMT +5.5. The time now is 14:21. |