sNews Forum

sNews 1.6 (previous version) => 3rd Party Integration and bridges => Topic started by: ens on May 30, 2007, 02:25:26 am

Title: [MOD] TinyMCE Editor
Post by: ens on May 30, 2007, 02:25:26 am
This isn't really a mod as no programming was required, but it could be helpful for some users.

This MOD will transform your comment boxes and administration article writing boxes into textareas using a WYSIWYG editor called TinyMCE. TinyMCE uses javascript, and if javascript is not enabled, the textarea will be like normal.

Simply download TinyMCE here (http://prdownloads.sourceforge.net/tinymce/tinymce_2_1_1_1.zip?download). Unzip it on your hard drive. Navigate through:
tinymce -> jscripts -> and copy folder "tiny_mce" to the root of your website.

Now, in your index.php file, add into the head
Code: [Select]
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>
Now, in your virgin sNews.php, find
Code: [Select]
echo html_input('button', 'strong', '', 'B', '', 'button', 'onclick="tag(\'strong\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'em', '', 'I', '', 'button', 'onclick="tag(\'em\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'strike', '', 'Strike', '', 'button', 'onclick="tag(\'strike\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'p', '', 'P', '', 'button', 'onclick="tag(\'p\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'br', '', 'BR', '', 'button', 'onclick="tag(\'br\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'break', '', 'Break', '', 'button', 'onclick="tag(\'break\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'img', '', 'Image', '', 'button', 'onclick="tag(\'img\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'link', '', 'Link', '', 'button', 'onclick="tag(\'link\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');
in the 'articles form' function and delete it (all of it).
Refresh your page(s) and voila!
Title: [MOD] TinyMCE Editor
Post by: mosh on May 30, 2007, 10:39:12 am
works very good, thank you ens  :cool:
Title: [MOD] TinyMCE Editor
Post by: tayson on May 30, 2007, 09:22:23 pm
Ens, by inserting this code:

Code: [Select]
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas"
});
</script>
in <head>, you change all the textareas.
I did this:

Code: [Select]
<? if(strstr ($_GET[action],"admin")){ ?>
   <script language="javascript" type="text/javascript" src="includes/tiny_mce/tiny_mce.js"></script>
   <script language="javascript" type="text/javascript">tinyMCE.init({ mode : "textareas" });</script>
<? } ?>
to change just the administrationīs textarea.
I donīt know if itīs the best way, but is functioning.

  :)
Title: [MOD] TinyMCE Editor
Post by: ens on May 30, 2007, 09:37:06 pm
You're right tayson, but the mod was originally meant to transform all text areas (including commentboxes for visitors).
Title: [MOD] TinyMCE Editor
Post by: Armen on May 30, 2007, 11:07:30 pm
Quote from: ens
You're right tayson, but the mod was originally meant to transform all text areas (including commentboxes for visitors).
I tried this once. Pretty unreliable, because it takes forever to initialize a 300-kb JS every time a page is refreshed. Besides not all tags are allowed for guests, so there's gonna be garbage in comments. And in my snews I use bbcode, so tags are just stripped.
Title: [MOD] TinyMCE Editor
Post by: ens on May 30, 2007, 11:10:59 pm
Hey, but for some people, thats what they want.

And when the multi-user mod comes out, it'll be handy.

(ooh yay! my 100th post!)
Title: [MOD] TinyMCE Editor
Post by: desdevlover on June 17, 2007, 08:41:30 am
Pls help me, This mod does not work with me.
I was edited files via tayson introductions but WYSIWYG not working fine?
Title: [MOD] TinyMCE Editor
Post by: ens on June 21, 2007, 11:30:06 pm
Quote from: desdevlover
Pls help me, This mod does not work with me.
I was edited files via tayson introductions but WYSIWYG not working fine?
Make sure the path to your TinyMCE is correct :
Code: [Select]
src="includes/tiny_mce/tiny_mce.js"Change that if necessary.
Title: [MOD] TinyMCE Editor
Post by: ens on June 21, 2007, 11:51:00 pm
Quote from: tayson
Ens, by inserting this code:

Code: [Select]
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas"
});
</script>
in <head>, you change all the textareas.
I did this:

