Skip to content

Instantly share code, notes, and snippets.

// Accessing image fields
$image = $doc->getImage("product.image");
// Most of the time you will be using the "main" view
$url = $image->getView("main")->getUrl();
// Accessing image fields
Fragment.Image image = doc.getImage("product.image");
// Most of the time you will be using the "main" view
String url = image.getView("main").getUrl();
// Accessing image fields
val image: Option[Fragment.Image] = doc.getImage("product.image")
// Most of the time you will be using the "main" view
val url: Option[String] = image.map(_.main.url)
// Accessing image fields
var image = doc.getImage("product.image");
// Most of the time you will be using the "main" view
var url = image.main.url;
// TODO
var cache = LambdaCache.For (
(key, value, ttl) => {
return null;
},
key => {
return null;
}
);
// This Api will use the custom cache object
// "near" predicate for GeoPoint fragments
var near = "[[:d = geopoint.near(my.store.location, 48.8768767, 2.3338802, 10)]]";
// Accessing GeoPoint fragments
fragments.GeoPoint place = document.GetGeoPoint("article.location");
var coordinates = place.Latitude + "," + place.Longitude;
var bgcolor = document.GetColor("article.background");
var hex = bgcolor.Hex;
var video = document.GetEmbed ("article.video");
// Html is the code to include to embed the object, and depends on the embedded service
var html = video.Html;
var group = document.GetGroup("article.documents");
foreach (GroupDoc doc in group.GroupDocs) {
try {
fragments.StructuredText desc = doc.GetStructuredText("desc");
fragments.Link link = doc.GetLink("linktodoc");
} catch (Exception e) {
// Missing key
}
}