9 Replies Latest reply on Oct 29, 2012 11:48 AM by _edmond

    Is there a way to create custom clientlibs that only apply to a specific app?

    _edmond

      for example, i'd like to add some custom widgets specific to a custom application, say apps/mycustom1, but i don't want these custom widgets available for my other custom application, say apps/mycustom2.  this is because i plan to have a www.mycustom1.com and www.mycustom2.com.  from what i've read so far, you can add your own custom clientlib widget by adding to the categories "cq.widgets".  but if i do this, my custom widget will show up for mycustom1 and mycustom2 apps.

       

      on a somewhat related note, i've found that the following online doc: http://dev.day.com/docs/en/cq/current/developing/components/clientlibs.html, regarding overriding libraries in /libs, does not work.  i've tried creating my own apps/cq/ui/widgets clientlib, but all it did was include my apps/cq/ui/widgets clientlib along with the libs/cq/ui/widgets clientlib.  I have the clientlib set up the same way as the cq widgets clientlib and tried overriding the js.txt, but when loading my page, it pulls down both widgets.js in apps and libs.  are the docs incorrect here?

       

      thanks,

        • 1. Re: Is there a way to create custom clientlibs that only apply to a specific app?
          orotas Level 4

          I believe the answer to your question is yes, how you do it depends on how you are utilizing the client libraries.

           

          Are you concerned with these files getting loaded in author or publish or both? Are these widget client libraries or or general CSS and JavaScript for site?

          • 2. Re: Is there a way to create custom clientlibs that only apply to a specific app?
            _edmond Level 1

            I'm trying to do things "out of the box", which means i'm trying to reuse the existing clientlibs.  this means i'm making use of wcm/core/components/init/init.jsp, which includes the "cq.wcm.edit" clientlib.  i believe the easiest way for me to do this is for me to create a "custom.wcm.edit" category which will include my "mycustom1.widgets" along with "cq.widgets", but then this forces me to copy/paste the entire init.jsp into my apps folder.  i was hoping for a better way than to have to copy the entire init.jsp just to change up the specific categories used for a specific app.

             

            as for your question, i got down this path as i was trying to add my own custom placeholders to display in edit mode as i've created my own custom components.  but with what i've read online, the way to do it is just to add to "cq.widgets" with my own widgets clientlibs, which would make it available to all apps in the system.

            • 3. Re: Is there a way to create custom clientlibs that only apply to a specific app?
              MarcGriebenow

              Why don't you create a clientlibs folder below your apps/custom/ with properties jcr:primaryType = cq:ClientLibraryFolder and categories = mycustomsomething

              Then you can include via <cq:includeClientLib categories="mycustomsomething"> in your template or your component

               

              Notice it won't work on publish, you either have to create such a folder below your etc/designs/custom/... or use the mechanism like geometrixx-outdoors does

              • 4. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                orotas Level 4

                I think that given your requirements you are probably best off creating a client library under each custom app and overriding the placeholder CSS styles in that client libraries CSS and then including that client library in your custom apps head.jsp (wrapped in a conditional statement so it only prints out in author mode). It will be less work and less surgery than the approach you are taking. Leaving aside any issues you have overriding /libs versions of client libraries the core issue would be getting different overrides to load in different apps. I'd say that any mechanism you find acheive your goal would be just as much a customization as do this in a custom library loaded in the head of your pages so you are better of going down the path of least resistence. I think that Client Library themes is close to what you are looking for, but it's based off of query string parameters so I am don't think it's be easy to leverage.

                1 person found this helpful
                • 5. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                  _edmond Level 1

                  thanks for the input, guys.  it sounds like i am going to have to basically do my own custom init.jsp the mimics the initial part of cq's init.jsp, ie.

                   

                  if (WCMMode.fromRequest(request) != WCMMode.DISABLED) {

                      String dlgPath = null;

                      if (editContext != null && editContext.getComponent() != null) {

                          dlgPath = editContext.getComponent().getDialogPath();

                      }

                      %><cq:includeClientLib categories="mycustom.cq.wcm.edit" />

                  <% } %>

                   

                  by the way orotas, can you direct me to any info about themes?  i thought it might help me too, but i've been trying to read up on that as well and can't seem to find any info online on that subject.

                   

                  thanks!

                  • 6. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                    orotas Level 4

                    There isn't much documentation that I can find. The most I have found is the reference here - http://dev.day.com/docs/en/cq/current/howto/taglib.html#par_title_9. It says that the theme name is extracted from the request (which I interpreted to mean a query string parameter).

                     

                    I don't think you have override init if you are implementing your own templates. You probably have a head.jsp where you load /libs/wcm/core/components/init/init.jsp. If you load your customer client lib after init you can exclude the dlgPath stuff and just load the client lib.

                    • 7. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                      _edmond Level 1

                      yup, that's what i meant actually.  the code snippet i had above would go into my own mycustom/init/init.jsp, and my head.jsp would reference both that init.jsp and cq's core init.jsp.  that's what i'm going to do for now until i find a better solution.

                       

                      thanks again,

                      • 8. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                        Bayani Portier

                        Not totally sure about your requirements, but if you have two distinct websites, could you perhaps leverage your ACL to restrict a set of components for a particular user, and have seperate logins for each site?

                         

                        To me, as a CMS, you may want to have components that can be accessed across a set of sites that you have deployed, and would only really want to restrict by customer.

                        • 9. Re: Is there a way to create custom clientlibs that only apply to a specific app?
                          _edmond Level 1

                          i don't think ACL restriction handles restricting of clientlibs though, does it?  because what i'm worried about it the "global" inclusion of clientlibs since clientlibs are picked up by category name, regardless of which project you want it to belong to.