內容片段範本 content-fragment-templates
建立內容片段時會選取範本。 它們為新片段提供基本結構、元素和變數。 用於內容片段的範本須受限於Granite Configuration Manager。
現成可用的範本位於下:
/libs/settings/dam/cfm/templates
您可以在下列位置建立內容片段的網站專屬範本:
-
/apps/settings/dam/cfm/templates
用於覆蓋現成範本或提供客戶特定、應用程式範圍範本(不打算在執行階段擴充/變更)的位置。 -
/conf/global/settings/dam/cfm/templates
必須在執行階段變更的執行個體範圍客戶特定範本的位置。
優先順序為(遞減順序) /conf
, /apps
, /libs
.
/libs
路徑。/libs
下次升級執行個體時會被覆寫(當您套用hotfix或feature pack時,很可能會被覆寫)。-
重新建立所需專案(即存在於中的專案)
/libs
)下/apps
-
進行任何變更
/apps
範本的基本結構儲存在下方:
conf
global
settings
dam
cfm
templates
<template-name>
...
特定結構為:
+ <template-name>
- jcr:primaryType
- jcr:title
- jcr:description
- initialAssociatedContent
- precreateElements
- version
+ elements
- jcr:primaryType
+ <element-name>
- jcr:primaryType
- jcr:title
- defaultContent
- initialContentType
- name
... + other element definitions
+ variations
- jcr:primaryType
+ <variation-name>
- jcr:primaryType
- jcr:title
- jcr:description
- name
... + other variation definitions
有關節點及其屬性的更多詳細資訊如下:
-
範本
table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 5-row-3 6-row-3 html-authored 名稱 類型 值 <template-name>
nt:unstructured
此節點是每個範本的根。 此為必填欄位,且應具有唯一名稱。 jcr:title
String
必填
範本的標題(顯示在 建立片段 精靈)。 jcr:description
String
可選
說明範本用途的文字(顯示在 建立片段 精靈)。 initialAssociatedContent
String[]
可選
一個陣列,內含的集合路徑依預設應關聯至新建立的內容片段。 precreateElements
Boolean
必要
true
,表示內容片段元素(主元素除外)的子資產是否應在建立內容片段時建立; false 是否應「即時」建立。注意:此引數目前必須設為
true
.version
Long
必要
內容結構的版本;目前支援:
注意:此引數目前必須設為
2
. -
元素
table 0-row-3 1-row-3 html-authored 名稱 類型 值 elements
nt:unstructured
必要
包含內容片段元素定義的節點。 這是強制性的,而且至少需要包含一個子節點 主要 元素,但可以包含[1..n]個子節點。
使用範本時,元素子分支會複製到片段的模型子分支。
第一個元素(在CRXDE Lite中檢視時)會自動視為 主要 元素;節點名稱不相關,且節點本身除了由主要資產表示外,沒有特殊意義;其他元素會作為子資產處理。
-
元素名稱
table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 5-row-3 html-authored 名稱 類型 值 <element-name>
nt:unstructured
此節點會定義元素。 此為必填欄位,且應具有唯一名稱。 jcr:title
String
必要
元素的標題(顯示在片段編輯器的元素選取器中)。 defaultContent
String
可選
預設值:「」
元素的初始內容;僅用於 precreateElements
=true
initialContentType
String
可選
預設:
text/html
元素的初始內容型別;僅用於
precreateElements
=true
;目前支援:text/html
text/plain
text/x-markdown
name
String
必要
元素的內部名稱;對片段型別而言必須是唯一的。 -
變數
table 0-row-3 1-row-3 html-authored 名稱 類型 值 variations
nt:unstructured
可選
此選用節點包含內容片段初始變數的定義。 -
變數名稱
table 0-row-3 1-row-3 2-row-3 3-row-3 html-authored 名稱 類型 值 <variation-name>
nt:unstructured
如果有變數節點,則必須填寫此項
定義初始變數。
依預設,變數會新增至內容片段的所有元素。變數會有與個別元素相同的初始內容(請參閱
defaultContent/ initialContentType
)
jcr:title
String
必要
變數的標題(顯示在片段編輯器的 變數 標籤(左側邊欄)。 jcr:desciption
String
可選
預設值:「」
提供變化描述的文字 (顯示在片段編輯器的 變數 標籤(左側邊欄)。