有っても仕方ないと言われそうなもの
<?php echo $html->link(__('Delete', true), array('action'=>'delete', $user['User']['dbid']), null, sprintf(__('Are you sure you want to delete # %s?', true), $user['User']['dbid'])); ?>
を、なんとなーく実現したかったけどAタグ書くのが面倒だったのでプラグインにしておきました。
{link url=$html->url($this->aa('action','view','0',$user.User.dbid)) label=$this->i18n('View', true)}
{link url=$html->url($this->aa('action','delete','0',$user.User.dbid)) confirm="`$user.User.dbid`を削除しますか?" label=$this->i18n('Delete', true)}
こんな感じ。
<?php function smarty_function_link($params, &$smarty) { $url = null; $confirm = null; $label = null; foreach($params as $_key => $_val) { switch($_key) { case 'url': case 'label': case 'confirm': $$_key = (string)$_val; break; default: $smarty->trigger_error("link_confirm: extra attribute '$_key' not use.", E_USER_NOTICE); break; } } if (!isset($url) && !isset($label)) return ''; /* raise error here? */ if ( isset($confirm) ) { $_html_result = sprintf ( '<a href="%s" onClick="return confirm(\'%s\');">%s</a>', $params['url'], $params['confirm'], $params['label']); } else { $_html_result = sprintf ( '<a href="%s">%s</a>', $params['url'], $params['label']); } return $_html_result; } ?>