Create Block with setTagName nested
-
29-12-2020 - |
سؤال
I have this code:
$link = $this->getLayout()->createBlock('core/text_tag')
->setTagName('a')
->setTagParams(array(
'href' => '#',
'class' => 'link',
))
->setTagContents($text)
;
that creates a link <a href="#" class"link"></a>
how do I create a span element inside this type?
<a href="#" class"link"><span></span></a>
المحلول
Looking at the Mage_Core_Block_Text_Tag
class, I guess that the fastest (not the most elegant...) way to do that is :
$link = $this->getLayout()->createBlock('core/text_tag')
->setTagName('a')
->setTagParams(array(
'href' => '#',
'class' => 'link',
))
->setTagContents('<span>'.$text.'</span>')
;
لا تنتمي إلى magento.stackexchange