Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created July 4, 2012 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacquesbh/3046344 to your computer and use it in GitHub Desktop.
Save jacquesbh/3046344 to your computer and use it in GitHub Desktop.
Magento - Grid column decorator for 'actions' depending on row
<?php
/**
* Decorate the actions column
* @access public
* @return string
*/
public function decorateActionColumn($value, $row, $column, $isExport)
{
$links = array();
foreach ($column->getActions() as $action) {
if (isset($action['condition_method']) && !$row->{$action['condition_method']}()) {
continue;
}
if (isset($action['condition']) && !$row->getData($action['condition'])) {
continue;
}
$args = array();
$args['href'] = 'href="' . $this->getUrl($action['url'], array($column->getIndex() => $row->{$column->getGetter()}())) . '"';
$args['title'] = 'title="' . addslashes($action['caption']) . '"';
if (isset($action['onclick'])) {
$args['onclick'] = 'onclick="' . $action['onclick'] . '"';
}
if (isset($action['confirm'])) {
$args['onclick'] = 'onclick="return window.confirm(\''
. addslashes($this->htmlEscape($action['confirm']))
. '\')"';
}
$links[] = '<a ' . implode(' ', $args) . '>' . $action['caption'] . '</a>';
}
return implode(' ', $links);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment