Introduction to custom pages
What is custom page?
"Custom page" feature allows administrator to create and modify new pages for Glossword, in addition to pages "Top 10" and "Feedback".
Custom pages are nested, and they have a tree structure. It means some pages (childs) could be placed under another pages (parents).
Custom pages are multilingual — page contents is based on the current interface language.
Each custom page may include a custom PHP-code.
Custom pages are available since version 1.7.0.
Beginning from version 1.8.0 Glossword allows to export and import all custom pages at once. So you can transfer all the site contents with a click.
What variables could be used in a custom page?
There are some PHP-variables which could be used in PHP-code:
$ar_tpl_construct
- Array. HTML-template names for visual theme. Each page of visual theme consists several HTML-templates.
$gw_this
- Array. Allowed values received from $_GET and $_POST, the list of dictionaries with their settings.
$oDb
- Object. Database class.
$oFunc
- Object. Functions class.
$oL
- Object. Translation Kit class to access translation files.
$oSqlQ
- Object. SQL-storage class to access database queries.
$oTpl
- Object. HTML-template class.
$str_current_section
- String. Current section name. Also used in HTML-tags <title>, <meta>.
$sys
- Array. All Glossword settings.
Program code 1
field- Primary purpose. Executes on loading a custom page.
Program code 2
field- Secondary purpose. Executes when building menu with custom pages.
Where are code examples for custom page?
The following example adds new variable block:dict_updated
to HTML-templates with the list of recently updated dictionaries:
- <?php
- $oTpl->addVal( 'block:dict_updated',
- gw_html_block_small(
- $oL->m( 'r_dict_updated' ),
- getTop10( 'DICT_UPDATED', $sys['max_dict_top'], 0 )
- )
- );
- ?>
Include the contents of HTML-file:
- <?php
- $arV['page_content'] = $oFunc->file_get_contents( 'templates/common/gw_info1.html' );
- $oTpl->addVal( 'block:', $arV['page_content'] );
- ?>
Explanation:
$arV['page_content']
— predefined variable.$oFunc->file_get_contents()
— function to read file contents.$oTpl->addVal()
— function to add a variable into HTML-templates.
Include the results of processing PHP-file:
- <?php
- chdir( '../myproject' );
- $arV['page_content'] = $oFunc->file_exe_contents( 'myindex.php' );
- $oTpl->addVal( 'block:', $arV['page_content'] );
- chdir( '../glossword' );
- ?>
Explanation:
$arV['page_content']
— predefined variable.$oFunc->file_exe_contents()
— function to execute PHP-script and read its contents.$oTpl->addVal()
— function to add a variable into HTML-templates.
Redirect user to another Glossword page:
- <?php
- gwtk_header( $sys['server_dir'].'/'.$sys['file_admin'] );
- ?>
Explanation:
gwtk_header()
— function used in Glossword to do redirects.$sys['server_dir'].'/'.$sys['file_admin']
— path to administration interface.
See also: Release dates