Code: [Select]
<? if(strstr ($_GET[action],"admin")){ ?>
   <script language="javascript" type="text/javascript" src="includes/tiny_mce/tiny_mce.js"></script>
   <script language="javascript" type="text/javascript">tinyMCE.init({ mode : "textareas" });</script>
<? } ?>
to change just the administrationīs textarea.
I donīt know if itīs the best way, but is functioning.

  :)
Tayson, it's not working for me. how exactly did you do this?
Title: [MOD] TinyMCE Editor
Post by: edsil on June 22, 2007, 09:29:06 am
Hi ens!

well I apply tinyMCE like this:
in the index.php, just under favicon, and before "</head>" I put:

Code: [Select]
<!-- Javascript  tinyMCE -->
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
        <script language="javascript" type="text/javascript">
        tinyMCE.init({
            mode : "textareas",
            theme : "advanced",
            editor_selector : "mceEditor",
            language : "en",
plugins : "imagemanager,filemanager,table,advhr,advimage,advlink,iespell,insertdatetime,flash,searchreplace,contextmenu",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_buttons1_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,flash,backcolor",
            width : "485",
            height : "300"
            });
            </script>
Then, into snews.php, I do like you said, to erase:

Code: [Select]
   echo html_input('button', 'strong', '', 'B', '', 'button', 'onclick="tag(\'strong\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'em', '', 'I', '', 'button', 'onclick="tag(\'em\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'strike', '', 'Strike', '', 'button', 'onclick="tag(\'strike\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'p', '', 'P', '', 'button', 'onclick="tag(\'p\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'br', '', 'BR', '', 'button', 'onclick="tag(\'br\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'break', '', 'Break', '', 'button', 'onclick="tag(\'break\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'img', '', 'Image', '', 'button', 'onclick="tag(\'img\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'link', '', 'Link', '', 'button', 'onclick="tag(\'link\')"', '', '', '', '', '', '', '', '');
    echo html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');
and after I put:

Code: [Select]
?><p><textarea name="text" class="mceEditor"><? echo $frm_text; ?></textarea><?It is working for me, and no problem... hope this help you :)
Title: [MOD] TinyMCE Editor
Post by: ens on June 23, 2007, 04:25:40 pm
You're right, this works perfectly. Thanks edsil!
Title: [MOD] TinyMCE Editor
Post by: edsil on June 23, 2007, 11:52:49 pm
Nice to know this help you :)
Title: [MOD] TinyMCE Editor
Post by: jeepnstein on July 26, 2007, 07:23:13 pm
Edsil,

You have just saved me a ton of work.  Thanks so much.   I needed a good editor for Rui's TUGA Mod.  This is just the ticket.

Jim
Title: [MOD] TinyMCE Editor
Post by: redman on August 13, 2007, 12:24:43 pm
I would like enjoyment TyniMCE (theme: simple)  near commentboxes for visitors, TinyMCE me functions in the same way how introduced ens, but me portrayals only when be logged like admin, doesn't know somebody how permit TyniMCe near   commentboxes for visitors  ?
Title: [MOD] TinyMCE Editor
Post by: mosh on August 18, 2007, 07:38:46 am
this snippet loads the js script only for editting.
Code: [Select]
<? if( $_GET['action'] == "admin_article"){ ?>
................. js code
<? } ?>
i would like the js script to load when admin add new article,extra,page and when editting the content ( article,extra,page, comments )

any idea for how to do it ?
thanks
Title: [MOD] TinyMCE Editor
Post by: codetwist on August 18, 2007, 11:27:08 am
Basically You can use conditions similar to those at the beginning of center() function ;)
Title: [MOD] TinyMCE Editor
Post by: mosh on August 18, 2007, 01:57:29 pm
thank you codetwist  :)

i set up small mod for loading tiny
when admin logged in
and click on add new or edit
articles,extra,page

