How put header from user page in another tpl page


  • GNU/Linux

    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?


  • Community Rep

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

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


  • GNU/Linux

    @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?


  • GNU/Linux

    @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?


  • Plugin & Theme Dev

    @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.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.