0

If I have a method in my renderer class:

public function render(Varien_Object $row)
{
    $rowValue = $row->getData($this->getColumn()->getIndex());
    $data = unserialize($rowValue);

    $result = '';

    if (is_array($data) && count($data) > 0) {
        foreach ($data as $orderItemData) {
            $result .= $orderItemData['name'] . ' </br>';
        }
    }
    return $result;
}

How can I render a template file here and return it?

1 Answer 1

1

A basic example to point you in the right direction:

public function render(Varien_Object $row)
{
    $block = $this->getLayout()->createBlock('core/template');
    $block->setTemplate('path/to/template.phtml');
    return $block->toHtml();
}

The render function is returning the final html for the column in question so any string you return from this function is valid. And if you need to pass your column object to the newly created block, just add $block->setColumn($this) before calling the ->toHtml() method and the column object will be available to you in your new block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.