View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006959||OXID eShop (all versions)||1. ----- eShop frontend -----||public||2019-02-28 10:55||2019-03-12 09:30|
|Target Version||Fixed in Version|
|Summary||0006959: User components not accessible in Smarty|
|Description||In the aUserComponentNames array you must provide the class name with the complete namespace. When the components are then assigned to smarty the class name with the namespace is used as the name of the variable in the template. This leads to a variable name that is inaccessible in smarty because it contains backslashes.|
|Steps To Reproduce||add a namespaced class to aUserComponentNames|
$this->aUserComponentNames['\tc\test'] = 1;
This class would now be available in smarty under the name $\tc\test, which will immediately cause a template error due to the backslashes in the name.
|Tags||Components, Namespaces, Smarty|
|PHP Version||Not defined|
|MySQL Version||Not defined|
edit: deleted my first answer as I missed an information.
As of now using class names with namespaces aren't working as key names when registering them for own components. Currently you still have to use the class names without the namespaces. For example the shop does it too:
protected $_aComponentNames = ['oxcmp_cur' => 1, 'oxcmp_shop' => 1, 'oxcmp_basket' => 1, 'oxcmp_user' => 1];
Because the namespaces are the prefered way to got, but we still have the backwards compatibility layer, this requirement is a feature for now.
There's a workaround for adding own namepaced components.
* Register own component in config.inc.php:
* $this->aUserComponentNames = ['oxcmp_oxsample' => 1];
class OxSample extends \OxidEsales\Eshop\Application\Controller\FrontendController
* Class alias is needed to make this work in templates.