Add scripts and style to Joomla plugin admin settings page only - joomla3.0

I just finished making a plugin but my javascript & css are being loaded into every page of the site rather than just on my admin settings page. This is the code I have in my Plugin's class:
public function onBeforeCompileHead(){
$app = JFactory::getApplication();
if ($app->isSite()) {
return;
}
$document = JFactory::getDocument();
$document->addScript(JUri::root() . 'plugins/system/plugin_name/js/jquery-ui.js');
$document->addScript(JUri::root() . 'plugins/system/plugin_name/js/custom.js');
$document->addStyleSheet(JUri::root() . 'plugins/system/plugin_name/css/style.css');
}

Related

Disable Angular Templates in ASP.NET Core

On an ASP.NET Core view using AngularJs I have:
<div ng-include="'/views/profile.html'" ng-controller="ProfileController as c"></div>
When I change the HTML file and run the application its content does not change.
I checked it and the HTML file is cached ...
How can I avoid the caching of angular HTML templates in ASP.NET Core?
Actually this solution, I have got originally from the replies at the link given by #Deblaton in the comment here.
But, I modified for the purpose of ours'...
Just for development environment I disabled cache for only the HTML templates in the Configure() method of ASP.Net Core Request pipeline,
if (env.IsDevelopment())
{
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = (context) =>
{
if (context.File.Name.ToLower().EndsWith(".html"))
{
context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
context.Context.Response.Headers["Pragma"] = "no-cache";
context.Context.Response.Headers["Expires"] = "-1";
}
}
});
}
else
{
app.UseStaticFiles();
}
And it just did the work!

How to enable a theme for all views?

I am working on a CakePHP 3 project and I'm new to CakePHP.
I have baked a theme MyTheme in plugins/MyTheme.
I have also configured default.ctp in plugins/MyTheme/src/Template/Layout/ directory and all css and js files in plugins/MyTheme/webroot/css/ and /plugins/MyTheme/webroot/js/ directories.
How do I enable this theme for all views (master theme) ?
[...] How do I enable this theme for all views (master theme) ?
By defining the theme to use (either via the $theme property (before CakePHP 3.1), or via the view builders theme() method) in a controller that all your applications controllers extend, which by default should be AppController.
Something along the lines of
//...
class AppController extends Controller
{
// With CakePHP < 3.1
public $theme = 'MyTheme';
// With CakePHP >= 3.1
public function beforeRender(\Cake\Event\Event $event)
{
$this->viewBuilder()->theme('MyTheme');
}
}
See also
Cookbook > Controllers > The App Controller
Cookbook > Views > Themes

Thymleaf everywhere Spring mvc

hey everyone i have an issue with thymeleaf and my static html pages
to be more specific i have a spring mvc web application am using also spring security , well in my login page i want to use thymeleaf so can spring security communicate with client layer in the other side i don't want to include thymeleaf in my all html pages cause am going to use AngularJs
I tried to put the login in templates folder and the other's in the static folder but id doesn't work
this is my thymleaf configuration class
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.thymeleaf.spring3.SpringTemplateEngine;
import org.thymeleaf.spring3.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
#Configuration
public class ThymeleafConfig {
#Bean
public ServletContextTemplateResolver templateResolver() {
ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
resolver.setPrefix("/WEB-INF/vues/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
resolver.setOrder(1);
return resolver;
}
#Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver());
return engine;
}
#Bean
public ThymeleafViewResolver thymeleafViewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
return resolver;
}
}
my problem is i don't want Thymeleaf included in my all pages you know XHTML is pretty annoying with closing the html tag
any guide will be thankfull
Well i think you dont have to use the XHTML Syntax if u are not including thymleaf into the specific page.

Using CSS #attached doesnt load stylesheet in

I am using Drupal's hook_form_alter to add a stylesheet into one of my forms (user registration form). My code does add the stylesheet to jquery.extend(Drupal.settings) as sites\/all\/themes\/mytheme\/css\/font-awesome-min.css:1, but this does not allow me to use the stylesheet as when I reference classes that are in it, they don't load as the CSS file does not show up as an import URL or link in <head>. Any help would be appreciated.
function mytheme_form_alter(&$form, &$form_state, $form_id) {
if ( $form_id == 'user_register_form' )
{
$form['#attached']['css'] = array(drupal_get_path('theme', 'mytheme') . '/css/font-awesome-min.css');
}
Add 'file' at the end of $form['#attached']['css'] array, like this:
$form['#attached']['css'] = array(drupal_get_path('theme', 'mytheme') . '/css/font-awesome-min.css', 'file');

nancy razor first time setup - route not found 404

Steps I took to setup project:
created new asp.net project
Install-Package Nancy.Viewengines.Razor
added Views/hello.cshtml (simple hello world html)
added MainModule.cs
hit ctrl-F5 (it returns the directory listing)
change url to localhost:41915/hello
Then I get 404 resource not found.
What am I missing?
// MainModule.cs
namespace MyProj
{
using Nancy.Routing;
using Nancy;
public class MainModule : NancyModule
{
public MainModule(IRouteCacheProvider routeCacheProvider)
{
Get["/hello"] = parameters => {
return View["hello.cshtml"];
};
}
}
}
You need the Nancy.Hosting.AspNet package too.

Resources