Components
博客专区 > _Eddy 的博客 > 博客详情
Components
_Eddy 发表于4年前
Components
  • 发表于 4年前
  • 阅读 92
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】新注册用户域名抢购1元起>>>   

摘要: Adobe CQ5中Component的一些使用细节分析。

一. Component简介##

  1. 作用: 将JCR数据库中的content呈现在你的网站上的一个功能单元

  2. 特性: 可复用,可以包含其它的component,有一个标准化的用户界面, 使用widget,editConfig来配置所呈现的用户界面

  3. 使用: 通常是找libs/foundation/components下合适的component拷贝至自己的apps下,再进行修改


##二. Component的properties ##

<table> <tr> <td>Name </td> <td>Type </td> <td>Description</td> </tr> <tr> <td>.</td> <td> cq:Component</td> <td>Current component. A component is of node type cq:Component.</td> </tr> <tr> <td> cq:isContainer</td> <td> Boolean</td> <td>Checks if this component is a container component. For example a paragraph system component.</td> </tr> <tr> <td> allowedChildren </td> <td> String[]</td> <td>Path of a component that is allowed to be a child of this component.</td> </tr> <tr> <td> allowedParents</td> <td> String[]</td> <td>Path of a component that is allowed to be a parent of this component.</td> </tr> <tr> <td> componentGroup</td> <td> String</td> <td>Group under which the component can be selected in the Sidekick.</td> </tr> <tr> <td> cq:cellName</td> <td> String</td> <td>If set, this property is taken as Cell Id. For more information, please refer to this article in the Knowledge Base.</td> </tr> <tr> <td> cq:noDecoration</td> <td> Boolean</td> <td>If true, the component is not rendered with automatically generated div and css classes.</td> </tr> <tr> <td> cq:templatePath</td> <td> String</td> <td>Path to a node to use as a content template when the component is added from Sidekick. This must be an absolute path, not relative to the component node.Unless you want to reuse content already available elsewhere, this is not required and cq:template is sufficient (see below)</td> </tr> <tr> <td> dialogPath</td> <td> String</td> <td>Path to a dialog in case that the component does not have a dialog node.</td> </tr> <tr> <td> jcr:created</td> <td> Date</td> <td>Date of creation of the component.</td> </tr> <tr> <td> jcr:description</td> <td> String</td> <td>Description of the component.</td> </tr> <tr> <td> jcr:title</td> <td> String</td> <td>Title of the component.</td> </tr> <tr> <td> sling:resourceSuperType</td> <td> String</td> <td>When set, the component inherits from this component.</td> </tr> </table>

  1. cq:isContainer 规定当前component是否可以包含其它component
  2. allowedParents 定义该component允许的父亲component,与父component的allowedChildren 属性对应,实际效果就是页面上:可以从sidekick中拖动一些component到libs/foundation/components/parsys对应的component的效果;
  3. allowedChildren 为当前component定义可以拖入自己内部的component,即自己的子component

<p> (**note:** cq:isContainer,allowedParents,allowedChild三组属性是结合在一起使用的,以系统component libs/foundation/components/parsys为例,要想让自定义的component拖入parsys内,必须符合以下条件:<br/> \*. parsys component,即所谓的父component设置cq:isContainer,为true<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;设置allowedChildren,值为\*,接受所有component<br/> \*.自定义的component,添加属性allowedParents ,值为*/parsys,这样自定义的component才能拖动入parsys中去)</p> 4. componentGroup 定义该component在sidekick中所处的分组 5. cq:noDecoration 如果设置该属性为true,则当前component不使用系统自定义的div,css样式 效果如下: 为component设置该属性之前:页面除了显示component的html外,自动在`<ul>`下添加了一个div标签,是我所不需要的: ![在此输入图片描述][1] 之后,为component添加属性: `cq:noDecoration value=true`,如图: ![在此输入图片描述][2] 结果: ![在此输入图片描述][3] 系统自动添加的样式去除了。 6. sling:resourceSuperType 设置当前component的父component,当前component会继承父component的内容.


三. Component的child node##

