Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 04, 2012 @ 15:59
    Marc-Anthony Taylor
    0

    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?

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Dec 07, 2012 @ 12:45
    Tim
    0

    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!

  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 07, 2012 @ 13:30
    Marc-Anthony Taylor
    0

    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?

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Dec 07, 2012 @ 14:01
    Tim
    0

    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?

  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 07, 2012 @ 14:04
    Marc-Anthony Taylor
    0

    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.

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Dec 07, 2012 @ 15:07
    Tim
    0

    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).

  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 07, 2012 @ 15:22
    Marc-Anthony Taylor
    0

    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?

  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 13, 2012 @ 10:06
    Marc-Anthony Taylor
    0

    I am still unsure how to use the modal windo. If anyone can give me a pointer or 2 it would be great!

  • Marc-Anthony Taylor 55 posts 68 karma points
    Dec 13, 2012 @ 10:27
    Marc-Anthony Taylor
    0

    Is there any way to add to/augment the existing create.aspx to do what I want?

Please Sign in or register to post replies

Write your reply to:

Draft