I have been trying to implement twitter bootstrap extension in Yii but cannot do it.
I am following the guide below to install it with Yii.
http://www.cniska.net/yii-bootstrap/setup.html
I copied and pasted the following code in my main config file as described in above guide.
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
return array(
'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
'modules'=>array(
'gii'=>array(
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
);
Can anyone please help.
Found the answer you need to put the following in your main.php file of your protected/views/layouts folder anywhere between <head> and </head> tag.
<?php Yii::app()->bootstrap->registerAllCss(); ?>
It worked for me like a piece of cake. I guess problem with you is your path to bootstrap extension. I would suggest to put complete path instead of relative path. Once it get working you can try to make the path relative.
Example:
Yii::setPathOfAlias('bootstrap', '/var/www/yoursite/application/extensions/bootstrap');
Instead of:
Yii::setPathOfAlias('bootstrap', dirname(FILE).'/../extensions/bootstrap');
This should work for you! Cheers!!!
I am also use that but the answer is not come but I got another way so you follow that I tell.
I think you want new themes so"
Go to download themes from yii framework.
Copy that folder then past to themes folder
config->main.php->'theme'=>'grey-stripes', protected go config folder go main.php go and copy 'theme'=>'grey-stripes',
Your new themes are ready
Related
I moved working plugin from /plugins/pluginname directory to /vendor/myname/pluginname
URL on which I call plugin controller is
http://domain.local/pluginname/index
Before moving from first directory to another, plugin was working as expected. I moved plugin to new directory to make it reusable for other cake PHP apps.
Plugin is installed by composer.
Why do I have message
"Error: Controller class Index could not be found.". All controllers
from plugin are not visible on app, throws the same error. Error is
thrown from line 79 from file
\vendor\cakephp\cakephp\src\Routing\Dispatcher.php
In main bootstrap.php file I put this line:
Plugin::load('MyName/PluginName', ['bootstrap' => false, 'routes' => true]);
Why plugin in vendor directory is not working in my case?
If plugin is installed by Composer, do not move it.
Whether it is installed at the plugin or vendor folder is determined by the author of the plugin.
If you need to fully load the Plugin in your bootstrap, simply use
Plugin::load('PluginName', ['bootstrap' => false, 'routes' => true]);
See http://book.cakephp.org/3.0/en/plugins.html#plugin-configuration
It will simply work regardless if Composer places it in vendor or plugins folder.
Most importantly, leave it in the folder that the author intended it to be in.
Lastly, check that your plugin is suitable for CakePHP 3.x
As for the url, you should expect to use /plugin-name/controller/action
See http://book.cakephp.org/3.0/en/plugins.html#plugin-controllers and I quote
If you want to access what we’ve got going thus far, visit /contact-manager/contacts
You can try by setting autoload variable true.Add below code in bootstrap.php, clear cache and then check.
Plugin::load('PluginName', ['autoload' => true]);
I have been using the CodeIgniter i18n library by Jérôme Jaglale (http://maestric.com/en/doc/php/codeigniter_i18n), which works great for my project.
But since I need to write separate modules, I recently added CodeIgniter Modular Extensions ( https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc ) and the navigation breaks.
How can I solve this issue please, I would love to use both the i18n library & Modular Extensions.
I think my application navigation fails to work because i18n library introduces adds a language segment in the site url, in my case my url is localhost/index.php/en/home and after adding Modular Extensions, my navigation/links stop working.
Thank you in advance.
Recently, I try to use HMVC with i18n and have similar problem. Below is my solution.
1.first you need to go to here HMVC select "Branches" to download HMVC extension, don't download the one on github it might not work.
2.Unzip HMVC extension inside the folder copy two files "MY_Loader.php" and "MY_Router.php" from core folder to Codeigniter's "application/core" after that copy "MX" folder from "third_party" to Codeigniter's "application/third_party". By this point your HMVC is installed, however it will not work because i18n cause the problem so if you run your website it might not display.
3.You need to get new version of i18n which support both HMVC and none HMVC, the old version of i18n seems not support HMVC. Go to here i18n download it and take time to read the description on github.
4.Before this step I suggest you to backup "application/core/MY_Config.php" and "application/core/MY_Lang.php" in case something goes wrong you can reverst back. Unzip i18n inside folder copy file "language.php" from config folder to Codeigniter's "application/config", copy two files "MY_Config.php" and "MY_Lang.php" from core folder to Codeigniter's "application/core", finally copy "MY_language_helper.php" from helpers folder to Codeigniter's "application/helpers". So far you have new i18n installed, but you need to configure it to make it work, otherwise you might get error message.
5.Open "application/core/MY_Config.php" and replace the line require_once APPPATH . "libraries/MX/Config.php"; to require_once APPPATH . "third_party/MX/Config.php"; then open "application/core/MY_Lang.php" replace the line require APPPATH . "libraries/MX/Lang.php"; to require APPPATH . "third_party/MX/Lang.php";. Why? because it point to the wrong directory, the MX folder is located in "third_party" not "libraries" in case you don't know, if you don't change it you might get error message.
6.To add new language(Not create language file) you need to open "application/config/language.php". You see at top the code block with comment says "Supported Languages" there already have English and Russian language configure for you just need to copy the template and change to the language you want, it's very easy. Be aware folder's name must exactly the same as folder in "application/language".
7.According to i18n github description you need to add these line
$route['^(en|de|fr|nl)/(.+)$'] = "$2";
$route['^(en|de|fr|nl)$'] = $route['default_controller'];
to the "application/config/routes.php". Be aware this line $route['^(en|de|fr|nl)/(.+)$'] = "$2"; in old i18n probably is $route['^(en|de|fr|nl)/(.+)$'] = "$1"; the difference is "$1" have to change to "$2", otherwise you will got problem.
8.To create language file is same as the method you did in old i18n. Now test your website with multi-language to make sure everything work fine.
9.Create your module. How? Create a folder name "modules" inside Codeigniter's application folder, inside modules folder you can start to create your module. That's say you want to create a module call foo, you just need to create a folder name it "foo" and then inside foo folder you can create three folders controllers, models and views. Create a php file with name foo with the code below
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Foo extends MX_Controller
{
public function index()
{
echo "<h1>class foo this is module test</h1>";
}
}
Enter url to run your module, if you see "class foo this is module test" then it work.
Remember module class must extends from MX_Controller.
If you still encounter any problem just ask.
I have been debugging this for quite some time and am unable to find any solution - so this is my last hope.
I am trying to install/configure an extension for Yii called minScript by following this installation guide.
I place the extracted extension in my extensions folder, and change the config/main.php to the following:
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Demo app',
'controllerMap'=>array(
'min'=>array(
'class'=>'ext.minScript.controllers.ExtMinScriptController',
),
),
...
// application components
'components'=>array(
'clientScript'=>array(
'class'=>'ext.minScript.components.ExtMinScript',
'minScriptDebug'=>true,
),
...
Although when I try to run it, I get an error message:
CException
Alias "ext.minScript.components.ExtMinScript" is invalid. Make sure it points to an existing PHP file and the file is readable.
The file exists in the defined folder and is readable, yet the error message always appears.
Anyone have any idea what I am doing wrong?
If your installation is on Linux, be careful with spelling in file and directory names. I wasted a lot of time trying to solve the same problem with views and other components or extensions,
If not, try removing:
'minScriptDebug'=>true,
From your 'components' block.
Also assets and protected/runtime should be writtable (recursively).
Your file structure should look like:
protected/extensions/minScript/
components/
ExtMinScript.php
controllers/
ExtMinScriptController.php
vendors/...
minify/...
And finally maybe you have a trouble with urls, routing rules or with your .htaccess / web server setup. In first case, in config/main.php I use all the urls with format domain.com/site/parm1/parm2 and adding this before routing rules solved the trouble:
'urlManager'=>array(
'urlFormat'=>'path',
EDIT: I forgot this:
'controllerMap' section should be after 'components' in config/main.php,
Good luck!
Try insert before return (you need to declare alias ext - set it on extension directory):
Yii::setPathOfAlias('ext',
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'extension';
I'm using the asset library that comes with pyrocms for my cms and I have a set up like this for my assets. I am trying to figure out with the paths and namespacing how I can access the bootstrap.css file correctly with the documentation.
http://docs.pyrocms.com/2.1/manual/developers/tools/assets
I have updated my asset.php configuration file to look like this:
$config['asset_paths'] = array(
'core' => 'assets/',
'globals' => 'assets/globals/'
);
This is the line I have set up in my template page to try and retrieve the bootstrap file:
<?php Asset::css('globals::bootstrap/css/bootstrap.min.css'); ?>
This is my file directory:
/root
/assets
/globals
/bootstrap
/css
bootstrap.css
It is saying the following error message.
Found no files matching
assets/globals/css/bootstrap/css/bootstrap.min.css
Any ideas on what I good fix would be for this?
I've never used the library in question, but judging on your post it appears that the library automatically checks for a css folder within the designated asset_path.
I would create a new asset path called bootstrap:
'bootstrap' => 'assets/globals/bootstrap/'
and add the CSS file as such:
Asset::css('bootstrap::bootstrap.min.css');
I want to use a central CI setup for multiple sites. The way I handle this is I created a package called MPACK and added it to autoload in the config file of each site.
Folder Structure:
/main
/system (CI 2 System folder)
/MPACK
/site1
/application
site2
/application
Inside this MPACK I have share libraries, models, helpers, etc.
However, I would like to have an extended MY_Form_Validation that would be common to ALL sites. Adding the class file to /MPACK/libraries fails. Adding it to /site1/application works fine, as expected.
Is there any way to do this extending inside MPACK?
Thank you for your time.
Please try this:
// Placed your MY_Form_validation.php under MPACK/libraries
$this->load->add_package_path('/path/to/MPACK');
$this->load->library('form_validation');
You can get more information from CodeIgniter User Guide - Loader Class. :)
You can also autoload your package in /application/config/autoload.php : $autoload['packages'] = array('/path/to/MPACK');
EDIT: turn out that the above solution doesn't work, because Loader always look for APPPATH & BASEPATH first, and I not sure modifying this core class won't break something. Here is another solution in theory:
You should have your MPACK form validation lib, and sites' form validation lib should be symlinks to the MPACK one:
/site1/application/MY_Form_validation.php -> /MPACK/libraries/MY_Form_validation.php
If you just use everything from MPACK, nothing specifically for /site1 or /site2, just make a folder link:
/site1/application/libraries/ -> /MPACK/application/libraries/
Hope this help =)
You can read more here: http://codeigniter.com/wiki/Multiple_Applications_via_Symlinks/