質問

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

What I'd like to accomplish is the following:

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

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.

thank you Brodie

役に立ちましたか?

解決

I think what you are looking for are templates.

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.

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.

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'

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>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top