943,652 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 731
  • PHP RSS
Jan 14th, 2009
0

Templates in PHP

Expand Post »
Hi,

Can anybody provide me some examples of using templates in php
Similar Threads
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jan 14th, 2009
0

Re: Templates in PHP

PHP templates? what do you mean? like frameworks?
Reputation Points: 7
Solved Threads: 1
Junior Poster in Training
it2051229 is offline Offline
82 posts
since May 2007
Jan 14th, 2009
0

Re: Templates in PHP

Click to Expand / Collapse  Quote originally posted by it2051229 ...
PHP templates? what do you mean? like frameworks?

Yes, if I want to create one according to my requirement.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jan 14th, 2009
0

Re: Templates in PHP

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:
PHP Syntax (Toggle Plain Text)
  1. include 'functions.php';
  2. include "variables.inc";

See also, include_once, require and require_once.
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
Jan 14th, 2009
0

Re: Templates in PHP

No,
I actually mean to seperate presentation layer from business logic.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jan 14th, 2009
0

Re: Templates in PHP

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)
PHP Syntax (Toggle Plain Text)
  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
css Syntax (Toggle Plain Text)
  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(); ?>
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jan 14th, 2009
0

Re: Templates in PHP

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.
Reputation Points: 7
Solved Threads: 1
Junior Poster in Training
it2051229 is offline Offline
82 posts
since May 2007
Jan 15th, 2009
0

Re: Templates in PHP

Click to Expand / Collapse  Quote originally posted by it2051229 ...
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.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008
Jan 15th, 2009
0

Re: Templates in PHP

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.
Reputation Points: 7
Solved Threads: 1
Junior Poster in Training
it2051229 is offline Offline
82 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to access accessing PHP variable in JavaScript
Next Thread in PHP Forum Timeline: trouble with logic





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC