在本节中,由于模板已在初始应用程序部分中设置,初始页面在初始内容部分中建立,因此可以使用基础脚本来开发应用程序,其中包括启用Communities组件创作功能。 在本节的末尾,网站将正常运行。
默认脚本(在添加呈现播放页模板的组件时创建)将被修改以包含基础页的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...
单击Save All
打开/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>
单击Save All
在编辑模式下在浏览器中查看页面:
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):
要启用社区组件进行创作,请首先按照以下说明操作:
出于此沙盒的目的,请从以下Communities组件开始(通过选中方框启用):
此外,请选择常规组件,例如
为页面段落启用的组件作为的components
属性的值存储在存储库中
/etc/designs/an-scf-sandbox/jcr:content/playpage/par
节点。
在多语言环境中,根页面将包含一个脚本,该脚本将解析来自客户端的请求以确定首选语言。
在这个简单的示例中,正在静态设置根页面以重定向到英语页面,该页面将来可能会开发为包含播放页面链接的主登陆页面。
将浏览器URL更改为根页面:http://localhost:4502/editor.html/content/an-scf-sandbox.html
选择页面信息图标
选择打开属性
在“高级”选项卡上
单击确定
网站发布后,浏览到发布实例上的根页面将重定向到英文页面。
播放社区SCF组件之前的最后一步是添加客户端库文件夹(clientlibs)。… ⇒