go!Johnny provides the TPage class for building an entire HTML5 page. It has the same basic behaviour of other go!Johnny classes. Ex.:
<?php $page = TPage('Welcome', 'Some text'); echo $page;
This will output a whole HTML5 page, from the <!DOCTYPE declaration up to the closing </html> tag, containing a <head> element with a <title> set to 'Welcome', a default icon, some default css and js files (viz. the bootstrap css library and jQuery), and a <body> element with a <div> containing the string 'Some text'.
As you see, the TPage class is not a class like the others. It is much more complex and basically does most of the work. You can manipulate virtually all aspects of a page:
-title element;
-meta tags;
-icon;
-javascript files;
-css files;
-content;
-encoding.
Also, instead of echoing the page, you a render() method is available.
Let's see a more complete example:
<?php $page = TPage(); $page->icon = 'my.ico'; $page->title = 'Testing'; $page->css[] = 'mystyle.css'; $page->js[] = 'somelibrary.js'; $page->js[] = 'myown.js'; $page->add('Lorem ipsum &c. ...'); $page->render();
The output will be:
<!DOCTYPE html> <html> <head> <!-- starting page head section --> <!-- starting page meta section --> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Expires" content="0" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> <meta name="language" content="en" /> <meta name="robots" content="index,follow" /> <meta name="coverage" content="Worldwide" /> <meta name="distribution" content="Global" /> <meta name="rating" content="General" /> <!-- finishing page meta section --> <title> Testing </title> <link rel="icon" href="my.ico" type="image/x-icon" /> <link rel="stylesheet" href="http://myserveraddress/gojohnny/lib/bootstrap/css/bootstrap.css" type="text/css" /> <link rel="stylesheet" href="http://myserveraddress/gojohnny/gojohnny.css" type="text/css" /> <link rel="stylesheet" href="http://myserveraddress/gojohnny/fonts.css.php" type="text/css" /> <link rel="stylesheet" href="mystyle.css" type="text/css" /> <script src="http://myserveraddress/gojohnny/lib/jquery/jquery.js" type="text/javascript"></script> <script src="http://localhost/_gojohnny7/gojohnny.js" type="text/javascript"></script> <script src="somelibrary.js" type="text/javascript"></script> <script src="myown.js" type="text/javascript"></script> <!-- finishing page head section --> </head> <body> <!-- starting page body section --> <div id="main" class="container-fluid"> Lorem ipsum &c. ... </div> <!-- finishing page body section --> </body> </html>