ArticleDirectory
- 1. Create a datatype named backgroundcolor.
- 2. select color picker as its render control and select nvarchar as its database datatype.
- 3. Add the pre-defined colors
- 4. Add the color to generic properties in the textpage document type.
- 5. Set the color in the content Properties tab
- 6. Apply the color in the template
- 7. See the effect.
Demo
Allow the end user has ability to change the background color with pre-defined color.
Steps1. create a datatype named backgroundcolor.
2. select color picker as its render control and select nvarchar as its database datatype.
3. Add the pre-defined colors
You can add any number of colors as you wish.
4. Add the color to generic properties in the textpage document type.
It is reasonable to place content background color in the generic Properties tab as it controls the content's background color.
5. Set the color in the content Properties tab
After 1-4 steps are carried out, the content background color comes up to you when you select the Properties tab in content page which take textpage as its template. select one of color as your background color here.
6. Apply the color in the template
The Code finally looks like the following.
<Div class = "entry" style = "background-color: # <umbraco: item field =" contentbackgroundcolor "runat =" server "/>">
<Umbraco: item runat = "server" field = "bodytext"> </umbraco: item>
</Div>
7. See the effect.
More knowledge
Umbraco datatypes are created based on the control either shipped with umbraco or self-developed implementing idatatype interface. you can create you specific ype with specific pre-defined values in different context in your umbraco site. for example, you can create background color 1 and background color 2 based on color picker to control colors in different areas in the template. have fun here.
The source code is available at novaumbracodemo in codeplex.
Supported by Nova umbraco