Copied to clipboard

Flag this post as spam?

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


  • Johan Roug 97 posts 153 karma points
    Sep 01, 2010 @ 14:09
    Johan Roug
    0

    Assign class in tinyMCE

    I would like to be able to assign a class to text from the tinyMCE. How can this be done

    Thanks

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Sep 01, 2010 @ 15:23
    Ismail Mayat
    0

    create a new css call it say editor.  under it create your style definitions eg h1 h2 and put styles in there. then goto developer section and pick the rich text edit datatype and from the available css select editor.  when you now got back to content editor the styles that you defined will no be available from the styles drop down.  Please note you have to also put the styles in your main style sheet.

    Regards

    Ismail

  • Johan Roug 97 posts 153 karma points
    Sep 01, 2010 @ 15:47
    Johan Roug
    0

    thanks, but this is not what I want.

    I know how to assign styles to text.

    What I want is:

    lets say I have

    <p>this is some text</p>

    then I want to choose a class and assign it. Now the code should look like this

    <p class="myAssignedClass">this is some text</p>

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Sep 01, 2010 @ 16:22
    Ismail Mayat
    0

    if you create the class and in alias for it put .whatever then when you select a some text in rich text edit it will wrap it with a span with that class not sure if you can without editing raw html get exact effect that you are after.

    Regards

    Ismail

  • jc 64 posts 101 karma points
    Sep 01, 2010 @ 17:34
    jc
    0

    If you do like Ismail has suggested:

    1. Create a new stylesheet
    2. Create a new style with a.) Name of "myAssignedClass" and b.) Alias of ".myAssignedClass"
    3. Associate it with your RTE

    Then when you are in the RTE, click to place the insertion point in a block of text (without selecting text), choose myAssignedClass from the styles dropdown and it will apply the style to the containing paragraph element. If you click and drag to select a block of text and then select the style, it will wrap it in a span element.

    If you want to remove the class, select "Styles" from the style dropdown and it will be removed.

  • Johan Roug 97 posts 153 karma points
    Sep 01, 2010 @ 18:22
    Johan Roug
    0

    thanks, I will give it a go tomorrow

Please Sign in or register to post replies

Write your reply to:

Draft