Actions

Actions with no view

All actions no view files are located in ../core/(front_end/back_end)/actions/no_view and contain the logic code which does not require to diplay a view. For this reason, the code is executed before the actions view file and must not return some content.

//======================================================================
// name_of_your_action
//======================================================================
$actions_no_view['name_of_your_action'] = function()
{   
    //-----------------------------------------------------
    // restricted access
    //-----------------------------------------------------
    if (defined("AUTH_ACCESS_FRT/BCK") && (AUTH_ACCESS_FRT/BCK != 0)) {
        
        /**
         * theme language for this tag
         */
        $action_lang_auth   = THEME_LANG_FRT/BCK; // (default: THEME_LANG_FRT/BCK)
        /**
         * theme folder for this tag
         */
        $action_folder_auth = THEME_FOLDER_FRT/BCK; // (default: THEME_FOLDER_FRT/BCK)
        /**
         * theme tpl for this tag
         */
        $action_tpl_auth    = '_all'; // '_all'|'tpl_name' (default: '_all')
        
        if ((defined("THEME_LANG_FRT/BCK") && isset($action_lang_auth))
        && (defined("THEME_FOLDER_FRT/BCK") && isset($action_folder_auth))
        && (defined("TPL_AUTH_FRT/BCK") && isset($action_tpl_auth))) {
        if ((THEME_LANG_FRT/BCK == $action_lang_auth
        || $action_lang_auth == '_all')
        && (THEME_FOLDER_FRT/BCK == $action_folder_auth
        || $action_folder_auth == '_all')
        && (TPL_AUTH_FRT/BCK == $action_tpl_auth
        || $action_tpl_auth == '_all')) {
                
                // level access; must be an integer different from 0 (default: 1)
                if ((AUTH_ACCESS_FRT/BCK == 1)) {
                
                    ///////////////////////////
                    // ADD YOUR LOGIC CODE HERE
                    ///////////////////////////
                }
            }
        }
    //-----------------------------------------------------
    // public access
    //-----------------------------------------------------
    } else {
        /**
         * theme language for this tag
         */
        $action_lang   = THEME_LANG_FRT/BCK; // (default: THEME_LANG_FRT/BCK)
        /**
         * theme folder for this tag
         */
        $action_folder = THEME_FOLDER_FRT/BCK; // (default: THEME_FOLDER_FRT/BCK)
        /**
         * theme tpl for this tag
         */
        $action_tpl    = '_all'; // '_all'|'tpl_name' (default: '_all')
        
        if ((defined("THEME_LANG_FRT/BCK") && isset($action_lang))
        && (defined("THEME_FOLDER_FRT/BCK") && isset($action_folder))
        && (defined("TPL_FRT/BCK") && isset($action_tpl))) {
        if ((THEME_LANG_FRT/BCK == $action_lang
        || $action_lang == '_all')
        && (THEME_FOLDER_FRT/BCK == $action_folder
        || $action_folder == '_all')
        && (TPL_FRT/BCK == $action_tpl || $action_tpl == '_all')) {
                
                ///////////////////////////
                // ADD YOUR LOGIC CODE HERE
                ///////////////////////////
                
            }
        }
    }
};
#Example
$actions_no_view['cache_browser'] = function()
{
    ...
    // enables browser caching
    $expires = 60*60*24*14;
    header("Pragma: public");
    header("Cache-Control: maxage=".$expires);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
    ...
};

Actions with view

All actions with view files are located in ../core/(front_end/back_end)/actions/view and contain the logic code which require to diplay a view. For this reason, the code is executed after the actions no view file and must return some content.

