Im sure I wont be the first person to ask this.
I need to have some extra info on a landing page, where people can login before going to forum page.
Im a moderate coder, so know how to get input fields. But then how do I pass username & password to the forum page to login automatically? I did see there is a tutorial for landing page but that didnt seem to have login function?
For security, is it better the landing page hashes the password and only passes that through in hashed format?
DataTables on custom plugin page
-
Hi All,
I have created a custom page and all works very nicely.
Next I had to display a table.DataTables have some nifty features, and I ended up downloading from: https://datatables.net/download/
As for the setup, I tried the following options (so as to avoid reloading JQuery / Bootstrap):
UI: datatables
Package: datatables,and:
UI: jQuery UI
Package: datatables,I followed https://community.nodebb.org/topic/734/loading-external-scripts-with-requirejs/5. In addition, I added define.amd=0 above datatable's js to escape:
(function( factory ) { "use strict"; if ( typeof define === 'function' && define.amd ) { // AMD define( ['jquery'], function ( $ ) { return factory( $, window, document ); } ); }
My client's plugin code is as follows:
define('forum/client/plugins/myfile', ['translator', 'benchpress', 'moment'], function (translator, Benchpress) { var myDataTables= {}; myDataTables.init = function () { jQuery('document').ready(function() { requirejs(['plugins/nodebb-plugin-myplugin/static/lib/datatables.js'], function (dataTable) { my code...
The table loads up, and looks nice and cool.
The problem follows: when I attempt to browse back into the forum (from the custom page), pages won't load up. The server does gets a request, but the client just does not display anything.
By the way, I tried loading DataTable's JS by including it in the project's json file (removing the requiredjs), with no luck.
I know I screwed up somewhere, just can't figure this one out.
Any help will be highly appreciated!
JJ -
Setting define.amd will make it so every script after yours will break. You should load datatables via requirejs instead by adding it to modules in plugin.json
-
@PitaJ , Thank you!
So you mean adding it as follows:
"scripts": [
"static/lib/datatables.js"If so I tried that. Without altering the file, removing the AMD related if, it won't load.
Once I remove the "if amd", deleting it this time, the table works, but other pages have issue loading...
Any idea?
-
@jjsagan no, look at some other plugin.json files. There's a modules object in addition to a scripts array. It works fine with anonymously defined scripts.
-
@jjsagan you don't have to deal with .amd if you use
modules
-
@jjsagan it's literally the whole purpose of that field in plugin.json, but you have to use it like this:
require(['datatables'], function (datatables) { ... });
-
This thread might be of help as well: https://community.nodebb.org/topic/11731/how-to-include-the-images-that-are-referred-from-inside-a-third-party-css/14