| | |
Templates in PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
There are functions for including in a script, a script held in another file. Is this what you mean? i.e. you can define the functions that you will use (and constants, variables, etc) and then include them.
Syntax:
See also, include_once, require and require_once.
Syntax:
PHP Syntax (Toggle Plain Text)
include 'functions.php'; include "variables.inc";
See also, include_once, require and require_once.
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
a template
<html>
<head>
<style>
.left {width:50% text-align:right; float:left;}
.right{width:50% text-align:left; float:right;}
</style>
</head>
</body>
<div class=left><?php include('left.php'); ?></div>
<div class=right><?php include('right.php'); ?></div>
</body>
</html>
a trivial example, yet without any idea of
'my requirement' its difficult
the template above is the <style></style> in the head
typically the layout is created in an external stylesheet, that specifies,
absolute (bad only works on 1 screensize) or
relative (good)
placement and size colors transparency visibility of the elements to appear on a html page.
then the stylesheet is referenced in each pages source and ensures uniformity of appearance.
also allows for easy alteration of appearance by editing a single stylesheet
in php it is simple,
each page is (trivial example)
where header file includes the lines
edit: in my sites all files are given php extensions and the first lines of code are
the last line of code is
in case mod_deflate is not enabled in the server
A CSS template
style.css.php
<html>
<head>
<style>
.left {width:50% text-align:right; float:left;}
.right{width:50% text-align:left; float:right;}
</style>
</head>
</body>
<div class=left><?php include('left.php'); ?></div>
<div class=right><?php include('right.php'); ?></div>
</body>
</html>
a trivial example, yet without any idea of
'my requirement' its difficult
the template above is the <style></style> in the head
typically the layout is created in an external stylesheet, that specifies,
absolute (bad only works on 1 screensize) or
relative (good)
placement and size colors transparency visibility of the elements to appear on a html page.
then the stylesheet is referenced in each pages source and ensures uniformity of appearance.
also allows for easy alteration of appearance by editing a single stylesheet
in php it is simple,
each page is (trivial example)
PHP Syntax (Toggle Plain Text)
<?php ob_start("ob_gzhandler"); include ('header file'); /* some code to generate a body or process data */ ?> <LINK Rel="stylesheet" Type="text/css" Media="screen" href="/style.css.php"> </head> <body> some static html <?php /* some more php to do something else */ include ('footer file'); ob_flush(); ?>
<LINK Rel="stylesheet" Type="text/css" Media="screen" href="/style.css.php"> <script type=text/javascript language='javascript' src='/script.js.php'>
edit: in my sites all files are given php extensions and the first lines of code are
<?php
header ('content-type: /* actual content:: text html text/css text/javascript */');
ob_start("ob_gzhandler"); ?>the last line of code is
<php ob_flush(); ?>
in case mod_deflate is not enabled in the server
A CSS template
style.css.php
css Syntax (Toggle Plain Text)
<?php header ('content-type: text/css'); ob_start("ob_gzhandler"); ?> /*<style>*/ .rss-box { margin: 1em 3%; padding: 4px 8px; background-color: #ededed; border: 2px dashed #7485CA; } .rss-title, rss-title a { font-family: "American Typewriter", "Trebuchet MS", Trebuchet, Lucida, sans-serif; font-size: 1em; font-weight:bold; margin: 5px 0; padding: 0; letter-spacing: 1px; } .rss-items { } .rss-item { font-family: verdana, arial, sans-serif; font-size: .95em; font-weight : bold; margin: 8px 0; } .rss-item a:link, .rss-item a:visited, .rss-item a:active { text-decoration : none; border-bottom: 1px solid #edefed; color: #88b; } .rss-item a:hover { text-decoration : none; color: #e0861e; border-bottom: 1px dotted #e0861e; } .rss-date { font-size: 0.90em; font-weight : normal; color: #F60; } /*test layout area, lt left block rt right block b* containers*/ .lt { float:left; text-align:right; width:30%; } .rt { float:right; text-align:left; width:65%; } .bk { width:90%; border: #778899 solid 0px; margin: 2px 5%; padding:2px; } .bkb { width:90%; border: #778899 solid 1px; margin: 2px 5%; padding:2px; } .block { float:left; border: #778899 solid 1px; margin:5px; padding:5px; } .blockr { float:right; text-align:left; border: #778899 solid 1px; margin:5px; padding:5px; } /*end test area*/ @media all { .dontall {display:none; } } @media print { .dontprint { display:none; } } @media screen { .dontshow { display:none; } .doshow { display:inline; } } a { font-size: 90%; text-decoration: none; } a:hover { background-color: #66cdaa; text-decoration: none; } a:focus { background-color: #66cdaa; text-decoration: none; } a:active { background-color: #66cdaa; text-decoration: none; } a.button { font-size: 80%; background-color: #d4d0c8; color: #000000; cursor: pointer; overflow: visible; padding: 2px; } a.button:hover { background-color: #66cdaa; } a.button:focus { background-color: #66cdaa; border: 1px solid #000000; } a.button:active { background-color: #66cdaa; border: 1px solid #000000; } body { background-color: #f6f6f6; color: #000000; font-family: verdana, geneva, arial, serif; font-size: 100%; margin: 15px; margin-top:0; padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 1px; } button { background-color: #d4d0c8; font-size: 80%; padding: 2px; border:1px; cursor: pointer; margin: 1px; overflow: visible; } button:hover { background-color: #66cdaa; } button:active { background-color: #66cdaa; border-left: 3px; border-bottom: 3px; text-enhance: bold; } button:focus { background-color: #66cdaa; border-left: 3px; border-bottom: 3px; text-enhance: bold; } div { text-size:100%; } form { PADDING: 1px; margin: 1px; } img { border: 0px; } input { background-color: #efefef; border: 0px; border-bottom: 1px solid #000000;font-size: 90%; } input:hover { background-color: #dfdfdf; } input:focus { background-color: #dfdfdf; border-bottom: 2px solid #000000; } input:active { background-color: #dfdfdf; border-bottom: 2px solid #000000;} input[type=button] { background-color: #d4d0c8; border: 1px solid; font-size: 90%; } input[type=button]:hover { background-color: #66cdaa; } input[type=button]:focus { background-color: #66cdaa; border: 2px solid #000000; } input[type=button]:active { background-color: #66cdaa; border: 2px solid #000000; } p { padding: 1px; font-size: 100%; list-style-type: square; } p:first-line { font-weight:bold; } p:first-letter { font-size:200%; float:left; } table { padding: 1px; } table.sortable th { background-color: #dedede; } table.sortable tr.odd td { background-color: #ededed; } table.sortable tr.even td { background-color: #dedede; } table.sortable tr.sortbottom td { background-color: #dfdfdf; font-weight: bold; } .top { background-color: #000070; color: #ffffff; text-align: right; } td.top { background-color: #000070; color: #ffffff; text-align: right; } td.bottom { background-color: #efefef; padding: 15px; } .bottom { background-color: #efefef; padding: 15px; } textarea { background-color: #efefef; color: #460606; font-size: 90%; font-weight: bold; } textarea:focus { background-color: #dfdfdf; color: #460606; font-size: 90%; font-weight: bold; } textarea:active { background-color: #dfdfdf; color: #460606; font-size: 90%; font-weight: bold; } ul li { PADDING: 1px; } .infor { color: #329932; font-size: 90%; font-weight: bold; background-color: #efefef; border: 0px; } .logo { background: transparent; color: #000000; text-align: right; font-size: 85%; top: auto; left: auto; bottom: 1px; right: 1px; position: fixed; } .logomid { background-color: #eeeeee; color: #000000; text-align: right; font-size: 85%; top: auto; left: auto; position: fixed; bottom: 300px; right: 3px; } .log1 { background: transparent; color: #000000; text-align: left; font-size: 85%; top: auto; left: 1px; position: fixed; bottom:1px; } .log2 { background: transparent; color: #000000; text-align: left; font-size: 85%; top: auto; bottom: 1px; left: 5px; right: auto; position: fixed; } .logtop { color: #000000; background: transparent; margin: 0; background-position: center center; text-align: right; font-size: 85%; top: 200px; left: 1px; right: auto; position: fixed; } .logotop { color: #000000; background: transparent; text-align: right; font-size: 85%; top: 200px; left: auto; bottom: auto; right: 1px; position: fixed; } .menu { font-size: 90%; font-weight: bold; color: #000000; background-color: #d4d0c8; cursor: pointer; } .menuitems{ padding-left:10px; padding-right:10px; } .mouseovermenu { font-size: 90%; font-weight: bold; color: #000000; background-color: #f6f6f6; cursor: pointer; } .mouseover { font-size: 90%; font-weight: bold; color: #000000; background-color: #f6f6f6; } .required { color: #662300; background-color: #f6f6f6; font-size: 100%; font-weight: bold; border: 0px; } .smalldisplay { background-color: #f6f6f6; text-align: right; font-weight: bold; color: #000000; font-size: 85%; } .smalltext { background-color: #f6f6f6; color: #000000; font-size: 85%; } .text { font-size: 100%; } .tinydisplay { background-color: #f6f6f6; text-align: right; font-weight: bold; color: #000000; font-size: 77%; } .tinytext { background-color: #f6f6f6; color: #000000; font-size: 75%; } .topmenu { background-color: #f6f6f6; text-align: right; top: 1px; left: auto; bottom: auto; right: 1px; position: fixed; } .skin0{ position:absolute; width:165px; border:2px solid #778899; background: #eeeeee; font-family:Verdana; line-height:20px; cursor:default; font-size:14px; z-index:100; visibility:hidden; } .menuitems{ padding-left:10px; padding-right:10px; } <?php ob_flush(); ?>
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
![]() |
Similar Threads
- page not redirecting - redirect2page('members.php'); (PHP)
- PDF Templates In PHP? (PHP)
- PHP Templates (PHP)
- vBulletin mod_rewrite (PHP)
- PHP, ASP, ColdFusion, what's your fav? (IT Professionals' Lounge)
- Help - This started out as 213.159.117.132/redir.php NOW??? (Viruses, Spyware and other Nasties)
- embPerl or PHP (Perl)
Other Threads in the PHP Forum
- Previous Thread: how to access accessing PHP variable in JavaScript
- Next Thread: trouble with logic
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube






