10

I need to create a schema with these fields:

1. Title(text type)
2. Image(multimedia type)
2. Color (Red, Blue, Yellow and Green only) 

To enable an author to choose any color(background/bgcolor) for components created using this schema and color should be visible like in Paint while creating/editing the component.

Do I need to create a utility or is there some out-of-the-box functionality?

4
  • I changed the title of your question slightly. If my edits are incorrect feel free to revert them. Just to confirm on your question, do you want the title to show in the component form using the color chosen? Or do you want to display a swatch on the component form showing the color selected in the color picker? Apr 27, 2013 at 23:12
  • I removed the tag core-service because I didn't see any relevance to that (unless @Manoj meant he needed to create this Schema through the Core Service, in that case the question should be updated) Apr 29, 2013 at 7:40
  • i just need to access that color code so that i can use that in tbb as a background color, text color etc. May 8, 2013 at 19:43
  • 1
    I made an example Custom Url color picker based on Spectrum Color Picker. Again, I would only recommend this for configuration-type use cases (not in editorial content). Jun 10, 2014 at 7:28

2 Answers 2

11

I would first say selecting a color for text is not a very common use case and most organizations prefer to set the style and color using CSS stylesheets to provide a consistent look and feel for the website.

However, I understand your requirement and will provide 3 options:

  1. The Rich Text field has an option to set a color or a CSS class on text.

  2. You could also use a Category called colors and then add color keywords. But, the colors would not be visible.

  3. The last option and probably what you are looking for is a way to pick a color and have that value saved as text field or keyword. The 'color picker' would need to be created and probably best to use a Custom URL to open a popup window where a user would select a color. You could stil use keywords for the color and perhaps put the color hex code in the description of the keyword. On selecting a color the keyword title would be saved into the text field or possibly keyword field. The Tridion Live Documentation has information about creating custom URLs and passing the values back to the field.

2
  • 3
    I like showing user-friendly terms to authors; ideally they'd be independent of site design with terms like high-contrast, light, dark, etc. Regardless of approach, if possible, I'd suggest using a keyword's Key over Description. The Key field isn't localizable and acts as a "identifier" across publications. Apr 28, 2013 at 17:36
  • 1
    Probably the simplest, well structured option here is option 2. I would also add to Robert and Alvin's comments regarding requiring an editor to choose a colour in the CMS. Colour is design, not content, and this is akin to putting bgcolor or similar in your HTML. You want a clean separation between your content and your style. Like Alvin suggests, try to have your users select a purpose in the CMS, and translate that to a colour in your templating/css. This allows you to re-purpose your content and/or change design much easier in the future. Apr 29, 2013 at 8:37
4

The safest option is always to head for out of the box but from your question the use case isn't quite clear.

If you simply require a list to be presented to an editor with no context of color etc. - i..e 'just a list' then select the option in the schema field when creating it 'Values will be Selected from a List'.

You can then select whether you want to use a Category/Keyword construct to manage the list or you can add a specific 'Pick list' within the schema field itself. Note that immediately after this you have the option of selecting the method for the user to select (Drop down list, Radio buttons etc.).

The option to specify the list directly in the schema also applies to Robs comment (2) above.

If this is for use in a Rich Text Field then you will need to add more detail into the question above regards the expectations for the user and for the management of future updates/additions etc.

3
  • this could be the solution but using categories and keywords doen't show color picker box where an author can see the actual colors. May 8, 2013 at 19:48
  • When you say the actual colours do you mean when applied - in which case I assume you mean in a rich text field then? = probably apply a class. Or as selecting = probably require an extension. Our, as Robert points out above there ids a color selector. Your requirement is not clear. May 9, 2013 at 0:58
  • i need to show a color picker like in paint. so that when author click/select any color from that picker , the background (bgcolor) of the component should change as per the selection. May 10, 2013 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.