Created

Jun 24, 2012

Defaults in your CQ5 component

Posted by Feike Visser

When you have read my post around default components in your parsys then if you take it a step futher you want to have also defaults at component level.

In this post I will take the Text & Image component and will make the following changes when you drag this component onto your page:

  • There is already a default text
  • An image is already pre-filled
Both items (text and image) can be changed by the author after the component is placed on a page.


Component

We start by using the Text & Image component in a content page and specify a value for the Text and drop an image in the component.

I have used one of the default images from the Geometrixx application.

cq_template-1

Nodes

After you added the component to the page and the values are specified, go to CRXDELite and look at the nodes created for the Text & Image component.

You see a "textimage" node with a childnode called "image" where the image details are stored. At the level of "textimage" the text is specified.

cq_template-2

Changes

Before we can make any changes we will overlay the default Text & Image component, this is located in /libs/foundation/components/textimage.

Create a folder structure "foundation/components" in the "apps" folder and copy the default component in that location.

cq_template-3

Trick

Ok, here comes the trick. Create a node cq:template of the type nt:unstructured under your component.

In the node add the two properties from the "textimage" node

  • "text", value "<p>This is some text</p>"
  • textIsRich, value "true"
cq_template-6

Now copy the "image" node (from the contentpage) so that is a child of the cq:template node.

cq_template-5

Test

To test the changes make sure you have saved the newly created nodes and you have refreshed the content page.

When you now drag/drop the Text & Image component on your page you see it contains a default text and a default image.

This all done by creating nodes, not by coding!


Feike Visser (twitter: @heervisscher)

