Closed ajax13 closed 10 years ago
This is done entirely in the browser.
You can add this into a custom js
file:
$(function () {
if (!window.localStorage.getItem('theme'))
$('#theme a:contains(Flatly)').trigger('click');
});
Keep in mind that there is a bug inside the current release, so what would normally work:
"some-key": {
"public": {
"local": {
"path": "/absolute/path/to/your/custom/stuff",
"js": [
"/default-theme.js"
]
}
}
}
will throw an error until the new version is out, so you need to add a dummy app key as well:
"app": {
"path" : "/absolute/path/to/your/custom/app",
"slug": "ddd",
"verbose": "...",
"mainview": {
"show": false
}
}
Or if you already have some custom view defined inside the custom.json
file you can just add your default-theme.js
file there. That's why the error with the missing app
key was missed in the first place - you can have app
with public
key or just only one of them. Refer to the documentation for the proper json structure - http://simov.github.io/express-admin-site/#customjson
thx,
to working well for me i add also another line in the `js` file:
$(function () {
if (!window.localStorage.getItem('theme'))
$('#theme a:contains(Flatly)').trigger('click');
window.localStorage.setItem('theme','flatly');
});
No need because it is set on this line - https://github.com/simov/express-admin/blob/master/public/express-admin.js#L172 But yes you are free to write whatever you want to inside your custom files, that's the point!
Closing this.
i found another solution:
changing `theme.html` :
(function () {
var bootstrap = document.getElementById('bootstrap'),
theme = localStorage.getItem('theme') || 'cerulean';
bootstrap.href = xAdmin.root+'/bootswatch/'+theme+'/bootstrap.min.css';
}());
and some changes into theme.json
:
[
{"key": "cerulean", "name": "Default"},
The idea of the custom static files and views (also the events in the next version) is to override and/or extend the core functionality without the need of touching the core of the app.
The default theme and layout should be a config that should be put in custom.json
?
Inside custom.json
you can include regular js
and css
files and define your own behavior there. Since there isn't an option for defining a default theme/layout the quickest solution was to include an additional js
file and trigger the button responsible for changing the theme using jquery: https://github.com/simov/express-admin-examples/blob/master/examples/custom/static/theme.js, the files are included here: https://github.com/simov/express-admin-examples/blob/master/examples/config/custom.json#L89
You can pull and run the https://github.com/simov/express-admin-examples repository.
Hi again,
how can i change the default theme with another theme to be the new default one.(but not with the theme button), thx