View Issue Details

IDProjectCategoryView StatusLast Update
0006959OXID eShop (all versions)1. ----- eShop frontend -----public2023-11-15 15:38
ReporterHelmut L. Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionwon't fix 
Product Version6.1.1 
Summary0006959: User components not accessible in Smarty
DescriptionIn 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 Reproduceadd 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.
TagsComponents, Namespaces, Smarty
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

michael_keiluweit

2019-03-01 08:43

administrator   ~0012804

Last edited: 2019-03-01 08:50

edit: deleted my first answer as I missed an information.

QA

2019-03-01 10:37

administrator   ~0012805

Last edited: 2019-03-01 10:39

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

HR

2019-03-12 09:30

administrator   ~0012816

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');

SvenBrunk

2023-11-15 15:38

administrator   ~0015744

Smarty support will no longer be maintained