本文介绍了CQ5将组件预加载到parsys中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇是否有人知道如何使用默认组件加载parsys.

I'm curious if anyone knows how to have a parsys load w/ default components already in it.

我要完成的工作如下:

Form Component
  - form-parsys
      - input component
      - input component

在大多数情况下,这很简单.我创建了一个具有parsys的表单"组件.我希望此表单组件加载一些已经设置的默认输入组件.这些输入组件需要成为form-parsys节点的一部分,以便可以在用户添加的输入组件之间进行重组.

For the most part this was pretty straight forward. I created a "form" component that has a parsys in it. What I would like is for this form component to load with a few default input components already set. These input components would need to be a part of the form-parsys node, so that they can be reorganized amongst user added input components.

不知道是否有任何文档,因为我找不到任何文档,但是我确定这不是完全不可能的,我想看看是否有人曾做过这样的事情,然后再开始黑客.离开.

Not sure if there is any documentation out on this as I couldn't find any, but I'm sure it's not entirely impossible and wanted to see if anyone has done anything like this before, before I go ahead and start hacking away.

谢谢你布罗迪

推荐答案

我认为您正在寻找的是

I think what you are looking for are templates.

在CQ5中,模板可用于创建具有预定义内容的页面,这可以是parsys(具有组件)或在创建页面时可能需要在页面中使用的任何其他节点.

In CQ5, templates can be used to create pages with a predefined content, this can be a parsys (with components) or any other node you might want in your page when it is created.

在您的情况下,您可以定义一个模板,其中包括parsys组件以及该parsys中您想要的任何内容.您还可以设置使用该模板可以在何处创建页面的规则.

In your case, you can define a template that includes a parsys component and whatever you want inside that parsys. You can also set rules for where a page can be created using that template.

创建(或编辑,因为可能已经有一个)模板之后,可以使用siteadmin使用模板创建新页面.将创建该页面,并将模板jcr:content下面的所有内容复制到新页面中.如果您需要不同类型的初始内容",甚至可以为同一类型的页面提供多个模板

After you have created (or edited, since you might already have one) the template, you can use the siteadmin to create a new page using your template. The page will be created and all the content below the jcr:content of the template will be copied into the new page. You can even have several templates for the same kind of page, if you need different types of 'initial contents'

一个包含带有某些内容的parsys的模板的示例可能看起来像这样(我主要是从内存中写出来的,可能会有错误):

An example of a template that includes a parsys with some content might look like this (I'm writing this mostly from memory, might have errors):

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="A form"
jcr:primaryType="cq:Template"
jcr:title="A form"
allowedChildren="/apps/app1/templates/home_page"
allowedParents="/apps/app1/templates/form_page"
allowedPaths="[/content(/.*)*]"
ranking="{Long}100">
<jcr:content
    jcr:primaryType="cq:PageContent"
    sling:resourceType="app1/pages/form_page">
  <parsys
    jcr:primaryType="nt:unstructured"
    sling:resourceType="foundation/components/parsys" >
     <component
         jcr:primaryType="nt:unstructured"
        sling:resourceType="foundation/components/text"
         text="here is some text"/>
     <!-- more components here-->
 </parsys>
</jcr:content>
</jcr:root>

这篇关于CQ5将组件预加载到parsys中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 09:59