Reputation: 338
I have a custom content type create in visual studio 2010:
custom http://img204.imageshack.us/img204/439/customf.jpg
Here you have my custom content type.... I would like to use this content type in a sub-site in the same site. Now I have this:
http // XXXXX/........../Forms/AllItems.aspx
I would like to use this content type in
http //XXXXX/SUBSITE...../Forms/AllItems.aspx...
In the code I associated my custom content type to the first document library like this:
<CustomAction
Id="SPTest.CustomMenuItem.ButtonClicked"
Location="CommandUI.Ribbon.ListView"
RegistrationId="{F9658A9F-3F04-48BD-A14A-9EBAF5DE9EE8}"
RegistrationType="List"
>
Where RegistrationId is the Id of document's library site, but when I put in this RegistrationId the Id of the subsite document library... nothing happens...
Another Question: When I selected an item in this document library, Documents tab will be show.... IS there some way to display PATOne Rule Engine instead of documents tab???
Upvotes: 0
Views: 1138
Reputation: 917
That is a "Custom Action", not a "Custom Content Type". Hint: the Content Type will contain a 'ContentType' element. It will look something like:
<ContentType ID="0x01AB"
Name="MyCustomContentType"
Group="MyCustomContentTypeGroup"
Description="Customized Content Type"
Version="0">
<FieldRefs>
<FieldRef ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}"
Name="Created"
DisplayName="Field1" />
<FieldRef ID="{1df5e554-ec7e-46a6-901d-d85a3881cb18}"
Name="Author"
DisplayName="Field2" />
</FieldRefs>
</ContentType>
Further, the RegistrationId should not be a guid if it is to be registered against a content type. If Registered against a list, the RegistrationId should either be the list's type ID e.g. (101 for document libraries in the site), or possibly the GUID of a specific list (in which case the action will only work for that list). I've not tried this last one, but suspect it'd work. (Edit: It is described as working this way at the bottom of this discussion)
Depending on what the guid is, you may have registered the custom action for a specific list, but the list in your subsite will have a different ID, so that custom action registration will not apply to it.
In short, you can add custom actions to:
To register against a content type, I would expect the registration to look like:
<CustomAction
Id="SPTest.CustomMenuItem.ButtonClicked"
Location="CommandUI.Ribbon.ListView"
RegistrationType="ContentType"
RegistrationId="0x01AB"
Note the RegistrationType and RegistrationId
Upvotes: 1
Reputation: 338
This is my content type
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="SPTest.CustomMenuItem.ButtonClicked"
Location="CommandUI.Ribbon.ListView"
RegistrationId="{F9658A9F-3F04-48BD-A14A-9EBAF5DE9EE8}"
RegistrationType="List"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Tabs._children">
<Tab
Id="Ribbon.PATOneRule"
Title="PATOne Rule Engine"
Sequence="501">
<Scaling
Id="Ribbon.PATOneRule.Scaling">
<MaxSize
Id="Ribbon.PATOneRule.MaxSize"
GroupId="Ribbon.PATOneRule.PATOneRuleGroup"
Size="OneLargeTwoMedium"/>
<Scale
Id="Ribbon.PATOneRule.Scaling.PATOneRuleScaling"
GroupId="Ribbon.PATOneRule.PATOneRuleGroup"
Size="OneLargeTwoMedium" />
</Scaling>
<Groups Id="Ribbon.PATOneRule.Groups">
<Group
Id="Ribbon.PATOneRule.PATOneRuleGroup"
Description="Workflow Rules"
Title="Workflow Group"
Sequence="52"
Template="Ribbon.Templates.CustomTemplateExample">
<Controls Id="Ribbon.PATOneRule.PATOneRuleGroup.Controls">
<Button
Id="Ribbon.PATOneRule.PATOneRuleGroup.NewWorkflow"
Image32by32="/PublishingImages/_t/new_jpg.jpg"
Command="PATOneRule.NewWorkflow"
Sequence="15"
Description="Create New Workflow"
LabelText="New Workflow"
TemplateAlias="cust1"/>
<Button
Id="Ribbon.PATOneRule.PATOneRuleGroup.RunWorkflow"
Image32by32="/PublishingImages/_t/play_jpg.jpg"
Command="PATOneRule.RunWorkflow"
Sequence="15"
Description="Run Selected Workflow"
LabelText="Run Workflow"
TemplateAlias="cust2"/>
<Button
Id="Ribbon.PATOneRule.PATOneRuleGroup.EditWorkflow"
Image32by32="/PublishingImages/_t/edit_jpg.jpg"
Command="PATOneRule.EditWorkflow"
Sequence="15"
Description="Edit Selected Workflow"
LabelText="Edit Workflow"
TemplateAlias="cust3"/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">
<Layout
Title="OneLargeTwoMedium"
LayoutTitle="OneLargeTwoMedium">
<Section Alignment="Top" Type="OneRow">
<Row>
<ControlRef DisplayMode="Large" TemplateAlias="cust1" />
<ControlRef DisplayMode="Large" TemplateAlias="cust3" />
<ControlRef DisplayMode="Large" TemplateAlias="cust2" />
</Row>
</Section>
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="PATOneRule.NewWorkflow"
CommandAction="javascript:__doPostBack('NewWorkflow', '')" />
<CommandUIHandler
Command="PATOneRule.EditWorkflow"
CommandAction="javascript:
function getId() {
var ctx = SP.ClientContext.get_current();
var selectedItems = SP.ListOperation.Selection.getSelectedItems(ctx);
var key;
var itemsSelected;
for (key in selectedItems) {
itemsSelected = itemsSelected + ', ' + selectedItems[key].id;
}
__doPostBack('EditWorkflow',itemsSelected);
}
getId();"
EnabledScript="javascript:
function singleEnable() {
var items =
SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
return (ci == 1);
}
singleEnable();"
/>
<CommandUIHandler
Command="PATOneRule.RunWorkflow"
CommandAction="javascript:
function getId() {
var ctx = SP.ClientContext.get_current();
var selectedItems = SP.ListOperation.Selection.getSelectedItems(ctx);
var key;
var itemsSelected;
for (key in selectedItems) {
itemsSelected = itemsSelected + ', ' + selectedItems[key].id;
}
__doPostBack('RunWorkflow',itemsSelected);
}
getId();"
EnabledScript="javascript:
function singleEnable() {
var items =
SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
return (ci>0);
}
singleEnable();"
/>
</CommandUIHandlers>
</CommandUIExtension>
Upvotes: 0