You can add content to a TPage object right when you create it; it is the second parameter, coming after the page title. Ex.:
<?php
$page = TPage('Page Title', 'Page content');
Instead of that, you can use the regular add() function to add content to the page. Ex.:
~~~~~~
add('Page content'); ~~~~~~... [read more](/p/gojohnny/blog/2013/04/the-tpage-class-adding-content/) ?>The most indicated method to adding scripts to your page is to put all javascript code in separate .js files and then reference them in the head element of your page.
You can manipulate the js[] property pretty much the same way as you do with the css[] property, i.e., either as a string or as an array.
Examples:
~~~~~~
js[] = 'somefunctions.js'; $page->js[] = 'someclass.js'; ~~~~~~... [read more](/p/gojohnny/blog/2013/04/the-tpage-class-javascript/) ?>There are different ways of adding style to a page. The most indicated method is putting your styles in separate css files and reference them in your page header.
To reference css files in your TPage, you can set the css[] property. This can be set as an array containing as many css files as you want, or as a simple string in case you want to reference one single css file (thus also overriding the default base css that is automatically included). If you don't want to reference any css files, you can set the css[] property as either a blank string or an empty array.... read more
Although you can set basic page properties upon construction, it may be more practical to do so by setting one property a time.
The title of the page (that will appear in the window title bar and when you bookmark the page) is the first parameter to be passed when creating a page. If you prefer, you can set it later. Ex.:
<?php
$page = TPage('Welcome');
is exactly the same as:... read more
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'.... read more
There are basically two types of hyperlinks provided by go!Johnny: regular links (the TA class, representing a simple a tag) and javascript links (the TJSA class, whose name stands for "JavaScript A").
In both cases, the first parameter represents the resource you are linking to, while the second parameter is the text to be displayed.
~~~~~~
Simple container elements, like p, div, span, section, article &c., behave and are used in exactly the same way: you create an instance of the corresponding class, add content to it, set its properties, echo it directly or concatenate it with more elements or more text to be output later.
Each HTML5 element is represented by a class in go!Johnny. The class names consist in the prefix 'T' followed by the name of the element/tag you want. For example, if you want a paragraph (HTML p element), you have to use the TP class; for a span element, use the TSpan class and so on. ... read more
There are several methods for creating an element with go!Johnny.
The most canonical, traditional method is the straightforward:
<?php
$score = new TP();
This can be shortcutted like this:
<?php
$score = TP();
For each class there is a shortcut function with an identical name. This way you don't need to use the new keyword every time you need a go!Johnny element.... read more
Every go!Johnny class implements an add() function, whose purpose is to add content to the element. E.g.:
<?php
$time = new TDiv();
$time->add(date('H:i:s'));
echo $time;
This will generate the following output:
:::html
<div id="time">
09:53:12
</div>
In more simple cases, you can pass the content directly to the constructor, e.g.:
~~~~~~
There are three properties that receive special treatment in a go!Johnny class:
*The id property is generated automatically, either reflecting the name given to the variable in the php code, or (if no variable is assigned) with a random generated uid. It can be overwritten by the setID() function. In input elements, it is automatically copied to the name property. This can be turned off by defining GJ_AUTOID as false before including the library.... read more
Beginning with this post, we will be describing the basic structure of go!Johnny classes. As virtually each class represents an HTML element (tag), most properties and methods are common to all of them.
First of all, let's consider the properties variable. This is an array that stores all the properties (!) of the HTML element represented by the instance. You can set any property you want, and it will be communicated to the resulting HTML tag. E.g.:... read more
The go!Johnny library is not provided in any special package type like e.g. PEAR. You just have to download the latest version, unpack it to your server and then include the main file in your PHP scripts. There are only two options you have to define (constants GJ_PATH_LOCAL and GJ_PATH_WEB), in case your scripts are located in a folder other than that of the library (which is mostly the case).... read more
go!Johnny is a collection of classes designed to help in the creation of HTML5 content and web pages. Each class represents an HTML5 tag, with some extra classes for related useful tools such as database access.
The ideas behind the library are:
-a web page is an application
-the user is enabled to write in a single programming language (php), without mixing programming code and HTML/CSS markup.
-even if you have to write different languages (e.g. javascript, css), each one will be in a separate file.
-the classes are highly flexible, so you can find the most comfortable way to work with them.
-default options should always be the most meaningful ones.... read more