it work like this:
in index.php in the head section add new function
Code: [Select]
<? function tiny_load() { ?>
<!-- place here your tinyMCE code  -->
 <? } ?>
in snews.php go to start of center() function on the third switch find:
delete those 4 lines
Code: [Select]
case 'admin_article': form_articles(''); return; break;
case 'article_new': form_articles('article_new'); return; break;
case 'extra_new': form_articles('extra_new'); return; break;
case 'page_new': form_articles('page_new');  return; break;
replace with this:
Code: [Select]
case 'admin_article': form_articles(''); tiny_load(); return; break; //tiny
case 'article_new': form_articles('article_new'); tiny_load(); return; break; //tiny
case 'extra_new': form_articles('extra_new'); tiny_load(); return; break; //tiny
case 'page_new': form_articles('page_new'); tiny_load(); return; break; //tiny
no more slowdown and wasted bandwidth when not using the editor  :D .


update: grrrr lol it dont work with IE, only FF, need to find why.
thanks for any help :)

aweome day to all
Title: Re: [MOD] TinyMCE Editor
Post by: Alien on August 21, 2007, 04:00:34 pm
Thanks for the mod/addon, great stuff. :)

I've added the following to my index.php page header as outlined in this thread:

Code: [Select]
<? if(strstr ($_GET[action],"admin")) { ?>
   <script language="javascript" type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
   <script language="javascript" type="text/javascript">tinyMCE.init({ mode : "textareas" });</script>
<? } ?>

- But it only shows the RTE up when editing an article; not creating a new article (article new). Is there anyway to have it for both (creating and editing)?

Thanks.  8)
Title: Re: [MOD] TinyMCE Editor
Post by: mill on August 24, 2007, 03:30:49 am
Hi! I have a problem with this addon. If i have instaled it, i ca't use the pagination [break]. Can somebody helpme?ŋ?
Title: Re: [MOD] TinyMCE Editor
Post by: ens on August 24, 2007, 04:00:19 am
Just type [break] wherever you want it.
Title: Re: [MOD] TinyMCE Editor
Post by: edsil on August 24, 2007, 02:06:47 pm
Hi there...

I have now some problems with this: to download a page it takes a lot of time... I dont know why before I had not this problem...
Other thing, some codes in this topic (and in others in this forum) does not appear... or it is just my browser? (FF)...
Title: Re: [MOD] TinyMCE Editor
Post by: Keyrocks on August 24, 2007, 03:34:36 pm
Hi there...
1)  I have now some problems with this: to download a page it takes a lot of time... I dont know why before I had not this problem...
2)  Other thing, some codes in this topic (and in others in this forum) does not appear... or it is just my browser? (FF)...

1)  I have experienced longer loading times for pages when TinyMCE is loading in the page, and it is to be expected since more stuff is loading to create the TinyMCE interface and activate their functions. This was the main reason I took the route of modifying existing... and adding new... functions to the existing sNews Editor scripts and... while they load faster than TinyMCE... my mods take more a little more time to load than the default Editor functions because there are more of them and they use icon images instead of browser-generated buttons.

2)  Yes... you are right. We have been experiencing some problems with code not displaying properly in some of the posts on our new Forums. This is one of the un-expected glitches that usually surface when taking the database from one Forum system and converting it to run with another Forum system. Hopefully, over time, each active member will go into their own posts and correct the situation. Philmoz has suggested (elsewhere) that opening an existing post with the MODIFY function, then saving it again without making any changes, usually results in the code displaying properly again.

Title: Re: [MOD] TinyMCE Editor
Post by: mill on August 24, 2007, 05:55:54 pm
Just type [break] wherever you want it.

thanks, it a simple method but works  :)
Title: Re: [MOD] TinyMCE Editor
Post by: edsil on August 25, 2007, 02:09:57 am
Hi there,

yeah, sure St Keyrocks, but the thing is that I prefer to use tinyMCE...

