How to include a js Library within a CakePHP Plugin - cakephp

can anyone tell me how to include a js Library within a CakePHP Plugin ?
In the root app/ folder I can do it in the Config/assets.php but where do I include it in a Plugin ?
The Library which I want to include is located in /app/Plugin/MyModule/webtoor/js/lib/

You can use blocks for scripts and CSS files. More info here: http://book.cakephp.org/2.0/en/views.html#using-blocks-for-script-and-css-files
Short answer:
// in your view
$this->Html->script('/pluginName/js/lib/whatever', array('block' => 'scriptBottom'));
// in your layout
echo $this->fetch('scriptBottom');
This should do the trick.

Related

For sencha app build , do we need to include all js files related to view in main.js(portal.js)?

I am using sencha cmd 6 for building my application.
my folder structure is
classic
src
model
view
account
jobs
portal
portal.js
controller
store
production build process execution is successful but when i load that build its giving .js file not found error.
So i include all js files in folder structure into main js portal.js then .js error is removed and build works.
But i dont want to include all these list of files in one single js, so can we skip the js include part from portal.js and use any property or attribute to include all js files ?
You can specify with * like 'Ext.chart.*' in requires section of Ext.app.Application.
Hope this helps.

where to put compiled typescript files in angular 2 production app?

following this application structure in angular 2.
angular app structure
If I put the compiled .js and .map files in the same directory as typescript file it becomes more cluttered structure.
so, where should I place the compiled js files (.js) and map (.js.map) files?
where should I place the compiled js files (.js) and map (.js.map) files?
You can git ignore these .js / .js.map files and they will not clutter your git history and stuff (and your IDE might support hiding them as well).
That said you are free to use the outDir option to move the generated assets into a seperate directory 🌹

Custom layout for page 404 in cakephp 3.x

I want to change default layout for 404 page in cakephp 3.x .I know I can change it from src/Templates/Error/error400.ctp file but what I want is to load css from my theme from plugins/Theme/webroot/ not from default webroot.
Can anyone help me with this please?
You can use plugin syntax for loading css file from plugin.
echo $this->Html->css('DebugKit.toolbar.css');
Source > Linking to CSS Files

Add new library

I'm trying to figure out the right way to add any eventual new library (for example I need angularJS ui-router) in an onsen app.
I installed bower and then downloaded ui-router.
Since I do not know exactly the way Gulp is used, I got confused on what I'm suppose to do.
At the moment, I have the following folders:
bower_components, hooks, merges, node, modules, platforms, plugins, www
The index.html has the following reference:
What I suppose to do, now?
manually copy the ui-router js files in /www/lib/
configure gulp to copy the files automatically
change the script tag src and make the reference to the bower_component folder
change the Bower default folder
could you please guide me on sort it out?
tnx
At the end I chose the option 2.
I edited the file gulpfile.js adding a new custom task supposed to copy the missing bower libraries.
var mainBowerFiles = require('main-bower-files');
gulp.task('copy-bower-libs', function() {
return gulp.src(mainBowerFiles())
.pipe(gulp.dest(__dirname + "/www/lib/bower/js"))
});

How to use custom css in extjs app

In my Extjs app I have kept custom.css file in the resources folder of the root for testing and in the build- resources folder. And add the css path to two both index.html files(test and build). But whenever I make it to convert to build production, index.html file overwrites and custom.css file finds missing. Somewhat problematic it is. I know that this is because I add this file externally. But Is there any permanent solutions to fix this, without violating the Extjs app structure ??
You can add your custom styles via scss. There are several articles around the web about styling your ExtJS app.
http://docs.sencha.com/extjs/5.0.0/core_concepts/theming.html
http://www.rallydev.com/community/engineering/guide-custom-themes-extjs-4 [dead link]
If you only want to add your single custom css file - which i do not recommend - you can do things like that:
Include an existing CSS file in custom extjs theme
http://www.sencha.com/forum/showthread.php?270694-How-to-include-custom-components-CSS-in-build-CSS

Resources