You have a blog.
You want certain combinations of symbols (i.e. :), :(, :p ...) to be parsed into emoticons before the post in the blog are printed on the screen.
Should this parsing be a responsibility of the Model, the View or the Controller?
You have a blog.
You want certain combinations of symbols (i.e. :), :(, :p ...) to be parsed into emoticons before the post in the blog are printed on the screen.
Should this parsing be a responsibility of the Model, the View or the Controller?
Do you want to store them parsed or raw?
If the former, the controller or model, depending on how fat or thin you are. If the latter, the view.
Use a View Helper. The helper should have a function that parses for the emoticons.
Think of this parsing as formatting for output, therefore, it should be handled in the View.
If you want to store them raw, then it belongs to the View.
A View Helper is one choice. Another would be a custom ob_handler that post-processes the rendered HTML before it is delivered. Since you mentioned, the post might also contain BBCode, you could also consider using a BBCode parser, which would handle the emoticons as well.
Personally, I think emoticons are so useless, that the server shouldnt be bothered with it. So I'd probably put that responsibility in a JavaScript that will parse and replace on page load. Did a quick Google and think you could use http://benalman.com/projects/javascript-emotify/