COMMENTS

  • By Alex - 11:06 PM on Jun 24, 2012   Reply
    Note that the node type of the cq:template node is irrelevant. I would use nt:unstructured and only use cq:Template for page templates (it's only meant for them), otherwise you might end up with one of those component templates in the create page dialog.
  • By Beth - 4:03 PM on Jun 25, 2012   Reply
    This is great. Does this work for page components too? I want to prepopulate a new page with components, and then give those components defaults.
  • By Beth - 4:22 PM on Jun 25, 2012   Reply
    I get it! You covered that in your other post. Thanks for sharing!
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Mallik Vamaraju - 5:59 PM on Mar 15, 2013   Reply
    thanks for sharing.
  • By Benni wagner - 10:07 AM on Mar 20, 2013   Reply
    Thanks for sharing this awesome information. The illustration are really crucial for understanding - thank you!
  • By www.interiordesigngroups.com - 8:38 AM on Mar 24, 2013   Reply
    This will be cool go for it I will use it. Thank You
  • By may ozone - 9:29 AM on Mar 24, 2013   Reply
    Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial. Appreciate your sharing.
  • By Yan - 8:17 PM on Mar 27, 2013   Reply
    I found a possible bug. Adding cq:template of type nt:unstructured worked great when dragging the component from the sidekick. However, when I tried to move the component to another parsys, it would copy the copy the component instead of moving it. In other words, after the move, once I refreshed the page, the original component would exist in both parsys.

    I experienced the same behavior when I changed node type to cq:template, and the behavior ceased as soon as I deleted this node.

    Has anyone else experienced this? I'm using CQ 5.4
  • By jual propolis murah - 12:15 PM on Apr 05, 2013   Reply
    informative post, its so useful, keep it up
  • By manfaat madu - 12:15 PM on Apr 05, 2013   Reply
    wow, i dont know that, this is a great share, thank you
  • By belly bands for dogs - 12:16 PM on Apr 05, 2013   Reply
    nice share, it open my mind even more now, thanks
  • By wooden dog crates - 12:16 PM on Apr 05, 2013   Reply
    i dont know at first that it will be a useful information, but really, thank you for posting it
  • By bee propolis hd - 12:16 PM on Apr 05, 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
  • By diễn đàn seo - 3:38 AM on Apr 18, 2013   Reply
    thank you
  • By cộng đồng lập trình - 3:39 AM on Apr 18, 2013   Reply
    i like it
  • By hdi bee propolis - 9:41 AM on Apr 21, 2013   Reply
    awesome information man, thx
  • By Hayley - 10:47 PM on Apr 23, 2013   Reply
    Is there a way to do this for subcomponents but not pages?

    For example, my component "Big Component" does a cq:include of "small component"
    small component has various properties. I would like to in "Big Component" provide a default "small component" and defaults on those properties, but that only apply to "Big Component".

    It does not seem to work to add a "small component" node to cq:template, and it doesnt appear that you can add it to the jcr:content node under bigComponent.jsp either. Any thoughts?
  • By Cheap Louis Vuitton Sunglasses - 8:12 AM on Apr 25, 2013   Reply

    We have all the best and newest styles of Epi Leather Handbags that you want to look at ---all the best of the Fall and Winter fashions!
  • By manfaat madu asli - 10:26 AM on Apr 27, 2013   Reply
    what a great post, thx for the share
  • By bestwebsdesigns - 12:34 PM on Apr 27, 2013   Reply
    A very comprehensive article that shed some light on this very strange subject. Thank you for a new type of writing for me.
  • By nj photo booth - 4:53 PM on Apr 27, 2013   Reply
    Thanks for keeping us informed
  • By wedding photography nj - 5:39 PM on Apr 27, 2013   Reply
    Its great to see you taking the time to share this information
  • By realestatebestlawyer - 9:49 AM on Apr 30, 2013   Reply
    It’s hard to tell with these Internet startups if they’re really interested in building companies or if they’re just interested in the money. I can tell you, though:
  • By seo tips and tricks - 10:13 PM on May 04, 2013   Reply
    We have all the best and newest styles of Epi Leather Handbags that you want to look at ---all the best of the Fall and Winter fashions!..<a href="http://simsmoneysolution.com/seo-tips-and-tricks">seo tips and tricks</a>
  • By e-papierosy - 9:56 AM on May 06, 2013   Reply
    We start by using the Text & Image component in a content page and specify a value for the Text and drop an image in the component.
  • By Free mp3 download - 1:30 PM on May 07, 2013   Reply
    Thanks for sharing this great article! I am always searching for informative information like this!
  • By พระเครื่อง - 6:43 PM on May 07, 2013   Reply
    Thanks for sharing this great article! I am always searching for informative information like this!
  • By ultherapy pittsburgh pa - 6:28 PM on May 10, 2013   Reply
    It’s hard to tell with these Internet startups if they’re really interested in building companies or if they’re just interested in the money. I can tell you, though
  • By ultherapy pittsburgh pa - 8:32 PM on May 10, 2013   Reply
    It’s hard to tell with these Internet startups if they’re really interested in building companies or if they’re just interested in the money. I can tell you, though
  • By additional resource - 9:20 PM on May 11, 2013   Reply
    Thank you for the efforts you been putting on making your site such an interesting and informative place to browse through. I'll be visiting your site again to gather some more valuable information. You truly did a good job...
  • By Prescott AZ - 9:38 PM on May 11, 2013   Reply
    A very comprehensive article that shed some light on this very strange subject. Thank you for a new type of writing for me.
  • By Chambres d'hotes cassis - 5:04 AM on May 14, 2013   Reply
    I do not also find out the way I finished up here, having said that I believed this created was terrific. I do not realize that you are actually but definitely you are actually heading to a renowned blog writer in the event you aren't presently. Thanks! And also check this: <a href="http://www.financeutile.com">financement participatif</a> and <a href="http://mathsmalin.fr/exercices10/6,aires-et-perimetres.html">exercices aires et périmètres 6eme</a>.
  • By yourglamor - 3:52 PM on May 16, 2013   Reply
    Being in this blog has ended up absolutely stimulated to read through them. Unquestionably been having more things opened. You have given more than visitors expectancy. This post is very helpful, edifying and in addition cool thoughts
  • By bamboo flooring - 7:14 PM on May 16, 2013   Reply
    This blog contains so many interesting stuff that makes me want to visit again, Must say that the post you've written is greatly benefit from each other. It's very valuable to read further on this issue
  • By dentists methuen ma - 10:07 PM on May 16, 2013   Reply
    Thanks for sharing this great article! I am always searching for informative information like this!
  • By tas ransel - 5:13 AM on May 17, 2013   Reply
    You blog has such an awesome design. I enjoy what you are usually up too. This sort of clever work of writing and coverage is a wonderful work indeed, must say you've done a very good job
  • By driversedguy.tumblr.com - 9:56 AM on May 17, 2013   Reply
    We start by using the Text & Image component in a content page and specify a value for the Text and drop an image in the component.
  • By http://wpblackhat.com/wpblog/ - 9:50 PM on May 17, 2013   Reply
    Thank you for the efforts you been putting on making your site such an interesting and informative place to browse through. I'll be visiting your site again to gather some more valuable information.
  • By plagiarism check - 10:34 PM on May 17, 2013   Reply
    Thanks for taking this opportunity to discuss this, I appreciate with this and if you have some more information please share it with me.
  • By elektronik sigara - 8:35 PM on May 18, 2013   Reply
    A very comprehensive article that shed some light on this very strange subject. Thank you for a new type of writing for me.
  • By Cobra Seats - 7:02 AM on May 19, 2013   Reply
    Your good knowledge and kindness in playing with all the pieces is very useful. This has been one outstanding blog to visit. The second one, I must say this blog loads a lot quicker then most
  • By קטעי קריאה באנגלית - 8:12 AM on May 19, 2013   Reply
    This blog contains so many interesting stuff that makes me want to visit again, Must say that the post you've written is greatly benefit from each other. It's very valuable to read further on this issue
  • By http://www.inmo.co.uk - 8:41 AM on May 19, 2013   Reply
    it's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information.
  • By lovetoattract - 9:20 AM on May 19, 2013   Reply
    Your good knowledge and kindness in playing with all the pieces is very useful. This has been one outstanding blog to visit. Id really love to stay around this website and be a part of where I can get a lot of valuable and beneficial advice
  • By things to do in Las Vegas - 11:46 AM on May 19, 2013   Reply
    In this post I will take the Text & Image component and will make the following changes when you drag this component onto your page:
  • By Abdelaziz Mohammed - 2:00 PM on May 19, 2013   Reply
    dont know at first that it will be a useful information, but really, thank you for posting it
  • By kurye - 8:05 PM on May 19, 2013   Reply
    Being a work from home mom will normally demand much more than either "job" would on its own. Being a mother is difficult. Being an entrepreneur is difficult. Mix the two and disaster often results.
  • By Umbrella company - 4:55 PM on May 20, 2013   Reply
    This post you have made here couldnt be written any better! Fairly certain this article will have a good read. Thanks for such post and please keep it up. You blog providing a lot of essential posts
  • By מורה פרטי לפסיכומטרי - 8:58 PM on May 20, 2013   Reply
    We start by using the Text & Image component in a content page and specify a value for the Text and drop an image in the component.
  • By ללמוד אנגלית באינטרנט - 10:17 PM on May 20, 2013   Reply
    This is great. Does this work for page components too? I want to prepopulate a new page with components, and then give those components defaults.
  • By how to get motivation - 11:09 PM on May 20, 2013   Reply
    In this post I will take the Text & Image component and will make the following changes when you drag this component onto your page: