4 Replies Latest reply on Jun 18, 2012 7:52 AM by Mr_JCSG

    How to create a component with static image?

    Mr_JCSG

      I would like to create a component that has an <img> static banner. This way I can include it in a template newsletter as header so that page authors don't have to import it every time they want to create a new newsletter

       

      Is there a way to accomplish this. I would appreciate the help.

        • 1. Re: How to create a component with static image?
          kasq Level 3

          Hi,

           

          You can just create a file newsletter_header.jsp file for a component which will render your newsletter page - template.

          Then you need add this file in the jsp which will build entire stucture (html) of newsletter page by adding something like:  <cq:include script="newsletter_header.jsp" />

          Then in this file just add <img src="path to your image file"/>, for example if it will be a static image you can place it inside /etc/design/your_project/images/banner.

           

          That's all.

          • 2. Re: How to create a component with static image?
            Mr_JCSG Level 1

            kasq,

             

            Thanks for your answer. I have managed to put an image using your intruction. However, what I really want to do is to have a default image on the header component so that this image can be either changed by the author or left alone as a default image.

             

            Do you have any idea on how to accomplish this?

             

            Thanks

            • 3. Re: How to create a component with static image?
              kasq Level 3

              In this case you need create a custom component like newsletter_header_image based for example on the text and image libs\foundation component.

              Then inside a jsp for this component you can check if the author set a path to a image using a dialog or not.

              In case when the property for a image will be empty you will add your static image in the html, if the property will be set by author then you add in the code path to image draged and droped by the author.

               

              The rest is almost the same like I wrote in my previous post. You need only in the newsletter_header.jsp include a custom component using something like:

               

              <cq:include path="newsletter_header" resourceType="your_apps/components/newsletter_image_header"/>

               

              I hope that this helps you.

              kasq

              • 4. Re: How to create a component with static image?
                Mr_JCSG Level 1

                You suggestion is pretty helpful, I will start working on it and see If I can get something working. Thanks