Yii with Bootstrap error (CWebApplication.bootstrap not defined) - yii

I have followed this setup, but not work for me http://www.cniska.net/yii-bootstrap/setup.html, all CSS files do not give style to the page,
So searching I found this thread How to install bootstrap extension in yii using some tricks. But not work's too.
Now I have this error
'Property "CWebApplication.bootstrap" is not defined.'
Anyone can help or have any idea?
Thanks in advance and for my English.

Property "CWebApplication.bootstrap" is not defined.
The error means the system is trying to access Yii::app()->bootstrap, which could be a property on the application. Since bootstrap is a component it should be accessible, if the configuration is done properly.
This error is most likely because you forgot the following in the main config file:
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// This should point to the location you placed the files in for example extensions/bootstrap/components/bootstrap.php
The class location above will only work if the alias is set properly before setting the configuration.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
Instead you could also change "bootstrap.components.Bootstrap" into "application.extensions.bootstrap.components.bootstrap".

I strongly advise you to use Yiistrap, it was made by the person who create yii boostrap and the person who created Yiibooster. Yiistrap has everything from both extensions and more new stuff. here is the page http://www.getyiistrap.com , also has a fully documented API which yii boostrap do not have and it will save a lot of google searches.

Related

Piranha CMS: Problem with custom block in manager interface

I am trying to add a custom block. I followed the steps in following two links:
http://piranhacms.org/docs/extensions/blocks
and
http://piranhacms.org/docs/manager-extensions/resources
In the CMS manager, I added the custom block to a page, but the block content is empty. Looks like the Vue.js didn't get associated to the custom block. I have set the block component attribute to the Vue.js.
I added the Vue.js by calling below method in the startup. Did I miss something to create a custom block?
App.Modules.Get<Piranha.Manager.Module>().Scripts.Add("~/assets/js/myscripts.js");
Move your "mycustomblock.js" file to the folder "wwwroot/js/" instead of the default "assets/js/". That way the file will be visible to Vue.js
Something is not working with the assets folder, probably it cannot be reached by Vue.js
after the Project is compiled. I had the same problem and this solution worked for me.
void Configure in Startup.cs will then look something like this (I simplified the syntax a bit compared to the documentation):
App.Modules.Manager().Scripts.Add("~/js/mycustomblock.js");
Adding a custom block and many other tasks have been difficult for me. Trial and error, and no knowledgebase to fall back on. The documentation is a fantastic start, and "Step by step" guides would be a good idea for the future (but I guess time is very limited).

Yii2 "Page not found" when using CRUD generator

I have succesfully used Yii2 Model & CRUD Generators to obtain some skeleton code files for my web app. Particularly, the CRUD Generator claims to have succesfully created its view files into:
<yii_root>/basic/views/<my_view_name>/*.php
which I got by leaving "View Path" field blank.
However, browsing to:
https://<my_site_FQDN>/basic/web/index.php?r=<my_view_name>/index
spits a "Not Found (#404)" error and I'm unable to find any useful info in the Yii2 debug logs.
Any idea on this matter shall be welcome.
Antonio
<my_view_name> this is a terrible way of looking at this. Read about MVC.
You are creating controllers, routes are to controllers not to views. Stop looking if the views are there... look if the controller is there. You never interact with a view, you always do with a controller. So, is your controller there? are you sure you have created it?
Also what is the controller name? if you have something like ProductCategory then the correct route is
https://<my_site_FQDN>/basic/web/index.php?r=product-category/index
and not
https://<my_site_FQDN>/basic/web/index.php?r=ProductCategory/index
Edit
Ok, I see your problem, stop putting folders under other folders and so on. You created your CRUD wrong. Your controller has to be directly under controllers not under controllers/bibliografia, the same goes for the model. Delete the files and start again with CRUD as probably your namespaces are also wrong.
In my case, Yii2 consistenly writes the following with gii CRUD auto-generator.
namespace app\Controllers;
Notice uppercase 'C' for Controllers. This causes 404 error.
It should be :
namespace app\controllers
This fixed my 404 error.
I found with Yii2 (advanced template) that the generated controllers had:
namespace app\controllers;
I had to change this to:
namespace frontend\controllers;
I fixed it by capitalizing the first letter of the controller name.
Controller name should start with capital letters.
If lower case is used, Controller generator won't throw any error, but you will get not found(404) error in the browser.
this threw an error:
app\controllers\testController
this worked:
app\controllers\TestController
Its very Simple, change the namespace and please be careful while creating CRUD..
change namespace app\controllers; to namespace backend\controllers;

How can I use a custom layout and still have the console application work?

I am using a custom layout in Yii. Everything works great in the web part of the app. Then I tried to run the console part of the app to run a job and it says:
exception 'CException' with message 'Property "CConsoleApplication.layout" is not defined.' in /pathToFramework/base/CComponent.php:173
If I revert to the default layout in config/main.php it works again. I can't find any documentation on how to specify the layout only for the console application. I know I can fix it but don't want to get hacky. Does anyone have a clue about the correct wat to go about this? Thanks.
Generally you don't need to specify a layout in your config, but rather do that within your controllers if you're overriding things. That's probably why your CWebApplication can handle things (you're giving it a layout property in your config), but your CConsoleApplication doesn't allow for that property to be set.
Seems like your options are:
Specify your layout property in each controller (any reason you couldn't just use the default views/layouts/main.php?)
Specify your layout property in a config file that is only used for your CWebApplication system instead of your CConsoleApplication
Override your layout property in a config file specific to your CConsoleApplication
Any of the above should work.

How to customize cluster icon using gmaps4rails

So we're trying to change the default cluster icon using gmaps for rails.
In the wiki
it says
You can customize the pics used by the clusterer by setting the Gmaps.map.customClusterer js function in your code.
Where would we put that function? It says "In the javascript" - but where? Do we straight-up edit the code generated by gmaps4rails? How does gmaps4rails pick up the information?
To do this customization you just need to create js file. Then you can
"require" that js file in your Application.js or otherwise just directly refer in your view file. That's it you need not to do anything else. I have used it and it worked for me. If any questions do let me know.
To understand how it works you can just refer the
gmaps4rails.base.js (see #customClusterer = -> false)
gmaps4rails.googlemaps.js (method - createClusterer)
it is straight forward to understand

How to disable AJAX in a Rails app using JQueryMobile

I've built a Rails 3 app and I'm trying to get it working with JQueryMobile. I've gone ahead and required query_mobile_rails and that works just fine, but I need to disable the AJAX loading as it seems to get in the way of many things. Looking at the jquerymobile docs, they recommend adding the following javascript after loading JQuery, but before loading JQueryMobile:
$(document).bind("mobileinit", function(){
$.mobile.ajaxEnabled = false;
});
I've been reading through the docs on the Asset Pipeline, but I cannot figure out how I can manage to get my code (the above) inserted after JQuery and before JQueryMobile. Where do I place such a .js file so that it will be loaded at the proper time?
Any help would be greatly appreciated!
Nevermind. I got it. I created a file called app/assets/app_lib.js with the code above and then added a require app_lib between require jquery and require query.mobile in my application.js file.