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 | 2023-11-15 15:38 |
Reporter | Helmut L. | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | won't fix | ||
Product Version | 6.1.1 | ||||
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 | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database 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: \OxidEsales\EshopCommunity\Application\Component\Widget\ArticleDetails: 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. -MK |
|
There's a workaround for adding own namepaced components. Example: <?php namespace HkReuter\OxSampleModule\Application\Component; /** * Register own component in config.inc.php: * * class_exists(\HkReuter\OxSampleModule\Application\Component\OxSample::class); * $this->aUserComponentNames = ['oxcmp_oxsample' => 1]; */ class OxSample extends \OxidEsales\Eshop\Application\Controller\FrontendController { .... } /** * Class alias is needed to make this work in templates. */ class_alias(\HkReuter\OxSampleModule\Application\Component\OxSample::class, 'oxcmp_oxsample'); |
|
Smarty support will no longer be maintained |