Please I need some help with modifying nodebb (themes/plugins).



  • Hi I'm a beginner and I'd like to create a forum with nodebb.

    Though nodebb is great but I need some major changes,and I 'm getting more and more confused. The documents needs to be more specific.
    . e.g I 'd like a new hompage,and some other functions (an exam system).

    • Do I need to develop a new theme for that? or a new plugin?

    • If I want to add some new pages to it,should I just create some tpl files?

    • What do I do to connect these tpl files? Register them in Router.js file?
      e.g. I'd like to modify categories(which is the default home page for nodebb),but I don't see any in dir "views". I found one named "categories.tpl" in dir "build ".But can I modify it?Aren't those files in dir "build" automatically built by "build" command?
      😢 I'm quite lost.Could anyone just give me hint or something? Thanks.


  • Global Moderator

    You can probably use a combination of nodebb-plugin-custom-pages and nodebb-plugin-customize.



  • @PitaJ Hi,u r the author of "nodebb-plugin-calendar" right? Very nice to meet u,I've been reading ur code but little progress by now.
    I don't feel well about using "nodebb-plugin-custom-pages", that's for a landing page right? I need a whole new set including tpl and backend code(controller,database connection etc) . I don't see any files other than .tpl in dir build which gives me doubts.
    Haven't used nodebb-plugin-customize before,but that's for translation?I 'd like to develop a new function which would need everything from inserting data into database to a new page.
    e.g I'm using theme-slick as a starter, but what should I do other than making a new tpl if I want a page which would query some data from mongodb and insert them into the page?
    Sorry the upload func is down. I'll use text instead.

    theme dir
    less
    lib
    templates(both admin & client)
    library.js
    plugin.js

    what should I do if I want to make a new tpl in client side? Where do I put controller?Do I need to keep anything else in mind?


  • Global Moderator

    You probably want to look at nodebb-plugin-quickstart



  • @PitaJ Already downloaded nodebb-plugin-quickstart and nodebb-theme-quickstart.
    Please excuse me,I worked with Vue before,don't know much about node.js.
    Perhaps I should look up documents on express to get a better understanding on nodebb?
    One thing that confuses me the most is I never found categories.tpl which serves as the home page.Where is it? I can see that controller renders "categories"
    res.render('categories', data).But the dir "categories" works as a service layer ,obviously not the one I'm looking for. There has to be a tpl file named "categories", and I can only find one in dir "build".
    That's not the one I'm looking for,is it?


  • Global Moderator

    categories.tpl is provided by whatever theme you're using. For a default install and this site, that is under nodebb-theme-persona/templates/categories.tpl. That template is used as the source for constructing the templates you see under build/



  • @PitaJ Indeed...Thanks a lot.
    I'm still having trouble making my new pages. Neither adding params.router.get('/myentrance',renderEntrance()); in theme.init function or adding router.get('/myentrance', controllers.user.getCurrentUser); works.
    What do I have to do to register a url in router?


  • Global Moderator

    You should have renderEntrance not renderEntrance(). Additionally you must register the API route or it will only work on cold load.

    What do you see when you go to /myentrance



  • @PitaJ Thank u so much!! So the correct way is to register my new url as router.get(url, middleware)in src>routes>api.js ,and then register params.router.get(url,controller); in nodebb-mytheme>lib>theme.js> theme.init = function(params, callback) {
    I need to spend some time checking what do these middlewares do.May stumble into a few more errors after.Hopefully I can still go to u for advice.👍


  • Global Moderator

    You don't need to edit any NodeBB core files to add a route in your theme. The quickstart plugin has working examples, follow those for how to add an API route.



  • @PitaJ Hi,sorry to bother you,but I ran into some errors.
    I set up a new page,registered it with params.router.get('/myentrance',renderEntrance).And I'd like to import the default header(with some modification later) so I placed these (<!-- IMPORT header.tpl -->) on entrance.tpl. Then the page went down.The error on console says Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at myentrance:12 The page shows only "Login" button and progress bar kept flashing.
    I know I must've missed the data "header.tpl" needs,but what do I do to get these data? Looking forward to your reply,thanks.


  • Global Moderator

    Your don't need the header in your template. You need to add it like this:

    router.get('/calendar', middleware.buildHeader, renderPageHandler);
    router.get('/api/calendar', renderPageHandler);
    

    https://github.com/pitaj/nodebb-plugin-calendar/blob/1.0.x/src/lib/controllers.js#L109-L110


Log in to reply
 

Suggested Topics

  • 3
  • 5
  • 2
  • 5
  • 1
| |