我的内容类型图片区域限制为10张图片。我需要获取url列表以在模板中创建一个滑块。我可以使用以下代码访问第一个网址。
{{ file_url(content.field_banner_image['#items'].entity.uri.value) }}
如何获取每个节点的完整图像列表?我需要将我的模板填充如下
<ul>
<li>imageUrl 1</li>
<li>imageUrl 2</li>
<li>imageUrl 3</li>
</ul>
答案 0 :(得分:1)
检查出来:https://www.drupal.org/project/slick
这个模块的优势在于它已经具有响应能力,并且具有许多功能和配置选项。
作为一般性的提示:每当你想到自己编写一些非常常见的东西(图像滑块/图库)时,研究一下是否已经有了这个模块,因为有机会!你不需要重新发明轮子; - )
但无论如何,如何获取多值图像字段的网址?像这样:
public void someFunction(){
var client = new SDataClient("https://domain/sdata/slx/dynamic/-/")
{
UserName = "username",
Password = "password"
};
var contact = new Contact
{
Account = new Account
{
AccountName = "accountName",
Id = "accountId"
},
Address = new Address
{
Address1 = "1234 Address",
City = "someCity",
PostalCode = "12345",
State = "ST"
},
FirstName = "John",
LastName = "Doe"
};
var contactOptions = new SDataPayloadOptions { Include = "Address" };
try
{
contact = client.Post(contact, null, contactOptions);
}
catch (Exception ex)
{
var error = ex.Message;
}
}
[SDataPath("accounts")]
public class Account
{
[SDataProtocolProperty(SDataProtocolProperty.Key)]
public string Id { get; set; }
public string AccountName { get; set; }
public List<Contact> Contacts { get; set; }
public string Status { get; set; }
public string Type { get; set; }
}
[SDataPath("contacts")]
public class Contact
{
[SDataProtocolProperty(SDataProtocolProperty.Key)]
public string Id { get; set; }
public Account Account { get; set; }
public Address Address { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
public string FullName { get; set; }
public string LastName { get; set; }
public DateTime? ModifyDate { get; set; }
public string Status { get; set; }
}
[SDataPath("addresses")]
public class Address
{
[SDataProtocolProperty]
public string Key { get; set; }
public string Address1 { get; set; }
public string Address3 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string CountryCode { get; set; }
public string Description { get; set; }
public string PostalCode { get; set; }
public string State { get; set; }
public string Street { get; set; }
}
希望这有帮助。