Functions
We call function to each thematic activity you can do in Navigate CMS: Elements, Blocks, Structure... Of course, Functions is also a function! Unless you want to develop some new functionallity in Navigate CMS, you won't use this function.
The Functions function uses two views: List and Form.
List
As with other lists in Navigate CMS:
- Click on a row to select/unselect it
- Double click or do a long press on a row to load the edit form
- Ctrl + Double click on a row to load the edit form on a new tab/window
- Move the scrollbar to get more items
- Find rows using the top right mini search form
Form
Functions edit form has only one tab: Main. It only defines 6 fields:
- ID — numerical identifier of the function or (new) if it's an unsaved new function
- Category — thematic group of the function (used in Menus function); it is a free text field, but Navigate CMS defines the following thematic groups by default:
- admin — Administration tools
- config — User configuration and preferences
- content — Functions to manage the content of a website
- shop — Functions to manage a shop (available in future versions)
- tools — Unclassificable website tools: Extensions, Newsletters...
- web — Functions to manage the properties of a website: Structure, Themes...
- Code — Internal function codename, it will be used in Navigate CMS urls (?fid=function)
- Icon — relative path to the 16x16 icon of the function (from the Navigate CMS root folder)
- #Title (lid) — number assigned to the title of the application in the Navigate CMS dictionary
- Enabled — defines it the function is visible/executable or hidden
Creating new functions
You can create new functions in Navigate CMS but understand that if new features are added in the application they may overwrite your changes. Take that in account when performing automatic or manual updates.
If there is enough interest we may improve this area of the application. Right now we will only explain the basics.
All functions are located at lib/packages. Each function has its own folder titled with its codename. Inside you must create at least one file named function_codename.php. Example:
- lib/packages/blocks/blocks.php
The last requirement is to write your main function, the one that will be always executed when the user does any interaction:
function run()
{
global $DB;
switch($_REQUEST['act'])
{
case 'form':
// treat the fields of a posted form
// generate the form HTML
$out = myfunction_form();
break;
default:
case 'list':
// generate the list HTML
$out = myfunction_list();
break;
}
// return the generated HTML to Navigate CMS
return $out;
}
So you don't have to use echo, print or <?= to send HTML to the browser. Instead, you save everything in a variable and give it to Navigate CMS. The application will render that in the main content zone.
Navigate CMS interface has its own dictionary located at lib/lang. It is a collection of .inc files in plain text format. Each line represents a translatable string and begins with a number followed by a # and the translation for that language. You can add new lines but updates can remove them, so we always recommend having a backup of your work. Another option is to create and use your own dictionaries.
0 Comments