Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3942 karma points c-trib
    Sep 18, 2009 @ 13:57
    Dan
    0

    Set CSS class on link

    Hi,

    In the link dialog box in the main editing window, there is no field for a CSS class.  Is it possible to add this somehow, as I need my client to be able to add a css class to certain link tags without delving into the HTML view?

    Thanks

  • Chris Dunn 75 posts 127 karma points
    Oct 01, 2009 @ 01:11
    Chris Dunn
    1

    There's no way to add a class from the link window but it can still be done without entering the HTML view.  Have your client add the link by selecting link text and clicking the link button.  Once the link is set, have them re-select the same text which selects the link tag.  Then have them apply the css class by choosing the style from the styles dropdown on the toolbar.  It's a 2 step process but it gets the job done.   You will obviously have to add those link styles as properties to the style sheet and associate the style sheet with the RTE being used :)

    -Chris

  • Paul Blair 466 posts 731 karma points
    Feb 22, 2011 @ 04:16
    Paul Blair
    0

    I couldn't get this to work following the steps outlined by Chris (using 4.6.1)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 07:55
    Jan Skovgaard
    0

    Hi Paul

    Are the styles defined properly and are they selectable from the "styles" in the rich text editor? Could you please give a more thorough description of what you have done in order to try to get this working? Then it might be easier to figure out where things go wrong. :-)

    /Jan

  • Paul Blair 466 posts 731 karma points
    Feb 22, 2011 @ 08:27
    Paul Blair
    0

    Hi, yes the styles are selectable and are set up exactly as specified by Chris. If I apply the style to text it applies it correctly. When applied to an anchor it wraps it in a SPAN with the correct class name.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 08:46
    Jan Skovgaard
    0

    Hi Paul

    Yeah, that's a bit buggy because it will also insert a span in the <p> sometimes, with the class on it. But I guess this is just a matter of taking care of it in the CSS somehow making sure the link is properly styled if the span is wrapped around it.

    Have you defined the class style in the class definition in Umbraco? I guess that it should work if you add the selectors and properties to your ordinary stylesheet.

    (I'm guessing that the structure generated is <a href="#"><span class="yourclass">Text</span></a>, right?)

    /Jan

  • Paul Blair 466 posts 731 karma points
    Feb 22, 2011 @ 08:57
    Paul Blair
    0

    Hi,

    No, it is generating it like <span class="yourclass"> <a href="#">Text</a></span>.

    Fortunately, it is just for my own site so I am happy to edit the HTML directly.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 09:18
    Jan Skovgaard
    1

    Hi Paul

    Ok, but that should be ok too i guess - it should really just be a matter of taking care of it in the css. Either it should catch span.yourclass a og just a.yourclass, right?

    I know the ideal solution would be to not have the spans at all but sometimes one just needs to be pragmatic, right? :-)

    /Jan

  • Paul Blair 466 posts 731 karma points
    Feb 22, 2011 @ 09:31
    Paul Blair
    0

    Hi Jan,

    Point taken - And if it was a customer site this is the appoach I would probably take. As this will be in a prominent position on the re-design of my site I will just edit the HTML as a want the HTML to look clean.

    Thanks

    Paul

  • Paul Blair 466 posts 731 karma points
    Feb 22, 2011 @ 09:40
    Paul Blair
    0

    I have just added a work item here: http://umbraco.codeplex.com/workitem/30063

    (Incidently the pop used in the editor for this forum allows you to add a class)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies