我正在使用Magnolia - CMS创建一个网站。现在我正在实现一个博客页面,在每个博客页面上都有几个分享按钮。现在我正在忙于实现Twitter分享按钮。在这里,我将使用Twitter卡片。为此,我需要在元标记中提供图像的URL。主要问题是:我像这样检索我的图像:${damfn.getAssetLink(content.blogImage)}。这只返回到我的资源的相对路径。有没有一种快速的方式(在freemarker中),可以将其转换为绝对链接?
非常感谢!
非常感谢!
Components.getComponent(ServerConfiguration.class).getDefaultBaseUrl()
来检索它。getStartupTasks(...)
,类似于以下内容:@Override
protected List<Task> getStartupTasks(InstallContext installContext) {
final List<Task> tasks = new ArrayList<>();
tasks.add(new InstallRendererContextAttributeTask("rendering", "freemarker", "serverConf", ServerConfiguration.class.getName()));
tasks.add(new InstallRendererContextAttributeTask("site", "site", "serverConf", ServerConfiguration.class.getName()));
return tasks;
}
"${serverConf.defaultBaseUrl}/${ctx.contextPath}/${damfn.getAssetLink(content.blogImage)}"
${Request}
,因此它可以是"${Request.domain}/${ctx.contextPath}/${damfn.getAssetLink(content.blogImage)}",而无需将serverConfiguration注入渲染器。
${ctx.contextPath}
。 - Jozef Chocholacek