Archived
1
0
Fork 0

moving taglist generation to view helper

This commit is contained in:
Henrik Hautakoski 2010-11-01 15:37:22 +01:00
parent 0644ac3ac8
commit 78265e8044
2 changed files with 18 additions and 16 deletions

View file

@ -10,21 +10,10 @@
<?=$post->getContent() ?>
</div>
<?php
if ($post->getTags()) {
echo '<div class="tags">';
$tagList = '';
foreach ($post->getTags() as $k => $t) {
$tagList .= '<a href="'.$this->url(array('controller' => 'archive','action' => 'filter', 'tag' => $t), 'blog').'">'.$t.'</a>, ';
}
echo substr($tagList,0,-2);
echo '</div>';
}
?>
<?php if ($post->getTags()) : ?>
<div class="tags">
<?=$this->tagList($post->getTags(), array('controller' => 'archive', 'action' => 'filter'), 'blog') ?>
</div>
<?php endif ?>
</div>
<?php endforeach; ?>

View file

@ -0,0 +1,13 @@
<?php
class Fiktiv_View_Helper_TagList extends Zend_View_Helper_Abstract
{
public function taglist(array $list, array $url, $route = null)
{
foreach($list as $k => $v) {
$url['tag'] = $v;
$list[$k] = '<a href="' . $this->view->url($url, $route) . '">' . $v . '</a>';
}
return implode(', ', $list);
}
}