Knowledge need to build a plugin?

General Discussion
  • Just wondering what are needed to build a plugin for nodeBB. And I think many beginners in here will be asking, too.
    I'm trying to build a plugin with a simple function which is storing data from ACP to DB and get it back to the widget and still got errors for ages.
    I have only experience in JS, CSS, HTML, PHP, SQL and still a beginner with nodejs and noSQL.
    Thanks for your suggesting. 🙂

  • @Hưng-Thành-Nguyễn Do you have a work-in-progress repository you can show us? 🙂

  • @julian I'm just working on local not publish yet 😄 . My idea is simple. A quote rotator plugin will create a simple widget with timing count down for each quotes with author. Everything will be set in ACP and store in DB. My futher idea is allow user can use this to push a quote to the widget with some cash via plugin cash.
    My problem is I still wonder how to store the data to db and get it back in widget.

  • @Hưng-Thành-Nguyễn If you are using a regular ACP page, I would suggest you use our existing "settings" helper library.

    For example...

    <form class="quoteRotator">
    	<div class="form-group">
    		<label for="quotes">Quotes</label>
    		<input type="text" name="quotes" title="Quotes" class="form-control" placeholder="Key"><br />
    		<p class="help-block">
    			Please enter one quote at a time, separated by a new line.
    		</p>
    	</div>
    </form>
    <script>
    	require(['settings'], function(Settings) {
    		Settings.load('quoteRotator', $('.quoteRotator'));
    
    		$('#save').on('click', function() {
    			Settings.save('quoteRotator', $('.quoteRotator'));
    		});
    	});
    </script>
    
  • @julian I just take a look at custom-header plugin and just doing like him. Create an api save page which call this function and I think this should work fine. But I don't know how to render a widget with data get from the db 😄

    function save (req, res, next) {
    
    	var data = {
    		quotes: req.body.quotes
    	};
    	db.setObject('plugins:quotes-rotator', data, function(err) {
    		err ? res.json(500, 'Error while saving settings') : res.json('Settings successfully saved');
    	});
    }
    
  • I had the exact same idea last week 😞
    It was going to be my entry into the plugin competition. I can be my usual lazy self and leave it to you to create 😛

  • @Scuzz I'm kinda busy in these days 😞 and lazy too 😛
    Trying to learn how to push data to widget next weekend 😉
    Maybe we can be partners 😆


Suggested Topics