在本节中,由于模板已在 初始应用 ,以及 初始内容 部分,可以使用基础脚本来开发应用程序,其中包括启用使用社区组件进行创作的功能。 在本节的末尾,网站将正常运行。
默认脚本(在添加呈现播放页模板的组件时创建)将被修改以包含基础页的head.jsp和本地body.jsp。
第一步是向 /apps/an-scf-sandbox/components/playpage
节点,以便继承超类型的脚本和属性。
使用 CRXDE Lite:
sling:resourceSuperType
String
foundation/components/page
/apps/an-scf-sandbox/components/playpage
并双击该文件 playpage.jsp
,以在编辑窗格中将其打开。<%--
An SCF Sandbox Play Component component.
This is the component which renders content for An SCF Sandbox page.
--%><%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" %><%
%><%
// TODO add your code here
%>
请注意打开/关闭脚本标记,请替换“ // TODO …” 包含用于 <html>.
超级类型的 foundation/components/page
,该文件夹中未定义的任何脚本都将解析为 /apps/foundation/components/page
文件夹(如果存在), /libs/foundation/components/page
文件夹。
<%--
An SCF Sandbox Play Component component: playpage.jsp
This is the component which renders content for An SCF Sandbox page.
--%><%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" %>
<html>
<cq:include script="head.jsp"/>
<cq:include script="body.jsp"/>
</html>
基础脚本 head.jsp
不需要覆盖,但基础脚本 body.jsp
为空。
要设置以进行创作,请叠加 body.jsp
,并在正文中包含段落系统(parsys):
导航到 /apps/an-scf-sandbox/components
选择 playpage
节点
右键单击并选择 Create > Create File...
单击 全部保存
打开 /apps/an-scf-sandbox/components/playpage/body.jsp
并粘贴以下文本:
<%--
An SCF Sandbox Play Component component: body.jsp
This is the component which renders content for An SCF Sandbox page.
--%><%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" %>
<body>
<h2>Community Play</h2>
<cq:include path="par" resourceType="foundation/components/parsys" />
</body>
单击 全部保存
在编辑模式下在浏览器中查看页面:
http://localhost:4502/editor.html/content/an-scf-sandbox/en/play.html
您不应仅看到标题 社区游戏,还有用于编辑页面内容的UI。
当两个侧面板都切换为打开,并且窗口足够宽以便同时显示侧内容和页面内容时,会看到资产/组件侧面板。
http://localhost:4502/cf#/content/an-scf-sandbox/en/play.html
以下是播放页面在经典UI中的显示方式,包括内容查找器(cf):
要启用社区组件进行创作,请首先按照以下说明操作:
出于此沙盒的目的,请首先 社区 组件(通过选中框启用):
此外,选择 常规 组件,例如
为页面段落启用的组件作为 components
属性
/etc/designs/an-scf-sandbox/jcr:content/playpage/par
节点。
在多语言环境中,根页面将包含一个脚本,该脚本将解析来自客户端的请求以确定首选语言。
在这个简单的示例中,正在静态设置根页面以重定向到英语页面,该页面将来可能会开发为包含播放页面链接的主登陆页面。
将浏览器URL更改为根页面: http://localhost:4502/editor.html/content/an-scf-sandbox.html
选择页面信息图标
选择 打开属性
在“高级”选项卡上
单击 确定
网站发布后,浏览到发布实例上的根页面将重定向到英文页面。
播放社区SCF组件之前的最后一步是添加客户端库文件夹(clientlibs)。… ⇒