How show header profile when I go in a particular url
-
I want to show the header profile user :
My purpose is create a new url like "http://192.168.56.101:4567/favourites" (this is an example) and when the user goes in this url the forum show him the header profile like in the image.
In my library.js
plugin.init = function(params, callback) { var router = params.router, hostMiddleware = params.middleware, hostControllers = params.controllers; console.log(hostMiddleware); router.get('/favourites', hostMiddleware.buildHeader, controllers.renderFavourites); };
can I create header profile user with some method in "hostMiddleware" variable? Anyone can help me?
-
You can inspect the
accounts/info
controller to see what data is required in your new route.Off-hand, I believe the following are required:
-
@julian I change in the library this:
router.get('/user/:userslug/favouri' hostMiddleware.buildHeader, controllers.renderFavourites);
Now I need to create "controllers.renderFavourites" method to handle request so I do this
var db = module.parent.parent.require('./database'), user = module.parent.parent.require('./user'), async = module.parent.parent.require('async'), helpers = module.parent.parent.require('./controllers/helpers'), accountHelpers = module.parent.parent.require('./controllers/accounts/helpers'); var Controllers = {}; Controllers.renderFavourites = function(req, res, callback) { var userData; async.waterfall([ function (next) { accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next); }, function (_userData, next) { userData = _userData; console.log("sotto 1"); if (!userData) { return callback(); } async.parallel({ history: async.apply(user.getModerationHistory, userData.uid), sessions: async.apply(user.auth.getSessions, userData.uid, req.sessionID), usernames: async.apply(user.getHistory, 'user:' + userData.uid + ':usernames'), emails: async.apply(user.getHistory, 'user:' + userData.uid + ':emails') }, next); } ], function (err, data) { if (err) { return callback(err); } userData.history = data.history; userData.sessions = data.sessions; userData.usernames = data.usernames; userData.emails = data.emails; userData.title = '[[pages:account/info]]'; userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:account_info]]'}]); res.render('account/info', userData); }); //res.render('',{}); };
So for example suppose to create a user with slio like username and when this user goes at route /user/slio/favouri, the page that appears is
Now With jquery I can modify the page according my intentions. @julian is the correct solution?