I guess you need to add a function to the menu item? Here's an example of one that I wrote ages ago that calls one of the built in JS functions (to open an Umbraco modal window):
public class TweetMenuAction : IAction
{
private static readonly TweetMenuAction instance = new TweetMenuAction();
private TweetMenuAction() { }
public static TweetMenuAction Instance
{
get { return instance; }
}
private string _alias = "TweetMenu";
public string Alias
{
get { return _alias; }
}
public bool CanBePermissionAssigned
{
get { return false; }
}
public string Icon
{
get { return "plugins/tweetmenu/images/twitter.png"; }
}
public string JsFunctionName
{
get
{
return "openModal('plugins/tweetmenu/dialog/tweetpage.aspx?id=' + nodeID, 'Share This Page On Twitter', 540, 620);";
}
}
public string JsSource
{
get { return string.Empty; }
}
public char Letter
{
get { return '^'; }
}
public bool ShowInNotifier
{
get { return false; }
}
}
This is quite old, so the API might have changed, but it should give you the idea. You could use your own function (as long as it's registered to the page). I can't find an example of that to hand, but you can do that by overriding the tree render method to inject the script, you can see an example in this umbraco.tv video. Hopefully that hasn't changed in the newer versions of Umbraco!
Thank you very much for the answer. I actually posted the question again with my code (couldn't edit this question), my code is fairly similar to yours. I have watched the video but the API does seem to have changed a bit.
I am completely new to asp.net, but from what I can see in your code I have to make a new aspx page that will send the parameter to my class. Is that correct?
Yes, you'll need to make the action pass through to a page of some kind to get the value (although you could also pass the value to an AJAX style remote call if you wanted, depending on what you're after doing. What action do you want the menu item to do?
I am developing a multilingual site and I have created a class that will replicate created content to all 'language' nodes (en, fr...). At the moment it does this automatically but I would like to give the content creator the choice. A simple yes/no answer that I would pass back to the class to allow/prevent the event from firing.
Cool! Yeah, you could create a page that can be opened using the modal window function in my example, and then have the page give the option and then do the copy in the modal code (rather than as an event). If you wanted to get fancy, you could even list all the other languages in the modal popup and let them choose which ones to create (if they only wanted the content in some of the sites for example).
Return value from custom context item
I can't work out how to get the value of a javascript confirm box fired by my custom context menu item. Any ideas?
I guess you need to add a function to the menu item? Here's an example of one that I wrote ages ago that calls one of the built in JS functions (to open an Umbraco modal window):
This is quite old, so the API might have changed, but it should give you the idea. You could use your own function (as long as it's registered to the page). I can't find an example of that to hand, but you can do that by overriding the tree render method to inject the script, you can see an example in this umbraco.tv video. Hopefully that hasn't changed in the newer versions of Umbraco!
Thank you very much for the answer. I actually posted the question again with my code (couldn't edit this question), my code is fairly similar to yours. I have watched the video but the API does seem to have changed a bit.
I am completely new to asp.net, but from what I can see in your code I have to make a new aspx page that will send the parameter to my class. Is that correct?
Yes, you'll need to make the action pass through to a page of some kind to get the value (although you could also pass the value to an AJAX style remote call if you wanted, depending on what you're after doing. What action do you want the menu item to do?
I am developing a multilingual site and I have created a class that will replicate created content to all 'language' nodes (en, fr...). At the moment it does this automatically but I would like to give the content creator the choice. A simple yes/no answer that I would pass back to the class to allow/prevent the event from firing.
Cool! Yeah, you could create a page that can be opened using the modal window function in my example, and then have the page give the option and then do the copy in the modal code (rather than as an event). If you wanted to get fancy, you could even list all the other languages in the modal popup and let them choose which ones to create (if they only wanted the content in some of the sites for example).
That sounds superb! Thank you very much. Do you know where would be a good place to learn how to work with the modal code?
I am still unsure how to use the modal windo. If anyone can give me a pointer or 2 it would be great!
Is there any way to add to/augment the existing create.aspx to do what I want?
is working on a reply...