public class SiteMappingAction : IAction { public string Alias { get { return "SiteMemberGroupMapping"; } } public bool CanBePermissionAssigned { get { return true; } } public string Icon { get { return string.Empty; } } public string JsFunctionName { get { return "alert('Hello');"; } } public string JsSource { get { return string.Empty; } } public char Letter { get { return 'S'; } } public bool ShowInNotifier { get { return false; } } }
After I compile the above code and place it in my Umbraco site; when I navigate to the Umraco admin area, all of the content is blank - the left hand navigation, the sections area, the right side content, they are all empty. Other UI items such as the help button and search are still appear.
Now when I remove my custom tree event class from the site, and refresh the page, then all the content appears without fail.
My question is : I must be doing something wrong in either the TreeEvent or SiteMappingAction classes, but I don't know what it could be.
Thanks for your reply. I've made changes to my action class like so:
public class SiteMappingAction : IAction
{
#pragma warning disable 612,618
private static readonly SiteMappingAction instance = new SiteMappingAction();
#pragma warning restore 612,618
[Obsolete("Use the singleton instantiation instead of a constructor")]
public SiteMappingAction()
{
}
public static SiteMappingAction Instance
{
get
{
return instance;
}
}
public string Alias
{
get
{
return "Site Mappings";
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public string Icon
{
get
{
return string.Empty;
}
}
public string JsFunctionName
{
get
{
return "Testing()";
}
}
public string JsSource
{
get
{
return "function Testing() { alert('hello') };";
}
}
public char Letter
{
get
{
return 'S';
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
}
Now when I navigate to Umbraco, and right-click on the target tree node, instead of my action item appearing in the context menu, a new item named "Sort" appears?!?!? Very weird. It says the word "Sort" and has an icon.
My action class does not mention sort, nor does it mention that icon, so I've no idea why Umbraco is showing this item.
I've tried various other characters via the ALT+ random number technique, but I still get the same result : when I right-click now, my context menu item does not appear, but at least the "Sort" item has also vanished now.
It looks like the Alias property was at fault. I change it from returning "Site Mappings" to "siteMappings" and (after adding a new row in umbracoAppTree) my custom menu item does appear.
I do have a new issue regarding the text that appears in the menu item (it says [siteMappings] rather then "Site Mappings", but that's a different issue.
Awesome, glad you fixed it! The [siteMappings] issue is because you need to add a key to the language file with the actual text you want to use. Check /umbraco/config/lang/en.xml and add a new key for siteMappings.
Have added tree event class, now Umbraco UI is empty!
Hi there.
I've followed the instructions for creating custom context menu items in this video: http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/events/add-items-to-the-context-menu
Here is my code:
After I compile the above code and place it in my Umbraco site; when I navigate to the Umraco admin area, all of the content is blank - the left hand navigation, the sections area, the right side content, they are all empty. Other UI items such as the help button and search are still appear.
Now when I remove my custom tree event class from the site, and refresh the page, then all the content appears without fail.
My question is : I must be doing something wrong in either the TreeEvent or SiteMappingAction classes, but I don't know what it could be.
Can someone help please?
Hi Jason,
The video has some outdated code that breaks post-4.5. Here's the fix: http://our.umbraco.org/forum/developers/extending-umbraco/15025-Content-Tree-Will-Not-render-after-creating-new-Context-Menu-Item
Hope this helps,
Tom
Hi Tom.
Thanks for your reply. I've made changes to my action class like so:
public class SiteMappingAction : IAction
{
#pragma warning disable 612,618
private static readonly SiteMappingAction instance = new SiteMappingAction();
#pragma warning restore 612,618
[Obsolete("Use the singleton instantiation instead of a constructor")]
public SiteMappingAction()
{
}
public static SiteMappingAction Instance
{
get
{
return instance;
}
}
public string Alias
{
get
{
return "Site Mappings";
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public string Icon
{
get
{
return string.Empty;
}
}
public string JsFunctionName
{
get
{
return "Testing()";
}
}
public string JsSource
{
get
{
return "function Testing() { alert('hello') };";
}
}
public char Letter
{
get
{
return 'S';
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
}
Now when I navigate to Umbraco, and right-click on the target tree node, instead of my action item appearing in the context menu, a new item named "Sort" appears?!?!? Very weird. It says the word "Sort" and has an icon.
My action class does not mention sort, nor does it mention that icon, so I've no idea why Umbraco is showing this item.
Can you assist me with this please?
Hi,
Just a wild guess, the Letter property of your menu item needs to be unique. Maybe the Sort action is already using that.
Usually what I do to pick a letter is push ALT+(random chars on numpad), for ex ALT+4578 gives you Γ - and hope noone else is using that :)
-Tom
Hi Tom.
I gave that a shot by changing letter to:
public char Letter
{
get
{
return 'Ô';
}
}
I've tried various other characters via the ALT+ random number technique, but I still get the same result : when I right-click now, my context menu item does not appear, but at least the "Sort" item has also vanished now.
Still stuck on how to get my item to appear.
Hi there.
It looks like the Alias property was at fault. I change it from returning "Site Mappings" to "siteMappings" and (after adding a new row in umbracoAppTree) my custom menu item does appear.
I do have a new issue regarding the text that appears in the menu item (it says [siteMappings] rather then "Site Mappings", but that's a different issue.
Thanks for your help with this.
Awesome, glad you fixed it! The [siteMappings] issue is because you need to add a key to the language file with the actual text you want to use. Check /umbraco/config/lang/en.xml and add a new key for siteMappings.
is working on a reply...