diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 588cbe76d..656817efc 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -402,7 +402,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin return $noGetterData[$keyAttribute]; } - $getter = sprintf("get%s", ucfirst($attribute)); + $getter = sprintf("get%s", underscoreToCamelcase($attribute)); if (method_exists($data, $getter)) { $return = $data->$getter(); @@ -427,6 +427,26 @@ class DataAccessFunctions extends AbstractSmartyPlugin return ''; } + /** + * Transcode an underscored string into a camel-cased string, eg. default_folder into DefaultFolder + * + * @param string $str the string to convert from underscore to camel-case + * + * @return string the camel cased string. + */ + private function underscoreToCamelcase($str) { + // Split string in words. + $words = explode('_', strtolower($str)); + + $return = ''; + + foreach ($words as $word) { + $return .= ucfirst(trim($word)); + } + + return $return; + } + /** * Define the various smarty plugins hendled by this class *