6 Replies Latest reply on Oct 3, 2012 11:25 PM by chaack

    Make Custom Component Available to Reference Component

    Jayatl Level 1

      Hello,

       

      I would like to make several of my components available to the Reference component (so that the Auther can reuse them throughout the site).  When I place a refernce component ona  page, none of my components are available to be selected.  i've tried setting the sling:resourceSuperType of my components to "foundation/components/par, parbase and parsys" - none of them do the trick.

       

      What exactly do I need to do to get any component to be used with the built-in refernce component?  Thanks

        • 1. Re: Make Custom Component Available to Reference Component
          Ryan Lunka Level 3

          I don't think you have to do anything special.  Remember that you are actually referencing an instance of your component and it has to be persisted in the JCR to be selected (synthetic resources are not going to work).  If your component is now showing up, I'd be looking at if/how its corresponding node is persisted beneath a page's jcr:content node.

          • 2. Re: Make Custom Component Available to Reference Component
            Jayatl Level 1

            Ryan,

             

            Thanks for the reply; however I'm still confused.  Let's say I create a simple component as outlined below; how would I make this available to the Reference (I realize I could make this simple component part of the template, but I want the Author to be able to reuse it via the reference Component).

             

            <%@include file="/libs/foundation/global.jsp"%>

            <div>

              Hello World!!

            </div>

             

            What do I need to do to make this simple example visible to the Reference component?

            • 3. Re: Make Custom Component Available to Reference Component
              Ryan Lunka Level 3

              The reason that your example component will not be availale from the reference component is exactly I as I laid out before.  This component does nothing but output static text and CQ only stores components in the repository if it needs to.  Static text like this doesn't need to be persisted in any way.  Unless you manually add a node that represents it in the JCR (I think adding to a parsys does this automatically), the reference component will not be able to access the component.  The reference component is just going to let you select a location in the repository and it will let you select from whatever components it finds in the repository at that level.

              • 4. Re: Make Custom Component Available to Reference Component
                Jayatl Level 1

                Right - I thought adding a parasys would do it as well - but it doesn't.  If I modified the example above (wasn't meant to be taken literally), it still isn't available.

                 

                <%@include file="/libs/foundation/global.jsp"%>

                <div>

                  <div>Hello World!!</div>

                  <div><cq:include path="mypar" resourceType="foundation/components/parsys"/></div>

                </div>

                • 5. Re: Make Custom Component Available to Reference Component
                  Yogesh Upadhyay Level 4

                  Jayati,

                   

                  You can see how that node is persisted in repository to find out why it is not showing in reference component. Most of the time it is because there is no valid sling:resourceType associated with it. Can you send JSON or XML representation of valid and invalid resource (/path/jcr:content.json) ?

                   

                  Yogesh

                  • 6. Re: Make Custom Component Available to Reference Component
                    chaack Level 1

                    did you try with ctrl-c to copy your source and ctrl-alt-v to paste it into the target position?

                     

                    christian