sf
Introduction to custom pages. What is custom page? "Custom page"… ← ArticlesSupportA free dictionary/glossary PHP-script Guest  •  Sign In  •  Register a new account

Article: #kb-15 Introduction to custom pages. What is custom page? "Custom page"…

  • Status: Published
  • Topic: Back-end (Admin interface)
  • Applies to: Glossword 1.8.11
  • 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.

    Editing custom page settings. / 1008×2291, 362 KB
    Editing custom page settings.

    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
    1. <?php
    2. $oTpl->addVal( 'block:dict_updated',
    3.   gw_html_block_small(
    4.     $oL->m( 'r_dict_updated' ),
    5.     getTop10( 'DICT_UPDATED', $sys['max_dict_top'], 0 )
    6.   )
    7. );
    8. ?>

    Include the contents of HTML-file:

    php
    1. <?php
    2. $arV['page_content'] = $oFunc->file_get_contents( 'templates/common/gw_info1.html' );
    3. $oTpl->addVal( 'block:', $arV['page_content'] );
    4. ?>

    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
    1. <?php
    2. chdir( '../myproject' );
    3. $arV['page_content'] = $oFunc->file_exe_contents( 'myindex.php' );
    4. $oTpl->addVal( 'block:', $arV['page_content'] );
    5. chdir( '../glossword' );
    6. ?>

    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
    1. <?php
    2. gwtk_header( $sys['server_dir'].'/'.$sys['file_admin'] );
    3. ?>

    Explanation:

    • gwtk_header() — function used in Glossword to do redirects.
    • $sys['server_dir'].'/'.$sys['file_admin'] — path to administration interface.

    See also: Release dates

  • Created: , DmitrySh
  • Modified:

New comment

Discussion closed.