How put header from user page in another tpl page

NodeBB Plugins
  • I need to create another page when the user go in his page. I must load the header that an user sees when he goes in hiw /user/namepage:

    router.get('/user/admin/favourites', params.middleware.buildHeader, controllers.renderBookmarked);
    

    In the controllers I do:

    Controllers.renderBookmarked = function(req, res, callback) {
    	console.log("QUIII");
    	res.render('connect-bookmarked-user', {});
    
    };
    

    How I can load the header like in this way?:
    0_1477668225726_forum.png

    Anyone can help me?

  • I think you have to import the header template in your page's template.

    <!-- IMPORT partials/account/header.tpl -->

  • @yariplus I follow this link that is a question that I have published 8 month ago:

    https://community.nodebb.org/topic/7980/how-modify-user-profle-page-with-a-response-in-a-plugin/4

    My purpose is modify the bookmarked page when the use go there so I follow your suggest and I create the file.js:

    'use strict';
    
    
    (function() {
    	console.log("CIAO");
    	$(function() {
    		$(window).on('action:ajaxify.contentLoaded', function(event, data) {
    			console.log("DATA TPL");
    			console.log(data.tpl);
    			if (data.tpl === "account/favourites") {
    				console.log("MIAOOO");
    				// Add your jQuery here.
    				$('ul[component="posts"]').remove();
    				
    			}
    		});
    	});
    
    }());
    

    The code works when the user click on the menu and come in the page from the menu but If an user come in this page and reload the page the code doesn't work and I see the old bookmarked. can you help me?

  • @yariplus I resolve in this way:

    (function() {
    	console.log("CIAO");
    	$(window).on('action:ajaxify.end,action:ajaxify.contentLoaded', function(e, data) {
    
    		if (data.tpl_url === "account/favourites") {
    			$(window).trigger('action:ajaxify.contentLoaded', {
    				url: data.url,
    				tpl: data.tpl_url
    			});
    		}
    		if (data.tpl === "account/favourites") {
    			
    			// Add your jQuery here.
    			$('ul[component="posts"]').remove();
    //The next line i think is the problem
    			var  gancio=$('#content');
    			gancio.append('<br/><div><textarea>C</textarea></div>');
    		}
    	});
    
    }());
    

    But whe I create bookmarked and I put obtain an Error alert when I go up and down with mouse:

    0_1478168410206_nodebb.png

    Anyone can help me?

  • @Doppy this line is the problem...

    $('ul[component="posts"]').remove();

    when you scroll down the page, infinite scroll kicks in and the DOM element removed using the above statement contains a data point that the infinite scroll needs to look for more data.


Suggested Topics


  • 0 Votes
    1 Posts
    814 Views

    I'd like to know how to create a page for rules, like this: https://shotbow.net/forum/p/rules/

    And have it added to the header for quick navigation. I'm inexperienced in html/css so i'll need help with that.

    Same thing with the donate/donation page. I'd like it to be like a shop sort of: https://shotbow.net/forum/xp/shop

    Where you can purchase an item, and be redirected to my paypal. I'm unsure if any of this is even possible, but would i'm sure it'd help a lot of sites.

  • 0 Votes
    1 Posts
    969 Views

    I am new to NodeBB and nodebb-plugin-sso-oauth authenticates users from oauth2-server-php with an Active Directory (Samba 4) backend. "So far so good" - this plug in obviously works in that configuration, but I was not able to include more than id, displayName and email from OAuth into user NodeBB account. My OAuth solution offers a big JSON object with many data which are usable for NodeBB.

    My library.js was patched to

    OAuth.parseUserReturn = function(data, callback) { // Alter this section to include whatever data is necessary // NodeBB *requires* the following: id, displayName, emails. // Everything else is optional. // Find out what is available by uncommenting this line: console.log(data); var profile = {}; profile.id = data.id; profile.displayName = data.display_name; profile.fullname = data.user_nicename; profile.emails = data.emails; console.log(profile); // Do you want to automatically make somebody an admin? This line might help you do that... // profile.isAdmin = data.isAdmin ? true : false; // Delete or comment out the next TWO (2) lines when you are ready to proceed //process.stdout.write('===\nAt this point, you\'ll need to customise the above section to id, displayName, and emails into the "profile" object.\n==='); //return callback(new Error('Congrats! So far so good -- please see server log for details')); callback(null, profile); }

    this console log show all data as expected, so oauth module got everything, but profile.fullname is ignored by NodBB. It seems it is not enough to patch that section to get more than minimum required data for a NodeBB user.

    Any hints?

  • 0 Votes
    4 Posts
    2k Views

    @limker said:

    Looks like your plugin will reject any user with a non-gmail account. Maybe you should check with a list of valid email domains, i'm sure you can find one easily on google.

    Actually I think this is a bad idea. Because anyone can run their own mailserver.

    Just check if the email contains an @ is enough for valid email testing. Most regex solutions will fail on stuff like:

    "this email contains spaces"@example.org which is a valid email address. An email address may even contain a @ character in the local part in some odd configurations.

  • Plugin to rate users

    NodeBB Plugins
    0 Votes
    7 Posts
    3k Views

    up, this will be nice feature for the market section of the boards

  • 6 Votes
    122 Posts
    83k Views

    Can we use this plugin to add announcements, reference to rules, or any html specifically to the login page?