Question

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>
Was it helpful?

Solution

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>')
;
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top