Adding Unpublish action to context menu in Umbraco 4.1
When trying to add the unpublish action to the context menu for content nodes using this code:
public OnContentTreeBeforeNodeRender() { BaseContentTree.BeforeNodeRender += new BaseTree.BeforeNodeRenderEventHandler(BaseContentTree_BeforeNodeRender); }
@Richard: you'd override the CreateRootNodeActions() or CreateAllowedActions() method, or if you wish to specify specific actions on specific content nodes, you'd override the Render() method...
@Stephan: bit puzzled as the unpublish action should be included by default? (for published content nodes that is)...
@slace, @Stephan: I'd still prefer Stephan's method in case you'd like to add the unpublish action for (a) specific node(s)
@Dirk, where can you configure that (for the existing umbraco config tree)? I think you can't besides hacking the database and register the correct type?
@Dirk The UnPublish Action isn't available in the context menu, and there's no JS-method for it in the AppActions registered, this is probably du to the fact that it's implemented with a postback button on the editpage. Dunno if this is by design, or just not implemented.
Adding Unpublish action to context menu in Umbraco 4.1
When trying to add the unpublish action to the context menu for content nodes using this code:
public OnContentTreeBeforeNodeRender()
{
BaseContentTree.BeforeNodeRender += new BaseTree.BeforeNodeRenderEventHandler(BaseContentTree_BeforeNodeRender);
}
void BaseContentTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
{
if (node.NodeType.Equals("content", StringComparison.InvariantCultureIgnoreCase))
{
try
{
if (node.Menu != null)
{
int index = node.Menu.FindIndex(a => a.Alias.Equals("publish", StringComparison.InvariantCultureIgnoreCase)) + 1;
node.Menu.Insert(index, ActionUnPublish.Instance);
}
}
catch (Exception ex)
{
Log.Add(LogTypes.Error, int.Parse(node.NodeID), ex.ToString());
}
}
}
The event is triggered, and when stepping through code, the action is even added to the context menu. However, no item appears in the menu.
Any ideas?
it'd be easier to just overload the content tree and add it that way. In fact I think it's the recommended way to modify the tree
@slace You got any examples or pointers on where I can find some?
@slace, this example is adding an item to the existing Umbraco content tree, how can you overload that?
@Richard: you'd override the CreateRootNodeActions() or CreateAllowedActions() method, or if you wish to specify specific actions on specific content nodes, you'd override the Render() method...
@Stephan: bit puzzled as the unpublish action should be included by default? (for published content nodes that is)...
@slace, @Stephan: I'd still prefer Stephan's method in case you'd like to add the unpublish action for (a) specific node(s)
Cheers,
/Dirk
Actually, it's Richard's method :)
Oh, and doing like it said here, http://our.umbraco.org/wiki/reference/backoffice-apis/tree-api---to-create-custom-treesapplications, only results in a non-working content tree.
When using the BeforeNodeRenderEventHandler results in javascript errors, when the JsFunctionName property is set to anything but an empty string.
@Dirk, where can you configure that (for the existing umbraco config tree)? I think you can't besides hacking the database and register the correct type?
@Dirk The UnPublish Action isn't available in the context menu, and there's no JS-method for it in the AppActions registered, this is probably du to the fact that it's implemented with a postback button on the editpage. Dunno if this is by design, or just not implemented.
is working on a reply...