This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From the browser | |
var experimentCookie = prismic.startExperiment ? prismic.utils.docCookies.getItem('io.prismic.experiment') : null; | |
var experimentRef = experimentCookie ? api.experiments.refFromCookie(experimentCookie) : null; | |
var ref = experimentRef || api.data.master.ref; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// This is necessary for the edit button | |
window.prismic = { | |
endpoint: 'https://lesbonneschoses.prismic.io/api' // replace by your repository's endpoint | |
}; | |
</script> | |
<script type="text/javascript" src="//static.cdn.prismic.io/prismic.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example ref selection for NodeJS with ExpressJS | |
var ref = req.cookies[Prismic.previewCookie] || Api.master(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example preview endpoint for NodeJS with ExpressJS | |
exports.preview = exports.route(function(req, res, ctx) { | |
var previewToken = req.query['token']; | |
ctx.api.previewSession(previewToken, ctx.linkResolver, '/', function(err, redirectUrl) { | |
res.cookie(Prismic.previewCookie, previewToken, { maxAge: 60 * 30, path: '/', httpOnly: false }); | |
res.redirect(redirectUrl); | |
}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Play Scala | |
val ref = queryRef orElse { | |
request.cookies.get(Experiment.cookieName) map (_.value) flatMap api.experiments.refFromCookie | |
} getOrElse api.master.ref |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Prismic experiments, goes right after your Google Analytics script --> | |
<!-- Replace {googleId} by the GoogleId of the current experiment, using your template language --> | |
<script src="//www.google-analytics.com/cx/api.js?experiment={googleId}"></script> | |
<script src="//static.cdn.prismic.io/prismic.js"></script> | |
<script>prismic.startExperiment("{googleId}", cxApi);</script> | |
<!-- End of Prismic experiments --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accessing image fields | |
fragments.Image.View imageView = doc.GetImageView("product.image", "main"); | |
String url = imageView.Url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Accessing image fields | |
image = doc.get_image('product.image') | |
# By default the 'main' view is returned | |
url = image.url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Accessing image fields | |
image = doc.get_image('product.image') | |
# Most of the time you will be using the "main" view | |
url = image.main.url |