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.:
<?php
$page = TPage('Page Title');
$page->add('Page content');
A page will automatically generate a container div element with its id set to "main". Any content added to a page will actually be added to the "main" div in that page. So, in the previous example, the <body> element of the page will be like this:
:::html
<body>
<div id="main">
Page content
</div>
</body>
You can easily create other div containers and add content to them instead of adding to the "main" div of the page. To do so, you just have to add one parameter to the add() function, corresponding to the id of the div you want to create. So, if you do this:
<?php
$page = TPage('Page Title');
$page->add('Some content.');
$page->add('Something else.', 'another');
The result will be:
:::html
<body>
<div id="main">
Some content.
</div>
<div id="another">
Something else.
</div>
</body>
Without you needing to declare and include the div by hand.
You can configure this behaviour by defining two constants before including the library:
<?php
define('GJ_PAGECONTAINERTYPE', 'section');
require_once('gj_main.php');
$page = TPage('Page Title');
$page->add('Some content.');
$page->add('Something else.', 'another');
will output:
:::html
<body>
<section id="main">
Some content.
</div>
<section id="another">
Something else.
</div>
</body>