<table> <tr> <td>Name </td> <td>Type </td> <td>Description</td> </tr> <tr> <td> design_dialog</td> <td> cq:Dialog </td> <td>Definition of the design dialog.</td> </tr> <tr> <td> cq:childEditConfig</td> <td> cq:EditConfig</td> <td>When the component is a container, as for example a paragraph system, this drives the edit configuration of the child nodes.</td> </tr> <tr> <td> cq:editConfig</td> <td> cq:EditConfig</td> <td>Edit configuration of the component.</td> </tr> <tr> <td> cq:htmlTag</td> <td> nt:unstructured </td> <td>Returns additional tag attributes that are added to the surrounding html tag. Enables addition of attributes to the automatically generated divs. See Modify the auto-generated DIVs using cq:htmlTag blog post.</td> </tr> <tr> <td> cq:template</td> <td> nt:unstructured</td> <td>If found, this node will be used as a content template when the component is added from Sidekick.</td> </tr> <tr> <td> dialog</td> <td> nt:unstructured</td> <td>Definition of the edit dialog.</td> </tr> <tr> <td> icon.png</td> <td> nt:file</td> <td>Icon of the component, appears next to the Title in Sidekick.</td> </tr> <tr> <td> thumbnail.png</td> <td> nt:file </td> <td>Optional thumbnail that is shown while the component is dragged into place from Sidekick.</td> </tr> <tr> <td> \*</td> <td>cq:ClientLibraryFolder</td> <td>define the component's js and css style</td> </tr> <tr> <td> virtual</td> <td>sling:Folder </td> <td>Enables creation of virtual components. To see an example, please look at the contact component at /libs/foundation/components/profile/form/contact.</td> </tr> </table>

<h3>三.1 dialog & design_dialog</h3> component下的dialog和design_dialog是页面的两种维护模式,dialog是在edit mode下编辑的,而design_dialog是在design模式下编辑的;

功能点: 禁用图片的上传功能,只能由content finder里拖动资源,禁用前禁用后

设置component下.../dialog.../items/image(jcr:primaryType为cq:Widget),为该image widget添加属性allowUpload : Name: allowUpload <br/>  Type: String <br/>  Value: false <br/> 即可。

<h3>三.2 global.jsp</h3> component下的每个jsp文件头部引入global.jsp文件<%@include file="/libs/foundation/global.jsp"%> 引入该文件后相当于默认初始化了一些jsp标签和类: e.g slingRequest ,slingResponse ,resource,resourceResolver,currentNode ,log ,sling ,properties ,pageProperties ,pageManager ,component ,designer ,currentDesign ,currentStyle

<h3>三.3 三种方法来从content数据库中取值</h3> properties, currentPage, currentNode

<h3> 三.4 标签库</h3> JSP标签库,cq标签库以及Sling标签库。

<h3>三.5 node cq:EditConfig的properties介绍:</h3> **editConfig's properties:** <br/> **properties1**-cq:actions (String array): 定义该component呈现的操作,<br/> **properties2**-cq:layout (String): : 定义该component修改,删除等功能的呈现方式,值有:rollover,editbar,auto三种,默认rollover点击弹出修改对话框,上图中edit等操作的触发方式是点击edit等的按钮,这就是layout设置为editbar的效果<br/> **properties3**-cq:dialogMode (String): 可设置的值有: floating,inline,auto默认inline,嵌入页面的方式进行编辑,设置为floating时是以页面的弹出框的方式编辑,见下图,第一个是嵌入页面的方式,其二个是以弹出对话框的方式呈现的<br/> ![cq:dialogMode值为inline][6] ![cq:dialogMode值为floating][7] **properties4**-cq:emptyText (String): defines text that is displayed when no visual content is present.<br/> **properties5**-cq:inherit (Boolean): defines if missing values are inherited from the component that it inherits from.<br/> <br/><br/><br/> <h3>三.6 node cq:EditConfig的child node介绍:</h3> <h4>三.6_1 cq:dropTargets node </h4> cq:dropTargets node (node type nt:unstructured) <br/> 定义该component可从content finder接受的资源的类型,组等<br/> <h4>三.6_2 cq:actionConfigs node </h4>cq:actionConfigs (node type nt:unstructured)<br/>定义该component和edit,delete同级别的操作,如下图的my Text操作即是该node定义的,也可以定义在点击my Text操作时触发的事件: ![cq:actionConfigs][8]<br/> <h4>三.6_3 cq:listeners node </h4> (node type cq:EditListenersConfig) <br/> 为该component添加监听器,如(before/after)(edit/copy/insert/move/childinsert/delete), 规定执行这些操作之前\/之后执行的事件.如图 ![cq:listeners][9]<br/> <h4>三.6_4 cq:inplaceEditing node </h4>cq:inplaceEditing node (node type cq:InplaceEditingConfig) <br/> <h4>三.6_5 cq:formParameters node </h4>cq:formParameters node (node type nt:unstructured) <br/>

第一次用markdown,搞得好累!!!

标签: adobe CQ Component
  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 5
博文 21
码字总数 16825
×
_Eddy
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: