Embedding Widgets in Templates

You can also embed widgets in web content templates. Core apps and custom apps, instanceable or non-instanceable can be embedded in web content templates. Below are examples of embedding a Language widget in FreeMarker and Velocity:

FreeMarker:

<@liferay_portlet_ext["runtime"] portletName="com_liferay_portal_kernel_servlet_taglib_ui_LanguageEntry" />

Velocity:

$theme.runtime("com_liferay_portal_kernel_servlet_taglib_ui_LanguageEntry");

In addition to embedding widgets in templates, you can embed a template within another template. This allows for reusable code, JavaScript library imports, scripts, or macros.

Below are examples of embedding template in FreeMarker and Velocity:

FreeMarker

<#include "${templatesPath}/[template-key]" />    

Velocity

#parse ("$templatesPath/[template-key]")

The Template Key can be found when editing a previously published template.

Figure 1: You can find the Template Key when view the Edit page for a template..

Figure 1: You can find the Template Key when view the Edit page for a template..

« Adding Templates with StructuresUsing Taglibs in Templates »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています