【问题标题】:Different templates for one content (KeystoneJS / Node)一个内容的不同模板(KeystoneJS / Node)
【发布时间】:2017-12-15 07:09:19
【问题描述】:

是否可以为相同的内容类型选择不同的模板(即树枝模板)?

一个例子: 3 篇博文,每篇都使用不同的模板显示...? 在创建博客文章期间从下拉列表中选择模板?

【问题讨论】:

    标签: node.js keystonejs


    【解决方案1】:

    使用混入

      mixin different_blog_view_type(type)
      ....
      if type !== "view1"
        .supacoolEl23
      .....
      if type === "view2"
        #moreCoolest2view
    

    不要忘记定义 locals.type 变量,并将其更改为您喜欢的方式(下拉菜单、收音机等)

      exports = module.exports = function(req, res) {
        var view = new keystone.View(req, res);
        var locals = res.locals;
        locals.type = req.params.type; 
        //this wil get from :type param
        //or you can use req.body or req.query
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 2017-06-01
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      • 2015-09-12
      相关资源
      最近更新 更多