2
votes

I want to create template so the user can create "alerts" by entering data including a description. To facilitate this, there will be 7 templates to choose the description from. The user can then change this description text...

I've created another template for these "alert descriptions" and created 7 items based on this template.

Now, what field types do I use on my alert template? I have a a field called description with a type of drop down list with the source mapping to the alert descriptions but this just gives me a value for the drop down. What I want is the user to select an alert description from the drop down and this will prefill another field which can be edited to make the final text. But how?

4

4 Answers

1
votes

You can't do this with any existing field type, as @TwentyGotoTen says. Alternatives to custom field:

Set default text in the __Standard Values of 7 different templates and have the content editors create the item from the insert menu. These could all inherit from the same alert base template. So when the different types of items are create they get default text for that type of alert. The user would be able to change the template type and reset the value of the message field to default if needed.

Or you could possibly use Snippets in the rich text field.

Downside to both these is the text is set in the template for templates and in core db for snippets and you really don't want to give your editors access to these if they need to make changes to the default text. It's going to depend on how often you think this text is likely to change vs the amount of work required for a custom field.

You could get around the issue of setting the standard values in templates by adding your own custom token and having the token value set in an editor accessible tree location.

0
votes

As TwentyGotoTen stated, you can't achieve exactly what you are asking for out of the box. Creating a custom field is definitely a good option. However, there are a couple of other things you could do to get a similar end result.

  1. Use Item Clones. You can make your alert descriptions and your actual alerts use the same template. Then, instead of having your users insert new items, have them clone one of your sample alerts. Then they can edit the description.

  2. Use the Field Fallback Module and create a custom FieldFallbackProcessor. This processor could look at your droplink field to determine which item to pull the fallback value from.

  3. Create a Command Template. Your command template could present the user with a dialog that allows them to select the alert description that they would like to start with and prefill the newly created item with it. See the Data Definition Cookbook on SDN for more info on command templates. Note that this could end up being more effort than the custom field.

0
votes

Why not use the Rules Engine?

I'm not entirely clear on where the alert needs to be displayed - inside Sitecore or to the visitor of the website, but it could be done in either case:

Inside Sitecore
You could use Sitecore's default (at least in Sitecore 6.5 it's an out-of-the-box Action) Set Content Editor Warning if some Conditions are true (i.e. it's of a specific template, in a specific location of the content tree, etc.). For the warning to show up you'll have to create a Rule in the /sitecore/system/Settings/Rules/Content Editor Warnings/Rules folder

To the visitor of the website
What you could do here is again run some Conditions - there is also an always run type of condition if you want to do this on every page - and Sitecore also has some actions available here: For instance, you could use the default Set datasource to item (the item being where you've saved your warning description) or 'Set parameters to value' - more on using Sitecore parameters here

You could even create your own custom Action or Condition so you could, for instance, add a new Sublayout or Rendering to a placeholder which will display something.

Of course, with setting the datasource to an item it will always take the text in that item - if you edit the original description it'll overwrite the old one, possibly affecting all other items using that description. Using the parameters will not have that issue, but you'll not be able to re-use text like that, so if you are using it in multiple locations it's not possible to apply one change everywhere.

Content Editors will be able to change the text fairly easily using the Page Editor (especially when using something like setting datasource to item or having a custom field)