Best way to add code to the html headers

Let’s say all my pages use the same layout templates. Once in a while, for some specific controller/actions I want my HTML <header> to have some extra code (extra css, javascript, meta …).

What’s the conventional way to achieve this?

You can use the methods from CClientScript.registerX in the controller action:

  • registerMetaTag

  • registerCssFile

  • registerScriptFile

 function actionXY()