我在课堂上发现了这个问题 Magento\Framework\View\Layout\ScheduledStructure\Helper
有功能_generateAnonymousName
:
protected function _generateAnonymousName($class)
{
$position = strpos($class, '\\Block\\');
$key = $position !== false ? substr($class, $position + 7) : $class;
$key = strtolower(trim($key, '_'));
return $key . $this->counter++;
}
从scheduleStructure
函数调用:
public function scheduleStructure(
Layout\ScheduledStructure $scheduledStructure,
Layout\Element $currentNode,
Layout\Element $parentNode
) {
// if it hasn't a name it must be generated
if (!(string)$currentNode->getAttribute('name')) {
$name = $this->_generateAnonymousName($parentNode->getElementName() . '_schedule_block'); // CALL HERE
$currentNode->setAttribute('name', $name);
}
$path = $name = (string)$currentNode->getAttribute('name');
// Prepare scheduled element with default parameters [type, alias, parentName, siblingName, isAfter]
$row = [
self::SCHEDULED_STRUCTURE_INDEX_TYPE => $currentNode->getName(),
self::SCHEDULED_STRUCTURE_INDEX_ALIAS => '',
self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME => '',
self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME => null,
self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER => true,
];
$parentName = $parentNode->getElementName();
//if this element has a parent element, there must be reset [alias, parentName, siblingName, isAfter]
if ($parentName) {
$row[self::SCHEDULED_STRUCTURE_INDEX_ALIAS] = (string)$currentNode->getAttribute('as');
$row[self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME] = $parentName;
list($row[self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME],
$row[self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER]) = $this->_beforeAfterToSibling($currentNode);
// materialized path for referencing nodes in the plain array of _scheduledStructure
if ($scheduledStructure->hasPath($parentName)) {
$path = $scheduledStructure->getPath($parentName) . '/' . $path;
}
}
$this->_overrideElementWorkaround($scheduledStructure, $name, $path);
$scheduledStructure->setPathElement($name, $path);
$scheduledStructure->setStructureElement($name, $row);
return $name;
}
在这种情况下,块名称可以是:
before.body.end_schedule_block1
before.body.end_schedule_block2
- ...
我认为您应该在容器上没有名称的情况下定义总计块,并且需要在容器上删除订单块名称。
[Vendor_Module]::template.phtml