Advertisement
Guest User

Untitled

a guest
May 25th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var keystone = require('keystone');
  2.  
  3. exports = module.exports = function(req, res) {
  4.     var view = new keystone.View(req,res);
  5.     var locals = res.locals;
  6.  
  7.     // Set locals
  8.     locals.section = 'store';
  9.     locals.filters = {
  10.         product : req.params.product
  11.     }
  12.     locals.data = {
  13.         products:[]
  14.     }
  15.  
  16.     view.on('init', function(next){
  17.         var q = keystone.list('Product').model.findOne({
  18.             slug: locals.filters.product
  19.         });
  20.  
  21.         q.exec(function(err, result){
  22.             locals.data.product = result;
  23.             next(err);
  24.         });
  25.     });
  26.  
  27.     // Render view
  28.     view.render('product');
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement