Templates in PHP

Reply

Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Templates in PHP

 
0
  #1
Jan 14th, 2009
Hi,

Can anybody provide me some examples of using templates in php
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 81
Reputation: it2051229 is an unknown quantity at this point 
Solved Threads: 1
it2051229 it2051229 is offline Offline
Junior Poster in Training

Re: Templates in PHP

 
0
  #2
Jan 14th, 2009
PHP templates? what do you mean? like frameworks?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Templates in PHP

 
0
  #3
Jan 14th, 2009
Originally Posted by it2051229 View Post
PHP templates? what do you mean? like frameworks?

Yes, if I want to create one according to my requirement.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: Templates in PHP

 
0
  #4
Jan 14th, 2009
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:
  1. include 'functions.php';
  2. 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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Templates in PHP

 
0
  #5
Jan 14th, 2009
No,
I actually mean to seperate presentation layer from business logic.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,350
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Templates in PHP

 
0
  #6
Jan 14th, 2009
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)
  1. <?php ob_start("ob_gzhandler");
  2. include ('header file');
  3. /* some code to generate a body or process data */
  4. ?>
  5. <LINK Rel="stylesheet" Type="text/css" Media="screen" href="/style.css.php">
  6. </head>
  7. <body>
  8. some static html
  9. <?php
  10. /* some more php to do something else */
  11. include ('footer file');
  12. ob_flush();
  13. ?>
