How put header from user page in another tpl page
-
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?:
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:
how modify user profle page with a response in a plugin
@pichalite Ah, you're right. Looks like tpl_url was added in master. Changed the hook to contentLoaded, since end doesn't pass the template in 0.9.x.
NodeBB Community (community.nodebb.org)
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:
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.