CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#12853] admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function

avatar
Created By: Philippe Thomas (filto)
Date Submitted: Sat Sep 12 23:59:12 -0400 2026

Assigned To: Fernando Morgado (JoMorg)
Version: 2.2.24
CMSMS Version: 2.2.24
Severity: Minor
Resolution: Works For Me
State: Open
Summary:
admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function
Detailed Description:
admin/listtags.php : directories bad config.php key for assets and Cannot
redeclare smarty_function

L47 $dirs[] = $config['root_path'].'/assets/plugins';
### assets plugin directory do not match if $config['assets_path'] is customised
in config.php

L48 $dirs[] = $config['root_path'].'/plugins';
### directory deprecated

admin/listtags.php : 
from L 46 to 51

$dirs = [];
$dirs[] = $config['root_path'].'/assets/plugins';
$dirs[] = $config['root_path'].'/plugins';
$dirs[] = $config['root_path'].'/lib/plugins';
$dirs[] = $config['admin_path'].'/plugins';
$config = cmsms()->GetConfig();

corrected :

$dirs = [];
$dirs[] = $config['assets_path'].'/plugins'; // good assets plugins directory
$dirs[] = $config['root_path'].'/plugins'; // deprecated
$dirs[] = $config['root_path'].'/lib/plugins';
$dirs[] = $config['admin_path'].'/plugins';
$config = cmsms()->GetConfig();


now, if I want to modify an existing plugin, this way for exemple :
copy lib/plugins/function.cms_stylesheet.php
to assets/plugins/function.cms_stylesheet.php (and do some modifications)

result:

Fatal error: Cannot redeclare smarty_function_cms_stylesheet() (previously
declared in....

admin/listtags.php L110 to 119

$files = array();
    foreach( $dirs as $one ) {
        $files = array_merge($files,glob($one.'/*.php'));
    }

    if( is_array($files) && count($files) ) {
        $file_array = array();
        foreach($files as $onefile) {
            $file = basename($onefile);
            $parts = explode('.',$file);

#### problem : plugins are merged even if already exist

### corrected

$files = array();
    foreach( $dirs as $one ) {
        foreach (glob($one.'/*.php') as $pluginfilepath){
            //get plugin name as key
            $files[basename($pluginfilepath)] = $pluginfilepath;
        }
        unset($pluginfilepath);
    }

    if( is_array($files) && count($files) ) {
        $file_array = array();
        foreach($files as $file => $onefile) {
 //add $file as already formated key
            $parts = explode('.',$file);

then works as expected



also assets plugin directory do not match if $config['assets_path'] is
customised in config.php

in lib/classes/internal/class.Smarty_CMS.php L 237

// plugins with the smarty_cms_function
$cachable = TRUE;
$dirs = [];
$dirs[] =
cms_join_path(CMS_ROOT_PATH,'assets','plugins',$type.'.'.$name.'.php');
$dirs[] = cms_join_path(CMS_ROOT_PATH,'plugins',$type.'.'.$name.'.php');

--------corrected------------------

// plugins with the smarty_cms_function
$cachable = TRUE;
$dirs = [];
$config = cms_config::get_instance(); // get config
$dirs[] =
cms_join_path(CMS_ROOT_PATH,$config['assets_dir'],'plugins',$type.'.'.$name.'.php');
// good assets plugins directory
$dirs[] = cms_join_path(CMS_ROOT_PATH,'plugins',$type.'.'.$name.'.php'); //
deprecated

------------------------
Note in 
https://docs.cmsmadesimple.org/configuration/config-file/config-reference#config_assets_url

assets_url
 seem to be use nowhere and not set

so there is no default value




History

Updates

Updated: 2026-09-15 17:35
description: admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function L47 $dirs[] = $config['root_path'].'/assets/plugins'; ### assets plugin directory do not match if $config['assets_path'] is customised in config.php => admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function L47 $dirs[] = $config['root_path'].'/assets/plugins'; ### assets plugin directory do not match if $config['assets_path'] is customised in config.php

Updated: 2026-09-13 21:29
description: admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function L47 $dirs[] = $config['root_path'].'/assets/plugins'; ### assets plugin directory do not match if $config['assets_path'] is customised in config.php => admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function L47 $dirs[] = $config['root_path'].'/assets/plugins'; ### assets plugin directory do not match if $config['assets_path'] is customised in config.php
resolution_id: => 11