I remember somebody posted something like "download tinyMCE JS from an outside folder" and I dont find it in the forum...
I'm working with this post: http://snewscms.com/forum/index.php?topic=4548.0 (http://snewscms.com/forum/index.php?topic=4548.0) (tinyMCE editor in admin), but the thing is that this is about a bouton to call the tinyMCE and I need the tinyMCE directly in the admin...

 :)
Title: Re: [MOD] TinyMCE Editor
Post by: edsil on September 03, 2007, 02:14:51 pm
I dont find this post on, the forum, it is a very good alternative...
If dont I tryed the TinyMCE compressor, and it works fine, just go to: http://tinymce.moxiecode.com/download.php (http://tinymce.moxiecode.com/download.php)
and download compressor, then to install it is very simple, just follow: http://wiki.moxiecode.com/index.php/TinyMCE:Compressor/PHP (http://wiki.moxiecode.com/index.php/TinyMCE:Compressor/PHP)

Anyway, if some body know this post about download tinyMCE from an outside script, I will appreciate it ;)

Thanks...
Title: Re: [MOD] TinyMCE Editor
Post by: urbitasmedia on September 06, 2007, 03:20:59 am
One more option and the one I use is this...

Code: [Select]
<? if ($_SESSION[db('website').'Logged_In'] == token()) { ?>
   <script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
   <script language="javascript" type="text/javascript">tinyMCE.init({ theme : "advanced", mode : "textareas", plugins : "insertdatetime", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_buttons1_add : "insertdate", plugin_insertdate_dateFormat : "%m %d, %Y" });</script>
<? } ?>

If you logged in then you get TinyMCE otherwise you get the standard text box.
Title: Re: [MOD] TinyMCE Editor
Post by: edsil on September 06, 2007, 06:05:50 am
Hi urbitas,

Thanks for your comment, but where exactly I must paste this code?... I would like to try it...
Do I need to erase any other code?

Thanks :)
Title: Re: [MOD] TinyMCE Editor
Post by: Joost on September 06, 2007, 06:46:37 am
Looks like it is going into the header of index.php.
Title: Re: [MOD] TinyMCE Editor
Post by: ens on September 25, 2007, 01:30:55 pm
The first block of code in my first post, you paste into the HEAD of your index.php file.

The second part (with all of the html_input's) must be removed from your snews.php file.

The file you downloaded must be uploaded somewhere on your server, and referred to appropriately in the code that goes into your HEAD.
Title: Re: [MOD] TinyMCE Editor
Post by: atomkarinca on September 29, 2007, 01:40:57 pm
thanks,
Title: Re: [MOD] TinyMCE Editor
Post by: mico75 on October 09, 2007, 11:06:57 am
One more option and the one I use is this...

Code: [Select]
<? if ($_SESSION[db('website').'Logged_In'] == token()) { ?>
   <script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
   <script language="javascript" type="text/javascript">tinyMCE.init({ theme : "advanced", mode : "textareas", plugins : "insertdatetime", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_buttons1_add : "insertdate", plugin_insertdate_dateFormat : "%m %d, %Y" });</script>
<? } ?>

If you logged in then you get TinyMCE otherwise you get the standard text box.

Thanks urbitas! Just nice little script  :)
And what I did to make me easier when changing template:

I made short php script, let's call it: tinymce_load.php containing these lines:
Code: [Select]
<?php

function tinymce_if_login() {
    if (
$_SESSION[db('website').'Logged_In'] == token()) { 
        echo 
'<script language="javascript" type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>';
        echo 
'<script language="javascript" type="text/javascript">';
        echo 
'tinyMCE.init({ theme : "advanced",mode : "textareas", plugins : "insertdatetime", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_buttons1_add : "insertdate", plugin_insertdate_dateFormat : "%m %d, %Y", width : "485", height: "300"});';
        echo 
'</script>';
    }
}
?>


Then a little adjustment in index.php, add blue one:
<?php session_start(); include('snewsMU.php'); include('tinymce_load.php'); ?>

and then inside <head> section:
Code: [Select]
<?php tinymce_if_login(); ?>