Yii Framework Forum: Register Script File In End Of Head Tag - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Register Script File In End Of Head Tag Register Script File in end of Head Tag Rate Topic: -----

#1 User is offline   John Aston 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 21-January 14

Posted 13 February 2014 - 05:26 AM

i have code look like this:
// Add css files
		$cs = Yii::app()->clientScript;
		$cssFile = CHtml::asset(dirname(__FILE__).DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'mycss.css');
		$cs->registerCssFile($cssFile,CClientScript::POS_HEAD);
        
        // Add js files
        $jsFile = CHtml::asset(dirname(__FILE__).DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'myjs.js');
		$cs->registerScriptFile($jsFile,CClientScript::POS_HEAD);

but when render:
<head>
    <link rel="stylesheet" type="text/css" href="/store/assets/7e658267/mycss.css" />
    <script type="text/javascript" src="/store/assets/d826f7e/myjs.js"></script>
    <title>My Title</title>
    <link rel='stylesheet' media="screen" href='/store/themes/classic/css/normalize.css'/>
    <link rel='stylesheet' media="screen" href='/store/themes/classic/css/style.css'/>
    <script type="text/javascript" src="/store/themes/classic/js/jquery.js"></script>
    <link rel="shortcut icon" href="/store/themes/classic/images/favicon.png"/>
</head>

the file is not added to the end of head tag, somebody can help me?
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,598
  • Joined: 04-March 10
  • Location:UK

Posted 13 February 2014 - 06:46 AM

I believe they're inserted relative to the title tag. Try moving your other style sheet and script tags above the title tag and it should do what you need.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users