0

In my view I have this part:

$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);

And this is repeating 3 times for 3 different types of articles (this is needed, no way around this). My question here is: Is it good to call custom library inside view or bad? Is there some other way beside this and writing function in view controller (I also need this function in few other view files)?

Sasha
  • 7,725
  • 21
  • 78
  • 154
  • It's confusing when you use the terms `view controller`. Is that code in a view or in a controller? If it's in the view, did you try to [create an helper](http://stackoverflow.com/a/804520/423235)? – Maxime Morin Dec 18 '12 at 16:16
  • Ooops, my bad :D. This is in view part. – Sasha Dec 18 '12 at 16:16

1 Answers1

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.

Aidas
  • 1,133
  • 2
  • 8
  • 15