Yii Framework Forum: ClientScript and AssetManager - Yii Framework Forum

Jump to content

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

ClientScript and AssetManager Rate Topic: -----

#1 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 25 July 2010 - 04:02 PM

Hi!

I try to understand how AssetManager works. I delete all folders from asset folder, and then just update my main page. After that only one folder has been created 56dbe7a5. When I look into it, I saw there about 15 javascript files and some folders:

Posted Image

But I haven't any plugins in my main page. I just include some css styles and jquery core.
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/screen.css', 'screen'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/blueprint/print.css', 'print'); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/self.css'); ?>


But even 'em is not in asset folder. CSS files are places in css folder in the root, and jquery is from google library:
'clientScript' => array(
    'scriptMap' => array(
        'jquery.js' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js',
        'jquery.min.js' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js',
    ),
),


So I can't understand why these scripts has been copied into asset folder.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 25 July 2010 - 04:23 PM

Are you using grids or other Zii components?
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#3 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 25 July 2010 - 05:13 PM

No. On the main page no of that. I even write the menu manually.
0

#4 User is offline   Lex 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 31-October 09

Posted 25 July 2010 - 07:32 PM

Some code from CClientScript
/**
	 * Returns the base URL of all core javascript files.
	 * If the base URL is not explicitly set, this method will publish the whole directory
	 * 'framework/web/js/source' and return the corresponding URL.
	 * @return string the base URL of all core javascript files
	 */
	public function getCoreScriptUrl()
	{
		if($this->_baseUrl!==null)
			return $this->_baseUrl;
		else
			return $this->_baseUrl=Yii::app()->getAssetManager()->publish(YII_PATH.'/web/js/source');
	}



And you have
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

0

#5 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 25 July 2010 - 07:39 PM

Thanks Lex. I guess I need to use setCoreScriptUrl method in this case, but what directory should I pass into it :blink:
0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 26 July 2010 - 02:18 AM

If you want to disable asset publishing by clientScript completely, you can set a dummy value to coreSrciptUrl in your configuration. I use for example a custom js compressor in some projects and thus disabled script publishing completely in production mode like this:


        'clientScript'=>array(
            'coreScriptUrl'=>'dummy value', // required to prevent asset publishing of core scripts
            'scriptMap'=>array(
                '*.js'=>false,
                '*.css'=>false,
            ),
        ),

1

#7 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 26 July 2010 - 07:17 AM

Thanks Mike. It works, but if I write:
'*.js'=>false, '*.css'=>false,


it does not publicate any script and styles at all. You maybe brings all javascript files together in one file, and the same with CSS, and then pulicate ones manually. I wanna do this too but dont know the right way.

I saw an extension for it, but I could not make it working.
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