I have the following main.php config
'clientScript'=>array(
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'../www/js/jquery/',
'js'=>array('jquery.min.js'),
),
'jquery.ui'=>array(
'baseUrl'=>'../www/js/jquery/',
'js'=>array('jquery.ui.js'),
),
),
Both files are located in the same directory. The jquery script get loaded well but the jquery Ui does not.
Try This
public function registerAssets() {
Yii::app()->getClientScript()->registerCoreScript( 'jquery.ui' );
}
According to there site you can try followings
'clientScript' => array(
'scriptMap' => array(
'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js',
'jquery.min.js' => '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',
'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js',
),
),
you can replace your jui location if u have already it in local
but they suggest to not do that, if you are curious please go to [yii site]: http://www.yiiframework.com/wiki/259/serve-jquery-and-jquery-ui-from-google-s-cdn/
Related
I'm trying to setup hybrid auth on the Yii user management addon, the docs are here https://github.com/thyseus/yii-user-management/blob/master/user/docs/hybridauth.txt
according to this step
Take the modules/user/vendors/index.php, rename it to 'hybridauth.php' and place it
beside your application index.php bootstrap script. This will be your hybrid auth
entry script.
for this, there is NO index.php file in modules/user/vendors/index.php but there is one in modules/user/vendors/hybridauth/index.php which i renamed to hybridauth.php and put it in http://localhost/dev/ content of the hybridauth.php are
require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Auth.php" );
require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php" );
Hybrid_Endpoint::process();
now for this
Place the hybrid auth configuration file into your application
protected/config/hybridauth.php.
i took my modules/user/vendors/hybridauth/config.php and put it in protected/config/ and renamed config.php to hybridauth.php. the content looks like this
return
array(
"base_url" => Yii::app()->createAbsoluteUrl('/').'/hybridauth.php',
"providers" => array (
...........
"Google" => array (
"enabled" => true,
"keys" => array (
"id" => "ID",
"secret" => "SECRET",
),
),
"Facebook" => array (
"enabled" => true,
"keys" => array (
"id" => "ID",
"secret" => "SECRET",
),
"scope" => "email,user_birthday" // https://developers.facebook.com/docs/reference/login/
),
),
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
"debug_mode" => false,
"debug_file" => "",
);
problem is when i click say on the facebook icon on my login page, it shows my main page. (index.php)
here is the link it directs too
http://localhost/dev/index.php/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835
when i remove the index.php from the url
http://localhost/dev/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835
i get this error
You cannot access this page directly.
any idea what i'm doing wrong? Thanks
This sound like a routing problem in your configuration:
you might want to add a route for hybridauth.php and make sure it is only accessable by GET
for example :
'components'=>array(
......
'urlManager'=>array(
'showScriptName' => false,
'urlFormat'=>'path',
'rules'=>array(
'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
....
),
),
),
if anyone having the same problem, here is how i solved it:
by changing the base_url to point to the actual php file:
"base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php',
If you use YUM User Managment try to import
Yii::import('application.modules.profile.models.*');
on YumUserAuthController because profile cannot be found.
Is there a way to configure Yii such that it will no longer load any Javascript out of the Assets folder?
Make your own AssetManager or extend current
protected/components/DummyAssetManager.php:
class DummyAssetManager extends CApplicationComponent {
public function publish(){}
}
add into components array in
protected/config/main.php:
'assetManager'=>array(
'class'=>'DummyAssetManager',
),
You should consult the manual for a detailed description of
the assetManager options
I think you can try following option in your config/main.php
'components' => array(
'assetManager' => array(
'linkAssets' => true,
),
),
This will make asset files symbolic links to your original js/css sources. See linkAssets for more details on it.
If your PHP<5.3, or the OS it's running on doesn't support symbolic links, you won't be able to use 'linkAssets' option, in this case you can try:
'components' => array(
'assetManager' => array(
'forceCopy' => true,
),
),
This should update asset folder on every request. These two options are usually used during development process (btw, you can't use both) and should be removed from production.
PS: if you're sure that you haven't explicitly enabled ckeditor somewhere in your code and you're confident about your assetmanager calls throughout the code, check your layout and page for widgets that require this CKeditor, as Yii can't preload 'stuff' just randomly, it can be triggered by some preloaded component/extension or yii widget.
i'm new in Yii. and i'm using this LINK.
i'm extracted bootstrap on /blog/protected/extensions directory and define array into config/main.php like this:
//BOOT STRAP
'clientScript' => array(
'scriptMap' => array(
'jquery.js'=>false,
'jquery.min.js'=>false,
'core.css'=>false,
'styles.css'=>false,
'pager.css'=>false,
'default.css'=>false,
),
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/jquery.js'=>true /* SET AS DEFAULT*/ ),
),
'bootstrap'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/bootstrap.min.js',
'js/bootstrap-transition.js',
'js/bootstrap-alert.js',
'js/bootstrap-modal.js',
'js/bootstrap-dropdown.js',
'js/bootstrap-tab.js',
'js/bootstrap-tooltip.js',
'js/bootstrap-popover.js',
'js/bootstrap-button.js',
'js/bootstrap-collapse.js',
'js/bootstrap-carousel.js',
'js/bootstrap-typeahead.js',
'js/bootstrap-affix.js',
'js/holder.js',
'js/prettify.js',
'js/application.js',
),
'css'=>array(
'css/bootstrap.min.css',
'css/custom.css',
'css/bootstrap-responsive.min.css',
),
'depends'=>array('jquery'),
),
),
),
//BOOT STRAP
how to change 'baseUrl'=>'bootstrap/' to correct path of extension? this path does not work:
'baseUrl'=>'/protected/extensions/bootstrap/',
If you are new, learn about extensions.
Than download ready yii extension for bootstrap: Yii-Bootstrap or Yii-Booster.
You don't have to define any js package, bootstrap extension will do it for you.
Here is sample config part for yii-booster, which i use (actually for yii-bootstrap it should be same):
'components' => array(
// ... other components
'bootstrap' => array(
'class' => 'ext.bootstrap.components.Bootstrap',
'coreCss' => true,
'responsiveCss' => true,
'yiiCss' => true,
),
),
// .. other components
And thats it! Bootstrap will work.
I've added bootstrap Extension To my yii webapp and installed as described in setup Guide. All Folders in Extension Folder are rwrwrw but i get the error written above. What could be the reason? I've already dumped the path from yii::Import and that path was correct.
Thanks!
Edit With Code
This is my config:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
//Yii::setPathOfAlias('bootstrap', '/Users/gerritlober/Sites/yii/webapp/protected/extensions/bootstrap');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Carpool',
'theme' => 'bootstrap',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'xxx',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
/*
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=carpool_dev',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'enableProfiling' => true,
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
array(
'class'=>'CWebLogRoute',
'categories' => 'system.db.*,GLWeb.*,application.*'
),
),
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
My bootstrap extension is in ./protected/extensions/bootstrap
I was having the same problem. I granted full(777) permission to the folder.
Try it.
Update Component By :
ext.bootstrap.src.components.Bootstrap',
EG: If you are extracted under extension then follow above command:
Syntax: ext.path_to.Bootstrap
You have two options. One, in your config/main.php file, or equivalent, add the following line:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/yii-bootstrap');
Where you need to replace yii-bootstrap with whatever your bootstrap folder is actually called.
Or two, you can simply refer to the that bootstrap folder correctly in the first place. If your bootstrap installation is installed in /extensions/yii-bootstrap as mine is, then use this alias to load components:
ext.yii-bootstrap.components.Bootstrap
In short, your problem is likely you aren't defining the path to your installation correctly. Use one of the two above solutions so remedy that problem.
I need to use a file manager in pop up which comes on a button click. I am using Yii extension elfinder. I am finding it hard to understand the way of using it. I downloaded the code from bitbucket, put it inside my application in the folder extension. I try to test it using new controller, named it elfcontroller and put the following code (got from the website)
class ElfinderController extends CController
{
public function actions()
{
return array(
'connector' => array(
'class' => 'ext.elFinder.ElFinderConnectorAction',
'settings' => array(
'root' => Yii::getPathOfAlias('webroot') . '/uploads/',
'URL' => Yii::app()->baseUrl . '/uploads/',
'rootAlias' => 'Home',
'mimeDetect' => 'none'
)
),
);
}
}
and i created one more function for rendering the index page(i want the file manager to be in this page)
in the view i wrote the following code
$model = new xxxmodel();
$this->widget('ext.elFinder.ElFinderWidget', array(
'model' => $model,
'attribute' => 'serverFile',
'connectorRoute' => 'admin/elfinder/connector',
)
);
and i included a div for containing it
But i am getting the following error
Alias "ext.elFinder.ElFinderWidget" is invalid. Make sure it points to an existing PHP file and the file is readable.
i tried to include alias in config/main.php
I know i am messing some where with the folder structure
here is the path i am using the extension
C:\xampp\htdocs\project\protected\extensions\ext.elfinder
I returned empty after google searches, can any one please explain me how to use this extension to place the code exactly where it is needed to be?
In general the extensions folder already has the ext alias, so you don't need to set an alias for it.
Then the extension itself should be placed in the extensions folder, somewhat like : project/extensions/extension-name/ . In your case it should be: project\extensions\elFinder , and keep the rest of your code same, i.e continue referring to extension like:
ext.elFinder.ElFinderWidget