3 Replies Latest reply on Jul 22, 2013 6:06 AM by AlertAlert23

    Determine if current component is being pulled in by paragraph reference?

    AlertAlert23

      Is there a way to determine at the component level if the current component is currently being imported into a paragraph reference component? A simple example would look like this in the component's jsp:

       

      if (/* Being Referenced */) {
           out.write("This component is pulled in by a paragraph reference");
      } else {
           out.write("This component is the original");
      }
      

       

      I thought i'd be able to tell by using resource.getParent(), but that returns the original component's parent.

       

      I know i could compare the page path with the component's resource path if they were on different pages, but that wouldn't work out if the reference component and original component were on the same page.

        • 1. Re: Determine if current component is being pulled in by paragraph reference?
          rush_pawan Level 4

          Hello,

           

          I think there is no OOTB API which gives you this information because the reference relation maintance from one side (the reference component). So identifying it inside the component would be difficult and you have to write custom code. As of now what i can think you (if this is your fix requirement) to search query and iterate the result via validating it with current page path. This way you can resolve your other issue when reference and the component are on same page.

           

          A sample SQL2 query would be

           

          SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/project path]) and CONTAINS(s.path, 'path to referenced component instance')

           

          an exmaple

           

          SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/geometrixx]) and CONTAINS(s.path, /content/geometrixx/en/toolbar/jcr:content/content_parsys/a_listing')

           

          Let me know for more information.

          Thanks,

          Pawan

          • 2. Re: Determine if current component is being pulled in by paragraph reference?
            Jörg Hoh Adobe Employee

            It's really hard to determine if a component has been referenced by the reference component at all, rush_pawan showed you an reasonable approach for that. But can you give us your requirements? Maybe there is a better solution for your problem.

             

            Thanks,

            Jörg

            • 3. Re: Determine if current component is being pulled in by paragraph reference?
              AlertAlert23 Level 1

              Sure, this is what we're doing (i'm sure there must be a better way) -

               

              Our pages will serve many users across different areas and roles. The authors wanted the ability to create one master page that will display certain components to only a certain area or role. For example, one text box should only be displayed to "south" users and another only to "west" users. To accomplish this we added tagging for each component and when a component loads on a page it does a check to display if the user has the same tags it has been tagged with. Looks something like this in the component jsp -

               

              <% if (componentAreaTag == userAreaTag) { %>
                   <h1>Component Is Displayed</h1>
              <% } %>
              

               

              The problem with this is that a reference component also needs to be tagged independently of the component it is referencing. So right now it processes the reference component's tags to see if the user can access the component and then checks the referenced component before displaying. Ends up processing something like this -

               

              <% if (referenceComponentTag == userTag) { %> //From reference component
                   <% if (componentTag == userTag) { %> //From component being referenced
                        <h1>Component Is Displayed</h1>
                   <% } %>
              <% } %>
              

               

              We need it not to care about the original component's tag when coming in through a reference component.