Subscribe to Acqal

Got Thoughts? Write Us!

Contact
Request
Validate

Approved TYPO3 Agency

Acqal is an approved TYPO3 agency focusing on support, training and website migration.

This means that we...

  • are available on TYPO3.org
  • make substantial contributions to TYPO3 teams
  • are registered as business members of the TYPO3 Association
  • have completed more than four TYPO3 projects
  • have proven our technical abilities with quality TYPO3 extensions
  • use TYPO3 for our own website

Acqal is a TYPO3 Association Business Member

Popular Blog Posts

Blog Topics

Virgil on Twitter

Please wait while virgilhuston tweets load Twitter is loading

Recent Blog Posts

Blog Archives

Add Custom CSS Classes to the TYPO3 RTE

rtehtmlarea block style

rtehtmlarea block style

rtehtmlarea custom CSS classes in stylesheet

rtehtmlarea custom CSS classes in stylesheet

rtehtmlarea custom CSS classes in Page TSConfig

rtehtmlarea custom CSS classes in Page TSConfig

rtehtmlarea text style

rtehtmlarea text style
Tuesday, June 30, 2009 12:00 AM EDT

By: Michael Cannon

voting in progress Submitting your vote...
Rating: 3.0 of 5. 3 vote(s).
Click the rating bar to rate this item.

Easily enable custom CSS classes for TYPO3 RTE

The TYPO3 RTE is quite flexible. One easily proven aspect, is by the ability to select what CSS styling to apply by highlighting some text and choosing a custom CSS class from a drop-down. Furthermore, making this happen only takes a few minutes.

There's 2 basic steps to making custom CSS classes available in the RTE.

  1. Create custom classes in your CSS stylesheet, with only one per line.
  2. Modify the RTE via Page TSConfig
    1. Link the RTE to the site CSS stylesheet
    2. Assign the custom classes to text types

Sample content.css with custom classes.

.coding { font-family: monospace; font-size: 1.1em;}
.note {background: #dfd; padding: 1em; border-top: 1px #bdb dotted; border-bottom: 1px #bdb dotted;}
.important {background: #ffd; padding: 1em; border-top: 1px #ddb dotted; border-bottom: 1px #ddb dotted;}
.warning {background: #fdd; padding: 1em; border-top: 1px #dbb dotted; border-bottom: 1px #dbb dotted;}
.float_left { float: left; display:inline; margin-right: 1em; margin-bottom: 0.15em;}
.float_right { float: right; display:inline; margin-left: 1em; margin-bottom: 0.15em;}
.center { text-align:center; margin: 0.5em auto}

/* these are for showing alignment in RTE on the backend */
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }
.align-justify { text-align: justify; }

RTE Page TSConfig sample

RTE {
default {
# link to site css stylesheet
contentCSS = fileadmin/templates/css/screen/content.css

# clear typical styling
classesAnchor >
classesLinks =
# set classes available to these properties. Paragraph is another name
# for block
classesCharacter := addToList(coding, note, important, warning)
classesParagraph := addToList(coding, note, important, warning, float_left, center, float_right)
classesTD := addToList(sub)
classesTable := addToList(full, fixed)

# list all available classes here, otherwise they're removed on RTE save
proc.allowedClasses := addToList(coding, note, important, warning, float_left, center, float_right, sub, full, fixed)
}
}

In the above Page TSConfig, we adjust the CSS stylesheet being referenced via contentCSS. A relative file path is from the website root with TYPO3 installed is sufficient.

Next, as we want to supplement, not replace the classes applicable, we use the addToList TypoScript function to add our custom CSS classes. These CSS classes are assigned to specific text types, like block text-strings, elements and tables as shown by the classesCharacter & classesParagraph samples.

Once you add your custom classes, you must make sure all of them are listed in the proc.allowedClasses property. Otherwise, your custom classes will not show up.

Reference

If you've got problems or questions, ask them in our comments section.

Keywords:

  • typo3 htmlarea, rtehtmlarea, classesparagraph, allowedclasses, css

Please Share This Post

Tweet thisRedditBookmark on deliciousStumble thisShare on Facebook

Send this article via email to your friends and peers.

Leave a Comment

Add comment

* - required field







Notify me when a new comment is added.
By Petro on Wednesday, July 1, 2009 11:31 AM EDT
Gravatar: Petro Can someone share links with information about how to "powerfully" use RTE in TYPO3?

Things it would like to know:

* customize output generated in frontend
* customize view of text in backend (should look like in frontend)
* add typical styles specific for site
* adding special elements to text, like source code with syntax highlighting
* ,,,

thanks.

PS. Please, use little bigger default font size in textarea for comment.
By Michael Cannon on Friday, July 3, 2009 4:30 AM EDT
Gravatar: Michael Cannon Petro, the things you're asking about are found starting with the rtehtmlarea manual at TYPO3.org.

For frontend output handling, that's TypoScript.

For backend look of text, that's TSConfig, like above's contentCSS.

Add styling options to RTE is covered in this post.

Special elements could be handled through additional custom extensions or using content replacers. I'm not sure what exactly you're asking for.
By Peter Franzén on Tuesday, December 15, 2009 2:30 AM EST
Gravatar: Peter Franzén Don´t forget to add:
showTagFreeClasses = 1

otherwise it wont work! (at least not with 4.1.13 > )
//Peter
By jonni on Wednesday, July 14, 2010 3:38 AM EDT
Gravatar: jonni <a href="http://blabla.com/">nothing</a> not reaaly interesting
By Dr.dro on Friday, August 13, 2010 4:43 AM EDT
By klima servisi yusuf on Friday, August 13, 2010 4:00 PM EDT
Gravatar: klima servisi yusuf Things it would like to know:
By sezer biyam on Monday, August 30, 2010 12:57 PM EDT
Gravatar: sezer biyam CSS ( Cascading Style Sheets ) Tutorial - Why CSS ? - Introduction - Css Link Properties / Examples - Css List Properties / Examples - Css Layer Properties / Examples - Css TextBox Properties / Examples - Css Font Properties / Examples - Css Text Properties / Examples - Css Cursor Properties / Examples - Css Background Properties / Examples - Css Table Properties / Examples - Css Scroll Bar Properties / Examples - Tools - Units - Parameters - Template Page - Web Design Tutorial