Groovy 如何在tornado.no/cms中存储对页面的更改?
在tornado cms页面的控制器中,我执行以下操作:Groovy 如何在tornado.no/cms中存储对页面的更改?,groovy,Groovy,在tornado cms页面的控制器中,我执行以下操作: def res = Service.tornado.articles([ articleCategoryPath: "boker/ny"]); Service.tornado.loadFullArticles(res); res.sort { a,b -> b.props.year <=> a.props.year } tornado.small_articles = res; def res=Service.
def res = Service.tornado.articles([ articleCategoryPath: "boker/ny"]);
Service.tornado.loadFullArticles(res);
res.sort { a,b ->
b.props.year <=> a.props.year
}
tornado.small_articles = res;
def res=Service.tornado.articles([articleCategoryPath:“boker/ny”]);
服务。龙卷风。满载物品(res);
res.sort{a,b->
b、 道具年,道具年
}
tornado.small_articles=res;
或简称:
tornado.small_articles = Service.tornado.articles([
articleCategoryPath: "boker/ny",
full: true ])
.sort { a, b -> b.props.year <=> a.props.year };
tornado.small\u articles=Service.tornado.articles([
articleCategoryPath:“伯克/纽约”,
完整:正确])
.sort{a,b->b.props.year a.props.year};
这将使用特定文件夹“boker/ny”中的所有文章填充内容框small_articles
,这些文章按文章属性year
反向排序
它工作正常,但是否可以保存对内容框所做的更改,以便从GUI中也可以看到所生成的文章列表?类似于
Service.tornado.saveChangesToPageContentBox(第页,内容框,tornado.small文章)代码>?首先删除当前绑定到小文章框的文章,如下所示:
Integer containerId = <id-of-small-articles-container>;
Service.tornado.getPageBindings(page.id).each { binding ->
if (binding.containerId == containerId)
Service.tornado.deletePageBinding(binding);
}
您不应该对给定页面的每个请求都执行此操作,而应该在内容更改时更新列表,或者按照其他一些不太频繁的标准进行更新。我刚刚从文档中了解到,通过将full:true
添加到搜索查询中,我可以一步完成整个操作tornado.small_articles=Service.tornado.articles([articleCategoryPath:“boker/ny”,full:true])。排序{a,b->b.props.year a.props.year}
tornado.small_articles.each {
Service.tornado.addPageBinding(new ArticlePageContainer(page.id, it.id, containerId));
}