我是 Sitecore 的新手。
在 Sitecore 中,我需要使用户能够基于现有项目创建新项目。我设想这样的事情:
- 用户在上下文菜单中单击“插入”,系统
- 会提示用户在树中的某个位置输入另一个项目(它必须基于特定模板)
- 创建一个新项目,其中一些字段预先填充了原始项目中的值
- 用户现在可以填写未预填充的其他字段 - 或更改预填充的值
(请注意,新项目基于除原始项目之外的另一个模板)。我不担心对原始项目的更改 - 它们不需要传播到新项目。
作为初学者,我不知道如何做到这一点。我研究了各种选择
:克隆人。克隆似乎很接近我想要的,但我不能在新项目上有额外的字段,并且它们不能基于不同的模板。所以我想它并不是我真正想要的克隆。 (而且,它们对 Sitecore 来说还很陌生)
b.事件。我认为我应该能够拦截“新项目”事件,但我不知道如何弹出一个对话框并要求用户选择一个原始项目。
c.参考原始项目。我已经弄清楚如何创建一个可以包含对原始项目的引用的字段。但是,当用户设置字段时如何填充字段 - 以及如何确保用户在执行其他操作之前从该字段开始?
我还研究了命令、钩子等等……
那么呢?有什么想法吗?
I am new to Sitecore.
In Sitecore I need to enable users to create new items based on existing items. I am envisioning something like this:
- the user clicks "insert" in the context menu
- the user is prompted for another item somewhere in the tree (it must be based on a specific template)
- A new item is created with some fields pre-populated with the values from the original item
- The user can now fill out other fields which are not pre-filled - or change the pre-populated values
(notice that the new item is based on another template than the original). I do not have worry about changes to the original item - they do not need to be propagated to the new item.
As a beginner I don't know how to do this. I have looked at various options:
a. Clones. Clones seemed to be close to what I want, but I can't have extra fields on the new item, and they can't be based on different templates. So I guess its not really a clone I am after. (also, they are pretty new to Sitecore)
b. events. I think I should be able to intercept the "new item" event, but I have no idea how I would then throw up a dialogbox and ask the user to select an original item.
c. Reference to original item. I have figured out how to create a field that can contain a reference to the original item. However, how do I populate fields when the user sets it - and how can I make sure the user starts with this field before doing anything else?
I have also looked into commands, hooks and more ...
So? Any ideas?
发布评论
评论(3)
这将是一项特别重要的任务,如果您是 Sitecore 新手,这可能会非常困难。
我建议考虑自定义客户端(这可以通过从内容编辑器编辑
Core
数据库以及在代码中实现一些内容来完成)如果您有权访问 Sitecore 开发者网络,这将有帮助:http://sdn.sitecore.net/Reference/Sitecore%206/Client%20Configuration%20Cookbook.aspx
这些文章可能会为您提供一些有关实施的其他想法:
第一篇文章可能是添加上下文菜单项的最佳选择。您可以通过执行以下操作在编译的代码中执行命令:
Commands.config
文件中,添加一个项目,例如Execute(CommandContext context)
CommandContext
将提供进行更改所需的大量必要信息(例如当前选定的项目)。希望这会让您走上正轨。祝你好运!
This would be a particularly significant undertaking and if you're new to Sitecore, it might be extremely difficult.
I would suggest looking into customizing the client (this can be accomplished by editing the
Core
database from the Content Editor as well as implementing some things in code)If you have access to the Sitecore Developer Network, this will be helpful: http://sdn.sitecore.net/Reference/Sitecore%206/Client%20Configuration%20Cookbook.aspx
These articles might give you some additional ideas about implementation:
The first article might be your best bet for adding a context menu item. You can execute commands in your compiled code by doing the following:
Commands.config
file, add an item such as<command name="button:copycreateditem" type="Your.Namespace.And.Classname,Your.Assembly" />
Execute(CommandContext context)
The
CommandContext
will provide a lot of the necessary information you'll need to make your changes (such as currently selected item).Hopefully this will put you on the right track. Good luck!
我不太明白你所说的“它必须基于特定模板”,然后“新项目基于除原始模板之外的另一个模板”。不确定如何才能同时拥有这两种方式,所以我的回答假设您坚持使用一个模板。
标准的 Sitecore 方法是在模板中分配标准值。然后,用户可以根据模板创建新项目,并且将出现标准值。
要为模板创建标准值,
这将在模板下创建一个新项目“__标准值”,您可以在其中设置某些字段的默认值,将其他人留空。
I don't really understand what you're saying with "it must be based on a specific template" and then later "the new item is based on another template than the original". Not sure how you can have it both ways, so my answer assumes that you're sticking with one template.
The standard sitecore way to do this is to assign standard values in templates. The user can then create a new item based on a template, and the standard values will come across.
To create standard values for a template,
This will create a new item "__Standard Values" under the template where you can setup default values for some fields and leave others blank.
插入选项、插入规则、nvelocity 标记($name)和模板标准值。
Insert options, insert rules, nvelocity tokens ($name), and template standard values.