- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Lithium 自定义组件来创建撰写最多博客文章的用户列表。我有一个用户列表,他们写了一篇博客文章,然后进行了一次休息,以获取每个用户所写的博客文章的数量。
<#assign authors = rest("blogs/id/audiofile/posts")>
<#list authors.node_message_context.message.author as t>
<#assign count = rest("${t.@href}/posts/style/blog/count")>
<#assign orderedCount = count.value>
<#list orderedCount as c>
<ul>
<li>Blog posts ${c} userid ${t.@href}
</ul>
</#list>
</#list>
Blog posts 4 userid /users/id/2477
Blog posts 4 userid /users/id/2477
Blog posts 4 userid /users/id/2477
最佳答案
@Wolfgang Fahl 希望我们可以修改 Lithium REST API =)!
不幸的是,情况并非如此,所以我们必须处理我们得到的东西,可能会做这样的事情:
<#-- this variable we need to store unique author ids -->
<#assign authorids = [] />
<#-- I'd use API v2 here, think for such stuff it's more powerful than v1 -->
<#assign query = 'SELECT author FROM messages WHERE conversation.style = "blog" AND board.id = "audiofiles"'?url />
<#assign response = rest("2.0", "/search?q=" + query) />
<#-- the response object will contain a list of blog post authors,
we loop trough them to get uniqe ids of every user that has written
a blog post, we need them later -->
<#list response.data.items as author>
<#-- make sure each author just gets added once -->
<#if !authorids?seq_contains(author.id)>
<#assign authorids = authorids + [author.id] />
</#if>
</#list>
<#-- now we loop trough the unique author ids and ask for the amount of
blog posts they have written -->
<ul>
<#list authorids as id>
<#assign query = 'SELECT count(*) FROM messages WHERE author.id = id AND board.id = "audiofiles"'?url />
<#assign response = rest("2.0", "/search?q=" + query) />
<li>User with ID ${id} has written ${response.data.count} blog posts</li>
</#list>
</ul>
关于freemarker - 删除 Lithium/Freemarker 中的重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15925379/
我想将配置数据存储在单独的文件中,并使用正确的 Lithium 方式加载/读取它。 最佳答案 取决于它的用途。我们非常不鼓励抛出全局配置,除非它被仔细管理。 如果它与连接到某种外部系统有关,我建议您查
我通读了锂\数据\模型\查询,但没有看到任何连接示例。 最佳答案 有多种方法可以执行与 Lithium 的连接。 Lithium 将为您处理已定义关系 ( examples in the manual
在 Lithium 中,像这样获取给定模型的所有行之后: $users = Users::all(); 我怎么知道返回了多少行?我正在使用 MySQL 连接器。 谢谢! 最佳答案 如果你只是想要计数
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我有一个扩展的基础模型。在其中,我定义了两个验证过滤器。一个检查记录是否唯一,另一个检查记录是否存在。它们的工作方式完全相同,只是一个返回值与另一个相反。 因此,将相同的代码编写两次只返回不同的值听起
我正在尝试通过 CLI 运行操作。操作是 UsersController::test() 所以,我运行这个:php libraries/lithium/console/lithium.php\\app
我正在尝试通过 CLI 运行操作。操作是 UsersController::test() 所以,我运行这个:php libraries/lithium/console/lithium.php\\app
这让我从 cakePHP 时代起就感到愤怒。如何查看 Model::find() 上执行的 SQL 查询? 最佳答案 这个问题已经在这里得到了回答:Lithium: Can we see querie
是否可以在 Lithium 的关系中访问多个模型? 例如,我有一个用户模型: class Users extends \lithium\data\Model { public $validat
我在 mongodb 中使用锂,我想知道下面的模型如何从 Posts::find('all'); 获取用户数据查询? 我必须执行两次查询吗? 感谢您的帮助! array('type' =>
如果我有一个我没有设置的锂应用程序,我该如何找出版本? 最佳答案 我认为他们不会在文件本身上加上时间戳。我建议您查看测试用例并查看最近的时间戳。 关于PHP lithium(li3) 如何找出版本,我
我对Lithium框架感到满意,并且想知道是否有用于将MongoDB或Memcache用于Lithium session 的示例。是否需要编写一个新的 session 适配器? 最佳答案 一种选择是将
我过去曾在几个项目中使用过 CakePHP,最近开始使用 Ruby on Rails,但我即将开始一个新项目,它需要 PHP。在使用 CakePHP 更新自己的同时,我了解到有一个名为 Lithium
我正在使用 Lithium 自定义组件来创建撰写最多博客文章的用户列表。我有一个用户列表,他们写了一篇博客文章,然后进行了一次休息,以获取每个用户所写的博客文章的数量。 Blog post
我有一个 MySQL 表 categories以下列: 编号 姓名 我使用检索数据 $categories = Categories::find('all'); 现在,我想创建一个 带有值为 $cat
我想排除调用 Lithium 模型的 find() 方法的结果。我需要为同时具有 MongoDB 和 MySQL 数据源的模型执行此操作,但在 SQL 中,我的意思是类似于 WHERE myfield
我正在使用 Lithium 和 mongoDB 编写我的第一个社区页面。我真的很喜欢 mongo 的无模式方式,但是有一个问题使得没有模式就无法工作: 例如我们有一个像这样的简单形式: form->c
我希望使用 Lithium 框架来构建我的应用程序配置界面,因为我喜欢它的最小方法和以文档存储(即 Mongodb)为中心的模型。 但是,(我知道它还没有完全发布),几乎没有任何信息、教程或示例可以让
我正在构建一个测试 Lithium 应用程序以了解它的工作原理,我发现表单助手似乎无法识别我传回的数据或任何验证错误。 目前我不得不手动传回我的错误,然后在 View 中处理它们。 Questions
我想使用 Lithium 的“cookie” session 适配器。用户登录后,我将使用他的散列密码创建一个 cookie。如果此 cookie 存在并且散列密码与数据库中的密码匹配,我将自动让他登
我是一名优秀的程序员,十分优秀!