views:

235

answers:

2

Hi everyone.

I am facing a problem with tinyMCE.

I am giving a functionality on admin side of my website, where admin can edit the content of pages. I have provided them with the tinyMCE for that purpose.

Suppose they are editing Page 'page1'.

They will provide its content in tinyMCE, and save it.

When somebody is visiting that Page 'page1' all I am doing is:

  <html>
  <head>.........</head>
  <body>
  .......
  <div class='page_content'>
  <?php echo $page1->getContent(); ?>
  </div>
  ......
  </body>
  </html>

Everything is working fine.

Now, tinyMCE provide a feature where you tell which css will it use. You set the required css to the 'content_css' property of tinyMCE init function.

I did that, I provided the css which I was using to style my Page Content.

Now, my problem is this:::::::::

Content of my page is in div.page_content. But in tinyMCE, the content of this page is not in any other thing (any div.page_content ). So the style which tinyMCE is applying to my content, while I am editing it, is not visually effective.

The only way, which I can think of resolving this problem is, by telling tinyMCE to add

   <div class='page_content'>

at the top. And then when admin will submit the data, I will just strip this extra div.

::::::::::::::::::::::::::::::::::

Any suggestions?

A: 

The way I would solve this is by adding the class "mceContentBody" to the CSS definitions with a comma as seperator. For example:

.page_content, .mceContentBody {
   put your code here..
}
SjoerdV
Good trick. But it requires us to change our css for many things. Suppose we have many child css definitions, which are selected by reference to .page_content (Eg: .pageContent div.abc h1) . You will have to change each such occurences.
Krishna Kant Sharma
A: 

There is an option in TinyMCE configuration called 'body_class'. You just have to add "body_class = 'page_content'"

Ademir Martins