//======================================================================
// name_of_your_tag
//======================================================================
$tags_view['name_of_your_tag'] = function()
{
    $action_tag = 'name_of_your_tag';
    $content    = ''; // let this empty
    
    //-----------------------------------------------------
    // restricted access
    //-----------------------------------------------------
    if (defined("AUTH_ACCESS_FRT/BCK") && (AUTH_ACCESS_FRT/BCK != 0)) {
        /**
         * theme language for this tag
         */
        $action_lang_auth   = THEME_LANG_FRT/BCK; // (default: THEME_LANG_FRT/BCK)
        /**
         * theme folder for this tag
         */
        $action_folder_auth = THEME_FOLDER_FRT/BCK; // (default: THEME_FOLDER_FRT/BCK)
        /**
         * theme tpl for this tag
         */
        $action_tpl_auth    = '_all'; // '_all'|'tpl_name' (default: '_all')
        /**
         * cache activation for this tag
         */
        $cache_active       = 1; // 0|1 (default: 1)
        
        if ((defined("THEME_LANG_FRT/BCK") && isset($action_lang_auth))
        && (defined("THEME_FOLDER_FRT/BCK") && isset($action_folder_auth))
        && (defined("TPL_AUTH_FRT/BCK") && isset($action_tpl_auth))) {
        if ((THEME_LANG_FRT/BCK == $action_lang_auth
        || $action_lang_auth == '_all')
        && (THEME_FOLDER_FRT/BCK == $action_folder_auth
        || $action_folder_auth == '_all')
        && (TPL_AUTH_FRT/BCK == $action_tpl_auth
        || $action_tpl_auth == '_all')) {
            	
            	///////////////////////////
                // ADD YOUR LOGIC CODE HERE
                ///////////////////////////
                $content .= '';
                ///////////////////////////
                
                /**
                 * cache
                 */
                if (defined('UPDATE_CACHE_TAGS_OUTPUTS_FRT/BCK')
                && UPDATE_CACHE_TAGS_OUTPUTS_FRT/BCK === 1) {
                    Fxr_lib\Cache::updateCacheTagsOutputs(
                    $action_tag, $content, $cache_active);
                }
                return $content;
            } else {
                return '{' . $action_tag . '}';
            }
        } else {
            return '{' . $action_tag . '}';
        }
    //-----------------------------------------------------
    // public access
    //-----------------------------------------------------
    } else {
        /**
         * theme language for this tag
         */
        $action_lang   = THEME_LANG_FRT/BCK; // (default: THEME_LANG_FRT/BCK)
        /**
         * theme folder for this tag
         */
        $action_folder = THEME_FOLDER_FRT/BCK; // (default: THEME_FOLDER_FRT/BCK)
        /**
         * theme tpl for this tag
         */
        $action_tpl    = '_all'; // '_all'|'tpl_name' (default: '_all')
        /**
         * cache activation for this tag
         */
        $cache_active  = 1; // 0|1 (default: 1)
        
        if ((defined("THEME_LANG_FRT/BCK") && isset($action_lang))
        && (defined("THEME_FOLDER_FRT/BCK") && isset($action_folder))
        && (defined("TPL_FRT/BCK") && isset($action_tpl))) {
        if ((THEME_LANG_FRT/BCK == $action_lang
        || $action_lang == '_all')
        && (THEME_FOLDER_FRT/BCK == $action_folder
        || $action_folder == '_all')
        && (TPL_FRT/BCK == $action_tpl || $action_tpl == '_all')) {
                
                ///////////////////////////
                // ADD YOUR LOGIC CODE HERE
                ///////////////////////////
                $content .= '';
                ///////////////////////////
                
                /**
                 * cache
                 */
                if (defined('UPDATE_CACHE_TAGS_OUTPUTS_FRT/BCK')
                && UPDATE_CACHE_TAGS_OUTPUTS_FRT/BCK === 1) {
                    Fxr_lib\Cache::updateCacheTagsOutputs(
                    $action_tag, $content, $cache_active);
                }
                return $content;
            } else {
                return '{' . $action_tag . '}';
            }
        } else {
            return '{' . $action_tag . '}';
        }
    }
};

Simple example with no sub-template called:

#Example 1
$tags_view['current_date'] = function()
{
    $action_tag = 'current_date';
    ...
    // displays current date
     $content .= date('Y-m-d');
    ...
};

TPL file → defined in page_theme_tpl_frt/bck in DB:

<html>
<body>
<p>{current_date}</p>
</body>
</html>

More complex example with sub-template called:

#Example 2
$tags_view['articles'] = function()
{
    action_tag = 'articles';
    ...
    // loop to display articles
    $content .= Fxr_lib\Template::loadSubTemplates(
    '_all' . DS . 'content' . DS . 'sub_template_file', '',
    Fxr_lib\Database::loadQuery('select',
    "SELECT foo_title_frt, foo_content_frt
    FROM " . DB_PREFIX . "foo_table_frt
    WHERE foo_id_frt =  '" . GET_FOO_ID_FRT . "'",
    '+', ''), '', 1);
    ...
};

TPL file → defined in page_theme_tpl_frt/bck in DB:

<html>
<body>
{articles}
</body>
</html>

Sub-TPL file → defined in loadSubTemplates method:

<h1>{{foo_title_frt}}</h1>
<p>{{foo_content_frt}}</p>
<hr>

TPL and sub-TPL files are all located in Themes folder.