moving taglist generation to view helper
This commit is contained in:
parent
0644ac3ac8
commit
78265e8044
2 changed files with 18 additions and 16 deletions
|
|
@ -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; ?>
|
||||
13
library/Fiktiv/View/Helper/TagList.php
Normal file
13
library/Fiktiv/View/Helper/TagList.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in a new issue