Copied to clipboard

Flag this post as spam?

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


  • Dirk De Grave 4532 posts 5976 karma points MVP 3x admin
    Jun 30, 2010 @ 13:38
    Dirk De Grave
    0

    Custom action icons in context menu not showing up

    using umbraco v4.5

    Checking a package for 4.5 compatibility seems to be working out pretty nice, just have a minor issue: I've created a custom action implementing IAction, setting Icon property as in:

    public string Icon{
      get { return "umbraco/memberGroup.gif"; }
    }

    yet don't see the icon in the context menu? Has that syntax changed?

    I did try

    public string Icon{
      get { return "/umbraco/images/umbraco/memberGroup.gif"; }
    }

    but that doesn't do the trick either? Anyone knows how to set the path to the icon or am I taking the wrong approach now?

    First code snippet works fine in 4.0.3 version, but won't in 4.5

    Cheers,

    /Dirk

  • Shannon Deminick 1473 posts 4939 karma points hq
    Jun 30, 2010 @ 13:47
    Shannon Deminick
    0

    Can't remember off the top of my head but your best bet would be to use Charles or Fiddler and see where the request is going. Perhaps just try memberGroup.gif ?

    Sorry don't have source code with me at the moment so can't check :(

  • Søren Linaa 243 posts 166 karma points
    Jul 09, 2010 @ 15:34
    Søren Linaa
    0

    Hi Dirk.

    Did you find a solution to this problem ?

    I'm also strugling with a context menu icon that will not show up in Umbraco v4.5.

     

    /Søren Linaa

  • Morten Christensen 594 posts 2747 karma points admin hq c-trib
    Jul 16, 2010 @ 21:56
    Morten Christensen
    2

    I couldn't help but look into this, as I also use custom actions in my packages but usally try to use existing icons for the contextmenu.

    Looking at the source code for actions its the same as previous (taken from umbraco.BusinessLogic.Actions.Action);

    string icon = action.Icon;
    if (!string.IsNullOrEmpty(icon) && icon.StartsWith("."))
    icon = icon.Substring(1, icon.Length - 1);
    else
    icon = "images/" + icon;

    So this means that if the value of your string isn't a css class starting with a dot (everything in the backend is sprites by default) it'll use the images/ + what-ever-you-wrote to create the path to your image. BUT this doesn't work as you stated -> wwwroot/umbraco/images/umbraco/memberGroup.gif is a valid path, so I'm pretty sure someone forgot that package developers might want to use their own icons and not necessary sprites.

    Dirk, you can help verify this if you look at the html source for your 4.5 contextmenu.
    Search for an ul with id="jstree-contextmenu"
    Your menuitem is a list item like:

    <li>
    <a href="#" rel="0" class="0 ">
    <ins>&nbsp;</ins>
    <span>
    <div class="menuSpr sprNew"></div>
    <div class="menuLabel">Create</div></span>
    </a>
    </li>

    If the first div class looks like the following then my theory is correct :-)

    <div class="menuSpr images/umbraco/memberGroup.gif"></div>

     

    - Morten

  • Matt Brailsford 2149 posts 10593 karma points MVP 6x c-trib
    Jul 16, 2010 @ 22:09
    Matt Brailsford
    0

    This is the output I get when providing the path to an images

    <li>
    <a class="1 " rel="1" href="#">
    <ins style="background-image: url(&quot;/umbraco/images/umbraco/change_master_doc_type.png&quot;);">&nbsp;</ins>
    <span>Change Master Doc Type</span>
    </a>
    </li>

    In firebug, the &amp;quote; appears as double quotes. Maybe it's this that is breaking it (double quotes inside double quotes)

    Matt

  • Morten Christensen 594 posts 2747 karma points admin hq c-trib
    Jul 16, 2010 @ 22:16
    Morten Christensen
    0

    Okay, so it is actually outputting inline styling. Which is a plus :-D

    But yeah it should be:

    <ins style="background-image: url('/umbraco/images/umbraco/change_master_doc_type.png');"> </ins>

    - Morten

  • Matt Brailsford 2149 posts 10593 karma points MVP 6x c-trib
    Jul 16, 2010 @ 22:19
    Matt Brailsford
    0

    Hey Morten,

    There is another post with some usefull information here:

    http://our.umbraco.org/forum/using/ui-questions/6225-Custom-icon-in-Context-menu

    Matt

  • Morten Christensen 594 posts 2747 karma points admin hq c-trib
    Jul 16, 2010 @ 22:26
    Morten Christensen
    0

    Yes, you can define your own sprite but I think you would have to inject the styles into the existing umbraco css in order for the spirte to show. It might be possible to add a reference to your own stylesheet from within a custom section, but not sure it'll work outside of this section. Haven't really looked into the new dependency implementation yet :-S

    But here is the problem:

    if (opts.items[i].icon) str += "<ins " + (opts.items[i].icon.indexOf("/") == -1 ? " class='" + opts.items[i].icon + "' " : " style='background-image:url(\"" + opts.items[i].icon + "\");' ") + ">&nbsp;</ins>";

    Line 50 in jquery.tree.contextmenu.js

    background-image: url('url.jpg'); is only necessary if there is a space in the path, so... But I would say that it is the double quote that is causing the problem.

    - Morten

  • Morten Christensen 594 posts 2747 karma points admin hq c-trib
    Jul 16, 2010 @ 22:28
    Morten Christensen
    0

    @Matt You wanna try out the fix? The file is located under wwwroot\umbraco_client\Tree\jquery.tree.contextmenu.js

    Would be interesting to see if it actually works removing the two \" inside the ().

    - Morten

  • Morten Christensen 594 posts 2747 karma points admin hq c-trib
    Jul 17, 2010 @ 12:01
    Morten Christensen
    0

    Thought I'd add a link to another thread where Matt found a solution for the custom icon in contextmenu - umbraco 4.5:
    http://our.umbraco.org/forum/using/ui-questions/6225-Custom-icon-in-Context-menu#comment39514

    A codeplex issue has been added, so please go vote it up as its pretty important for Package developers to have this functionality.
    http://umbraco.codeplex.com/workitem/28119?ProjectName=umbraco

    - Morten

Please Sign in or register to post replies

Write your reply to:

Draft