Custom styles in the Joomla editor

Alright so here goes our first tip. The content editor is an important part of any CMS. Most people don't know HTML so editors and some admins will be using the default TinyMCE editor in Joomla. One simple thing you can do to make your template more friendly for this users is to add the custom styles for the template directly to the styles drop down list.

The styles drop down in the TinyMCE editor

As an admin, you can do this by editing the editor plugin settings to include the template's stylesheet but since we don't want the end users to have to do this we are going to use another method. The trick is to create a file inside the template's CSS folder called editor.css. Joomla will look for this file automatically. The styles that are listed in this stylesheet will then be shown in the drop down menu of the editor. So the file can look something like this:

.clearfix{}

.clear{}

.left{}

.right{}

.process-list{}

.step-number{}

.border{}

.pullquote{}

.make-me-btn{}

.zebratable{}

.hovertable{}

.caption{}

.highlight{}

hr#system-readmore{}

hr.system-pagebreak{}

Now this will get the styles listed and they will work then in the template. The only thing left to do is add some styling to them. keep in mind that the style rules applied in editor.css will be visible in the editor window but not in the template itself, so they are only to help the article writers. For example the default system-readmore id has the following styling:

hr#system-readmore{ border: red dashed 1px; color: red; }

The class names shown before are the ones used for the editor in the Helix template. Yours will be naturally different. And that's it. Now the writer can for example select some text and choose pullquote from the style menu to get it wrapped in a span with the proper class without touching the HTML. Pretty easy and practical, isn't it?

Rate this item
(1 Vote)
Tagged under

7 comments

  • Comment Link Demente Tuesday, 21 June 2011 14:30 posted by Demente

    Yes I thought the code was removed :? but couldn't guess what you meant.
    Anyways those styles depend on the template. Maybe it adds a certain class when the article has a readmore button.

  • Comment Link Hebergement Marrakech Tuesday, 21 June 2011 06:39 posted by Hebergement Marrakech

    Sorry I've just noticed that my sentence has been cut by the code cleaning function.
    I said in my last comment that I thought the problem was due to the editor styles because it only appears when I add a hr readmore tag. Without hr readmore no problem. But with the hr readmore the width is reduced and it's fixed by adding a 100% width to the blog class.

    So I really can't understand why there's a problem with the blog class only with the hr readmore tag.

  • Comment Link Demente Monday, 20 June 2011 21:01 posted by Demente

    Can't really tell what the problem was. If it was in the [i]blog[/i] class it shouldn't have anything to do with the article content.

  • Comment Link Hebergement Marrakech Monday, 20 June 2011 19:02 posted by Hebergement Marrakech

    I thought it was due to the styles from my editor because it only appeared when I add the

  • Comment Link Hebergement Marrakech Monday, 20 June 2011 19:00 posted by Hebergement Marrakech

    Thanks for your reply.
    I managed to fix the problem : you're right, it was a class that restricted the width
    I added a 100% width to the class table.blog and then it fixed the problem.
    Strange because I never had to modify this css class before.

  • Comment Link Demente Monday, 20 June 2011 18:21 posted by Demente

    What exactly do you mean? This issue should have nothing to do with the styles from your editor unless you have wrapped your article in an element with a class that restricts the width.

  • Comment Link Hebergement Marrakech Monday, 20 June 2011 08:21 posted by Hebergement Marrakech

    Hi,

    I have a problem when I use the in an article : my content doesn't display using the 100% widht anymore.
    Could you please help me ?

Leave a comment