where header file includes the lines
<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
  1. <?php header ('content-type: text/css');
  2. ob_start("ob_gzhandler"); ?>
  3. /*<style>*/
  4. .rss-box { margin: 1em 3%; padding: 4px 8px; background-color: #ededed; border: 2px dashed #7485CA; }
  5. .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; }
  6. .rss-items { }
  7. .rss-item { font-family: verdana, arial, sans-serif; font-size: .95em; font-weight : bold; margin: 8px 0; }
  8. .rss-item a:link, .rss-item a:visited, .rss-item a:active { text-decoration : none; border-bottom: 1px solid #edefed; color: #88b; }
  9. .rss-item a:hover { text-decoration : none; color: #e0861e; border-bottom: 1px dotted #e0861e; }
  10. .rss-date { font-size: 0.90em; font-weight : normal; color: #F60; }
  11. /*test layout area, lt left block rt right block b* containers*/
  12.  
  13. .lt { float:left; text-align:right; width:30%; }
  14. .rt { float:right; text-align:left; width:65%; }
  15. .bk { width:90%; border: #778899 solid 0px; margin: 2px 5%; padding:2px; }
  16. .bkb { width:90%; border: #778899 solid 1px; margin: 2px 5%; padding:2px; }
  17. .block { float:left; border: #778899 solid 1px; margin:5px; padding:5px; }
  18. .blockr { float:right; text-align:left; border: #778899 solid 1px; margin:5px; padding:5px; }
  19. /*end test area*/
  20. @media all { .dontall {display:none; } }
  21. @media print { .dontprint { display:none; } }
  22. @media screen { .dontshow { display:none; } .doshow { display:inline; } }
  23. a { font-size: 90%; text-decoration: none; }
  24. a:hover { background-color: #66cdaa; text-decoration: none; }
  25. a:focus { background-color: #66cdaa; text-decoration: none; }
  26. a:active { background-color: #66cdaa; text-decoration: none; }
  27. a.button { font-size: 80%; background-color: #d4d0c8; color: #000000; cursor: pointer; overflow: visible; padding: 2px; }
  28. a.button:hover { background-color: #66cdaa; }
  29. a.button:focus { background-color: #66cdaa; border: 1px solid #000000; }
  30. a.button:active { background-color: #66cdaa; border: 1px solid #000000; }
  31. 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; }
  32. button { background-color: #d4d0c8; font-size: 80%; padding: 2px; border:1px; cursor: pointer; margin: 1px; overflow: visible; }
  33. button:hover { background-color: #66cdaa; }
  34. button:active { background-color: #66cdaa; border-left: 3px; border-bottom: 3px; text-enhance: bold; }
  35. button:focus { background-color: #66cdaa; border-left: 3px; border-bottom: 3px; text-enhance: bold; }
  36. div { text-size:100%; }
  37. form { PADDING: 1px; margin: 1px; }
  38. img { border: 0px; }
  39. input { background-color: #efefef; border: 0px; border-bottom: 1px solid #000000;font-size: 90%; }
  40. input:hover { background-color: #dfdfdf; }
  41. input:focus { background-color: #dfdfdf; border-bottom: 2px solid #000000; }
  42. input:active { background-color: #dfdfdf; border-bottom: 2px solid #000000;}
  43. input[type=button] { background-color: #d4d0c8; border: 1px solid; font-size: 90%; }
  44. input[type=button]:hover { background-color: #66cdaa; }
  45. input[type=button]:focus { background-color: #66cdaa; border: 2px solid #000000; }
  46. input[type=button]:active { background-color: #66cdaa; border: 2px solid #000000; }
  47. p { padding: 1px; font-size: 100%; list-style-type: square; }
  48. p:first-line { font-weight:bold; }
  49. p:first-letter { font-size:200%; float:left; }
  50. table { padding: 1px; }
  51. table.sortable th { background-color: #dedede; }
  52. table.sortable tr.odd td { background-color: #ededed; }
  53. table.sortable tr.even td { background-color: #dedede; }
  54. table.sortable tr.sortbottom td { background-color: #dfdfdf; font-weight: bold; }
  55. .top { background-color: #000070; color: #ffffff; text-align: right; }
  56. td.top { background-color: #000070; color: #ffffff; text-align: right; }
  57. td.bottom { background-color: #efefef; padding: 15px; }
  58. .bottom { background-color: #efefef; padding: 15px; }
  59. textarea { background-color: #efefef; color: #460606; font-size: 90%; font-weight: bold; }
  60. textarea:focus { background-color: #dfdfdf; color: #460606; font-size: 90%; font-weight: bold; }
  61. textarea:active { background-color: #dfdfdf; color: #460606; font-size: 90%; font-weight: bold; }
  62. ul li { PADDING: 1px; }
  63. .infor { color: #329932; font-size: 90%; font-weight: bold; background-color: #efefef; border: 0px; }
  64. .logo { background: transparent; color: #000000; text-align: right; font-size: 85%; top: auto; left: auto; bottom: 1px; right: 1px; position: fixed; }
  65. .logomid { background-color: #eeeeee; color: #000000; text-align: right; font-size: 85%; top: auto; left: auto; position: fixed; bottom: 300px; right: 3px; }
  66. .log1 { background: transparent; color: #000000; text-align: left; font-size: 85%; top: auto; left: 1px; position: fixed; bottom:1px; }
  67. .log2 { background: transparent; color: #000000; text-align: left; font-size: 85%; top: auto; bottom: 1px; left: 5px; right: auto; position: fixed; }
  68. .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; }
  69. .logotop { color: #000000; background: transparent; text-align: right; font-size: 85%; top: 200px; left: auto; bottom: auto; right: 1px; position: fixed; }
  70. .menu { font-size: 90%; font-weight: bold; color: #000000; background-color: #d4d0c8; cursor: pointer; }
  71. .menuitems{ padding-left:10px; padding-right:10px; }
  72. .mouseovermenu { font-size: 90%; font-weight: bold; color: #000000; background-color: #f6f6f6; cursor: pointer; }
  73. .mouseover { font-size: 90%; font-weight: bold; color: #000000; background-color: #f6f6f6; }
  74. .required { color: #662300; background-color: #f6f6f6; font-size: 100%; font-weight: bold; border: 0px; }
  75. .smalldisplay { background-color: #f6f6f6; text-align: right; font-weight: bold; color: #000000; font-size: 85%; }
  76. .smalltext { background-color: #f6f6f6; color: #000000; font-size: 85%; }
  77. .text { font-size: 100%; }
  78. .tinydisplay { background-color: #f6f6f6; text-align: right; font-weight: bold; color: #000000; font-size: 77%; }
  79. .tinytext { background-color: #f6f6f6; color: #000000; font-size: 75%; }
  80. .topmenu { background-color: #f6f6f6; text-align: right; top: 1px; left: auto; bottom: auto; right: 1px; position: fixed; }
  81. .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; }
  82. .menuitems{ padding-left:10px; padding-right:10px; }
  83. <?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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 81
Reputation: it2051229 is an unknown quantity at this point 
Solved Threads: 1
it2051229 it2051229 is offline Offline
Junior Poster in Training

Re: Templates in PHP

 
0
  #7
Jan 14th, 2009
he isn't asking for a css or any html/xhtml template...

the delhi guy was asking for something like the Zend, CakePHP, PRADO, seagull, and etc. framework.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Templates in PHP

 
0
  #8
Jan 15th, 2009
Originally Posted by it2051229 View Post
he isn't asking for a css or any html/xhtml template...

the delhi guy was asking for something like the Zend, CakePHP, PRADO, seagull, and etc. framework.

Yes, you are right.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 81
Reputation: it2051229 is an unknown quantity at this point 
Solved Threads: 1
it2051229 it2051229 is offline Offline
Junior Poster in Training

Re: Templates in PHP

 
0
  #9
Jan 15th, 2009
you know when you use a template like them, they have a manual or documentation provided at there website.... on there manual, examples are provided.. so its going to cost some reading and testing.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC