2 Replies Latest reply on Sep 3, 2012 9:44 AM by smurfsky101

    how can get all the components used on the current page

    efish11 Level 1

      how can I get list of all components being used on the current page using javascript. I have tried CQ.WCM.getComponentList(CQ.WCM.getPagePath()) but this seems to list all the components available.

       

       

      Environment CQ 5.5 Update 1, Widnows 7

        • 1. Re: how can get all the components used on the current page
          Ryan Lunka Level 3

          You have to remember that once you are in JS, you are only really able to retrieve markup or representations of the DOM.  The markup is the result of a combination of components, which is technically a "server only" concept.  Components are just a way for CQ to organize executable code, so once a page is rendered a component isn't really a thing.  The closest thing I can think of is to list all of the DIVs that represent a component wrapper that are on the page, but this is error prone and clunky.  You could also make AJAX calls back to the server to retrieve a list of the components by node name, but that approach would not return synthetic resources (ones that render, but do not have a node representing them).

           

          Why are you trying to do this?  Maybe someone has a better idea, but this has a bad smell to me.

          • 2. Re: how can get all the components used on the current page
            smurfsky101

            I dont know what your use case is - but if you append the querystring '?debug=layout' to the url of the page you are looking at, you can at least get a view of the resources included in the web browser.

             

            What's the intended use?