Created

Feb 06, 2013

Add default components in the Sidekick

Posted by Vianney Baron

Lately I've had a few developers come to me with the same question: how do you set the default components appearing in the Sidekick when first opening a page?

It's a legitimate question, switching to Edit mode for every page can be quite annoying, and we don't necessarily want to let the authors decide what components they are allowed to use in a particular Parsys.

However this is quite easy to fix, and here is how.

When building your web site with CQ, you will define a clientlib to store all your graphical assets (JS, CSS and images) as described in this post. But what developers often overlook is the fact that you can also use the clientlib to store meta information, like the list of default components appearing in Sidekick!

To see an example of this navigate to /etc/designs/geometrixx-outdoors/jcr:content/page/par in crxde and look at the properties of the node:

file

Here you see we are using the "components" property, and we're simply listing the components we want to see appearing in the sidekick when we open a page using the page component defined in our Geometrixx Outdoors application (this one: /apps/geometrixx-outdoors/components/page), this will also restrict the number of components your can drag and drop in this specific parsys, which can be really useful when you use different Parsys for different purposes on the same page. Simply put the path of each component in this String array and voila!

One more thing though: you might argue that having to list every single component in there is a bit annoying, but there's actually a way around that. You can directly use groups in there as well:

file

Then it becomes quite obvious that groups should be used as often as possible, especially because they are so easy to setup: simply add a "componentGroup" property to the root of you component and that's it (see here: /apps/geometrixx-outdoors/components/colctrl for example). 

COMMENTS

  • By Gemblgembelgembelgembel - 11:15 PM on Feb 07, 2013   Reply
    Add a componensgroup
    • By Ruben - 8:56 PM on Feb 11, 2013   Reply
      Thank you for this nice, clear overview!

      A subtle note regarding the following explanation : "listing the components we want to see appearing in the sidekick when we open a page using the page template defined in our Geometrixx Outdoors application (this one: /apps/geometrixx-outdoors/templates/page)"

      Actually the classification within the "/etc/designs/geometrixx-outdoors/jcr:content/" node is based on the last part of the "sling:resourceType" and not the path of the "cq:Template". This is a subtle difference and in most cases (it is a best practice) the relative path of both will be the same... In this case "/apps/geometrixx-outdoors/templates/page" has the resourceType "geometrixx-outdoors/components/page", so the last part of the sling:resourceType "page", is used as relative path to store meta information within the etc/designs/geometrixx-outdoors/jcr:content/...

      So when for example 2 templates ('/apps/geometrixx-outdoors/templates/page_home' & '/apps/geometrixx-outdoors/templates/page') are using the same resourceType (e.g. geometrixx-outdoors/components/specialresourcetype), their meta information will be stored on the exact same location (within '/etc/designs/geometrixx-outdoors/jcr:content/specialresourcetype/')... Maybe something to keep in mind when you have lots and lots of templates...

      Best regards,
      Ruben
      • By Vianney Baron - 4:59 PM on Feb 13, 2013   Reply
        Thanks Ruben that's a nice catch, I've amended the entry accordingly!
        • By shakeeb - 1:41 PM on Mar 03, 2013   Reply
          A really helpful piece of work .
          • By yaoxing - 11:55 AM on May 07, 2013   Reply
            So if I have a component called "my_item" in /apps/my_project/components/system/my_item, do I have to create another folder in /etc/designs/my_project/jcr:content/system/my_item? And add the property under this newly created folder?
            • By pregnancy hair - 10:00 PM on May 23, 2013   Reply
              This information really helped me understand Things beyond my expertise. websites like this expanding knowledge everyone and I hope something like this will continue to grow

              ADD A COMMENT