Pass variables into nodebb
-
I'm developing a portal at work where we use nodebb for a knowledge base. Ideally, I'd just use a reverse proxy so that /kb for example renders in a div (not an iframe) but this doesn't seem to work.
I can reference the site directly in an iframe, but I'd like to be able to remove (well, hide) various elements to make it look as though nodebb appears native. To achieve this, I'd typically use
?embedded=true
and then collect this inside nodebb itself but it's not being transmitted.If these variables are collected successfully, then they can be used as triggers to hide various elements.
This seems to work fine with PHP for example, but not under nodebb / NodeJS. I'm also sharing the same base domain and have settings for that.
There are no doubt better ways of achieving the same task?
-
What programming language are you using. If you have javascript (or preferably nodejs, vuejs, or any other reactive javascript language), I am using something like this:
const navContainer = document.getElementById('elUserNav'); const userPicture = userData.picture ? `<a href="https://discussions.codenamejessica.com/user/${userData.username}" rel="nofollow" class="nodebbUserPhoto nodebbUserPhoto--fluid nodebbUserNav__link" title="Go to ${userData.username}'s profile"> <img src="${userData.picture}" alt="${userData.username}" class="nodebbUserNav__avatar"> </a>` : `<a href="https://discussions.codenamejessica.com/user/${userData.username}" rel="nofollow" data-nodebb-hook="userNoPhotoWithUrl" class="nodebbUserPhoto nodebbUserPhoto--fluid nodebbUserNav__link" title="Go to ${userData.username}'s profile"> <div class="nodeBBNavNoPhotoTile"> ${this.getInitial(userData.username)} </div> </a>`;
Basically I am looking for the userPicture from the API, then if it exists, display the picture, if it does not show a box with a letter in the center.
By getting the elements by ID, this will allow you to display hidden or not.
Maybe I am talking out of my a$$ too, I am not sure, but I think I see where you are going:
embedded ? 'do something' : 'don't do something';
-
@codenamejessica I'm using a mixture of PHP and JS.
-
Ok, I have not explored the ?embedded=true, I am currently working on that. If I get further along, I'll let you know. I was going to build a template that matches my website, but reading over your post, I may like this idea better. I will be breaking stuff over here for a little bit.
-
@codenamejessica no problems. It's standard GET and POST variable passing which works fine with
same-origin