Resource bundles
You can use Java-style .properties files to customize the content edit form for a given model.
See also:
The following procedure describes how to create a properties file for a given model.
- Change to or create the
resources/
directory for your Brightspot project. This directory is in the standard position for Maven projects,src/main/resources/
, although your Brightspot project may have a differentresources/
directory for different themes. - Change to or create the subdirectory corresponding to the required model. For example, if you are configuring the content edit form for a model
brightspot/core/article/Article.java
, change to or create the resources subdirectorybrightspot/core/article/
. - Create or open the file
Default_xx.properties
, wherexx
is the code of the target language. For example, the fileArticleDefault_en.properties
overrides the model associated with articles for English-language locales. For a list of two-letter language codes, see . - In the properties file, add lines of the form key=value. Use the following sections for a description of the available keys.
- Reload or rebuild your Brightspot project.
The properties key field renames a field on the content edit form.
- Following the procedure in Creating properties files, create or open open the appropriate .properties file.
- In the properties file, add a line of the form
field.<fieldname>=<newname>
.
Fields not appearing in this file have labels derived from their names in the model or as otherwise annotated.
The following snippet renames the field headline on the content edit form.
field.headline=Teaser Headline
![Renaming Resource Files.png](https://brightspot.brightspotcdn.com/dims4/default/683342c/2147483647/strip/true/crop/1236x192+0+0/resize/1236x192!/quality/90/?url=http%3A%2F%2Fbrightspot-brightspot.s3.amazonaws.com%2Fbsp%2F93%2F3e%2Ffd44b8c344369b0bf1c93f5c7a24%2Frenaming-resource-files.png)
![Renaming Resource Files.png](https://brightspot.brightspotcdn.com/dims4/default/7e6a807/2147483647/strip/true/crop/1236x192+0+0/resize/800x124!/quality/90/?url=http%3A%2F%2Fbrightspot-brightspot.s3.amazonaws.com%2Fbsp%2F93%2F3e%2Ffd44b8c344369b0bf1c93f5c7a24%2Frenaming-resource-files.png)
For additional information, see @Recordable.DisplayName.
The properties key displayName
renames a content type throughout the Brightspot UI.
- Following the procedure in Creating properties files, create or open open the appropriate .properties file.
- In the properties file, add a line of the form
displayName=NewLabel
. Do not enclose the label in quotes.
In the file resources/article/ArticleOverride.properties
, the following line displays Story
instead of Article
in Brightspot.
displayName=Story
For additional information, see @Recordable.DisplayName.
The properties key hidden prevents a content type from appearing in Brightspot.
- Following the procedure in Creating properties files, create or open open the appropriate .properties file.
- In the properties file, add a line
hidden=true
.
In the file resources/article/ArticleOverride.properties
, the following line prevents Article
from appearing in Brightspot.
hidden=true
For additional information, see @ToolUi.Hidden.
The properties key field.<fieldname>.hidden
hides <fieldname>
in the content edit form.
- Following the procedure in Creating properties files, create or open open the appropriate .properties file.
- In the properties file, add a line of the form
field.<fieldName>.hidden=true
.
The following snippet hides the Sub Headline
field in the content edit form.
field.subHeadline.hidden=true
![]() ![]() Content edit form with visible sub-headline
|
![]() ![]() Content edit form with hidden sub-headline
|
For additional information, see @ToolUi.Hidden.
The properties key fieldDisplayOrder
sets the display order of fields on the content edit form.
- Following the procedure in Creating properties files, create or open open the appropriate .properties file.
- In the properties file, add a line of the form
fieldDisplayOrder=fieldName [,fieldname ...]
.
Fields not appearing in this line appear in the order as in the model or as otherwise annotated.
The following snippet places the author field before the headline and body fields in the content edit form.
fieldDisplayOrder=author,headline,body
![Changing Field Order.png](https://brightspot.brightspotcdn.com/dims4/default/95dc033/2147483647/strip/true/crop/1320x704+0+0/resize/1320x704!/quality/90/?url=http%3A%2F%2Fbrightspot-brightspot.s3.amazonaws.com%2Fbsp%2Fe3%2F54%2F47d725534d0793df9e6d86f8b1a1%2Fchanging-field-order.png)
![Changing Field Order.png](https://brightspot.brightspotcdn.com/dims4/default/9c74ee8/2147483647/strip/true/crop/1320x704+0+0/resize/800x427!/quality/90/?url=http%3A%2F%2Fbrightspot-brightspot.s3.amazonaws.com%2Fbsp%2Fe3%2F54%2F47d725534d0793df9e6d86f8b1a1%2Fchanging-field-order.png)
For additional information, see @ToolUi.FieldDisplayOrder.
A Multipurpose Internet Mail Extensions (MIME) type is a standard description of a file based on its extension. Brightspot comes with the standard list of MIME types, and you can use the method ObjectUtils#getContentType
to retrieve it.
import com.psddev.cms.db.Content;
import com.psddev.dari.util.StorageItem;
public class Article extends Content {
private StorageItem image;
public String getImage() {
return image.getPublicUrl();
}
public void setImage(StorageItem image) {
this.image = image;
}
}
In the previous snippet, the method getImage()
returns the path, such as /storage/1f/asteroid.jpg
, to the stored image. You can use the path to look up the MIME type.
import com.psddev.cms.view.ViewModel;
import com.psddev.cms.view.PageEntryView;
import com.psddev.dari.util.ObjectUtils;
import com.psddev.styleguide.content.article.ArticleView;
public class ArticleViewModel extends ViewModel<Article> implements ArticleView, PageEntryView {
/* Overridden interface methods */
private String getMimeType() {
String path = model.getImage();
return ObjectUtils.getContentType(path);
}
}
-
Retrieves the current image’s path from the model.
-
Looks up the MIME type from a global file containing the . If you upload a file whose extension does not appear in that list, the method
getContentType
returns the stringapplication/octet-stream
.
You can add additional MIME types to your Brightspot project, and you can override the string returned for an existing MIME type.
- In your Brightspot project, create a file
com/psddev/dari/util/mime.types
file in aresources/
directory following the package structure of the source file that looks up MIME types. For example, if you have a Java file/src/main/java/content/article/ArticleViewModel.java
, create a filesrc/main/resources/com/psddev/dari/util/mime.types
. - Copy the file into the new file
mime.types
from step 1. - Modify and add MIME types as required.
- Rebuild your Brightspot project.
#image/jpeg jpeg jpg jpe
image/jpg jpeg jpg jpe
image/xcf xcf
-
Returns the string image/jpg for file extensions jpeg, jpg, and jpe, overriding the standard image/jpeg.
-
Returns the string image/xcf for the file extension xcf (associated with the GIMP image editor).
See also: