0

What is the best practice of using those yii CHtml::link and such others? I'm making a button which I need to have an icon some text and responds to hover events and it must be quite wide

Is there any advantage of using CHtml over regular tag which I can quickly customise using some CSS and jquery?

Hive7
  • 3,599
  • 2
  • 22
  • 38
David
  • 4,332
  • 13
  • 54
  • 93
  • You might as well ask, what the purpose of using a framework in the first place is, if you want to do stuff that it has designated methods for yourself … – CBroe Mar 15 '14 at 18:19
  • Well on the level of MVC I understand the good side of using framework, but when it comes down to customizing small things like buttons, I don't understand what CHtml::link can give me? because it draws button in it's own style, and I want mine, so I think it's better to use straight html+css in this case no ? – David Mar 15 '14 at 18:31
  • Well for example it will give you automatic escaping of values where necessary. But yes, those methods are maybe more intended to handle _dynamic_ content/values (get link text form a database for example, or have the link href output dynamically according to current routing rules), whereas if you just have a static component you might as well implement that in your template in a static way as well. “It all depends” … and with such little info, there is no real saying of what might be “better” in general for the actual use case. – CBroe Mar 15 '14 at 18:37
  • Well I have a regular button to make. Just a hyperlink. But a stylish hyperlink. I mean a lot of styles: size, color, etc... That's why I was wondering if CHtml can give me some advantage of styling the button. – David Mar 15 '14 at 18:43

1 Answers1

1

You can use either, but if you're using the framework why not use the built in methods. If you're building a stylish button in the css. Just apply it to the CHtml::link(). It also means that should your routes ever change that they will automatically be updated.

Jonnny
  • 4,939
  • 11
  • 63
  • 93