0

在我看来,我有这部分:

$rep    = array(' ', '@', ',');
$naslov = strtolower(str_replace($rep, '_', $vest['naslov']));
$naslov = str_replace('"', '', $naslov );
$text   = html_entity_decode(word_limiter(($vest['opis']),63));
$text   = preg_replace("/<img[^>]+>/i", "", $text);
$text   = str_replace('\n', '<br>', $text);

这对 3 种不同类型的文章重复了 3 次(这是必需的,没有办法解决这个问题)。我的问题是:在视图中调用自定义库是好还是坏?除了这个和在视图控制器中编写函数之外还有其他方法吗(我在其他几个视图文件中也需要这个函数)?

4

1 回答 1

0

I don't see why it would be bad to call library's static method to do this for you. If you don't want a library, you can include your custom helper. If you think your view would be too overloaded, then you can refactor your code to have all ops happening in the controller and the view would only have a very final data.

于 2012-12-18T16:16:40.757 回答