I’m banging my head to add a plain, simple link to a website on a custom column of a grid. I used the Inchoo blog to add a custom renderer for the column and it works. I though that just modifying the render and adding a tag will be enough. But my hopes were dashed, is not working.
How can be this done? Should be simple, but no way I can find how. I found lot of question/answers here in SO but about adding links to products, categories, etc, no reference to external websites, maybe I’m just using the wrong keywords in the search.
Here is the _prepareColumns() from my Grid.php
protected function _prepareColumns() {
$blog = Mage::getModel('blogtest/blog');
$this->addColumn('api_blog_url', array(
'header' => $this->__('URL'),
'align' => 'center',
'index' => 'api_blog_url',
'width' => 50,
'type' => 'text',
'renderer' => 'Dts_Blogtest_Block_Adminhtml_Blog_Renderer_MyRender'
));
....
And here is my render override for that column:
<?php
class Dts_Blogtest_Block_Adminhtml_Blog_Renderer_MyRender extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getData($this->getColumn()->getIndex());
// return '<a href="http://'.$value.'>'.$value.'</a>';
return '<span style="color:red;">'.$value.'</span>';
}
}
?>
You mean the style with color red it working properly but if you uncomment the line with the
<a href..>it is not?I think you just missed a quote in the href attribute.