You are not logged in.

#1 2007-04-18 15:43:02

tbobker
Member
Registered: 2007-04-18
Posts: 1

Loading HTML and CSS into tinymce

I want to load an html page that has css in the head into tinymce so i can edit the page. Only im having some problems. Is it possible to do this?

Offline

 

#2 2007-05-08 13:31:24

Jonna
Member
Registered: 2006-11-10
Posts: 16

Re: Loading HTML and CSS into tinymce

I have the exact same problem. I am fetching all my CSS content from a DB, and want to get away from storing multiple css-files. So I also want TinyMCE to recognice all settings from the <style type="css"></style> section in the HTML document. This must be a very common problem for many trying to build a CMS with this editor.....

Offline

 

#3 2007-05-08 15:31:27

brochris
Member
From: USA
Registered: 2006-12-11
Posts: 102
Website

Re: Loading HTML and CSS into tinymce

From my understanding, tinyMCE cannot do this.  It's not a css editor, and is not set up to recognize css unless it's contained in a style attribute within a tag (i.e. <span style="some css").  I'm sure, however, that it's possible to write a plugin that does this...it just hasn't been written yet as far as I know.


--------------------------------------------------------------------------------
chrisandabby.com : designsbychris.com : 100mostbeautifulbabies.com

Offline

 

#4 2007-05-10 23:57:16

Jonna
Member
Registered: 2006-11-10
Posts: 16

Re: Loading HTML and CSS into tinymce

Actually, I found a way to solve my problem!

I am building a cms, and I want to be able to shift a look in a template by simply shifting between different css setups. We call them themes. We want to avoid storing every different theme in a file, and instead store them in a database.

Well, to be able to do that up til now, I simply read in the css-values (the theme) from the DB and then plottet it out in the main HTML-file between <style type="css"></style>.

Up to now, everything was in order....then came the problem to make TinyMCE to read from the <style>- segment of the page instead of reading from a linked css-file....think it will work? You can just forget it, mate! I spent several hours in the forums.......

So, how do we solve it then?

Simply by generating a dynamic php-file that plots out the css-values instead! The neat thing is that you can put a php-file inside of a link-tag, instead of pointing to a static css-file!

Example:

<link rel="stylesheet" type="text/css" href="php_file_goes_here.php" >

That file in turn, can even take paramenters!

Example:

<link rel="stylesheet" type="text/css" href="theme_css_generator.php?theme_id=1" >

The file theme_css_generator.php collects all css values from DB and just echos it out in itself.

So, finally, you just feed TinyMCE with the same file by the content_css-command in the init section

tinyMCE.init({
   content_css : "theme_css_generator.php",
   ...

Work's like a charm!

Offline

 

#5 2008-02-22 18:47:29

upatune
Member
Registered: 2008-02-22
Posts: 1

Re: Loading HTML and CSS into tinymce

Just read your amazing post Jonna!

You can't believe how many hours you just saved me!

THANK YOU!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB