Umbraco、剃须刀和图片库
我是 Umbraco 的新手。我正在创建一个图片库(称为“客户”)。客户有一个徽标,它是一个图像。
如何创建输出客户徽标列表的 razor 宏?
我正在寻找 cshtml 代码,可能是这样的:
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach (var customer in Content.Customers) {
<img src="@customer.logo.umbracoFile" alt="@customer.Name"/>
}
提前致谢!
I am new to Umbraco. I am creating an image gallery (called Customers). A Customer has a logo, which is an image.
How do I create a razor macro that outputs a list of customer logos?
I am after the cshtml code, probably something like this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach (var customer in Content.Customers) {
<img src="@customer.logo.umbracoFile" alt="@customer.Name"/>
}
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设脚本在 Customers 页面上执行,并且包含日志和 url 的内容类型称为 Customer:
Model.Customer
将为您提供当前页面的所有子级的列表,这些子级是客户
(内容类型)。I'm assuming the script executes on the Customers page, and that the content type containing log and url is called Customer:
Model.Customer
will give you a list of all children of the current page which areCustomer
s (content type).这是有效的代码
Here is the code that works
要使用动态位置(宏参数),您可以做两件事:
1。在根文档中进行设置,以便用户可以更改客户滑块位置(如果您愿意):
其中 HeaderRoot 是起始文件(根)上的属性名称
2.在你的剃刀脚本上使用参数
并使用它:
所以在你的代码中,它看起来像这样(未经测试):
for using a dynamic location (macro parameters), you could do two things:
1. setting this in your root document so the user can change the customer slider location (if you would like that):
Where HeaderRoot is the name of a property on your starting file (root)
2. Using a parameter on your razor script
and use it something like:
so in your code, it would look something like this (not tested):