Archived CMSimple Support Forum
http://www.cmsimple.dk/forum/

Got simple editor working with CMSimple
http://www.cmsimple.dk/forum/viewtopic.php?f=5&t=869
Page 1 of 1

Author:  tbishop61 [ Sat Jun 05, 2004 9:34 am ]
Post subject:  Got simple editor working with CMSimple

Alex King, one of the contributors to Wordpress, has released his quicktags javascript editing script -- see http://www.alexking.org/blog/2004/06/03 ... nder-lgpl/.

These might be nice for people like me, who don't need a WYSIWYG HTML editor, but like to have little buttons for things like blockquote. Right now I am using the basic simple editor for CMsimple, because Firefox crashed so regularly in the standard editor, but I would love these.

Supposedly it is just a matter of including the Javascript at the head of the editing document, and giving the text area a special name.

thanks,
Tim

Author:  tbishop61 [ Mon Jun 07, 2004 5:52 am ]
Post subject: 

I got the quicktags editor working with CMSimple today. I downloaded the file from the link above and copied js_quicktags.js into the same directory that my index.php is in.

Then I took the code that Peter Harteg provided a while ago for a simple editor (see http://www.cmsimple.dk/forum/viewtopic.php?t=365) and changed it to:

Code:
// Took original from CMSimple forum http://www.cmsimple.dk/forum/viewtopic.php?t=365
// for making a very simple plain text editor that should work with any browser and
// changed it to work with Alex King's javascript-based quicktags (see
// http://www.alexking.org/blog/2004/06/03/js-quicktags-under-lgpl/

            if ($edit && (!$f || $f == 'save') && !$download) {
                if ($s < 0 && $ss < count($c))$s = $ss;
                 if ($s > -1) {
                    $su = $u[$s];
                     $o .= '<form method="post" style="margin:0" id="ta" action="' . $sn . '">
                     <script type="text/javascript">edToolbar();</script>
                     <input type="hidden" name="selected" value="' . $u[$s] . '">
                     <input type="hidden" name="function" value="save">
                     <textarea name="text" id="canvas" ROWS="15" COLS="40">' . $c[$s] . '</textarea>
                     <script type="text/javascript">var edCanvas = document.getElementById' . "('canvas')" . ';</script>
                     <input type="submit"></form>';
                     } else $o = '<p>' . $tx['error']['cntlocateheading'] . '</p>';
            }
           


Of course commenting out all the stuff below under //EDITOR CALL.

I also had to change the head function to include the javascript, as so:
Code:
// PAGE FUNCTIONS
        // tb added 2 lines for quicktags
        function head() {
            global $title, $cf, $pth, $tx, $hjs;
            if ($cf['site']['title'] != '')$t = $cf['site']['title'] . ' - ' . $title;
            else $t = $title;
            $t = '<title>' . $t . '</title>';
            $quicktags = '<script src="js_quicktags.js" type="text/javascript"></script>';
            foreach($cf['meta'] as $i => $k)$t .= meta($i);
            if ($tx['meta']['codepage'] != '')$t .= '<meta http-equiv="content-type" CONTENT="text/html;charset=' . $tx['meta']['codepage'] . '">';
            return $t . $quicktags . '<meta NAME="generator" CONTENT="CMSimple 2.3 - www.cmsimple.dk"><link rel="stylesheet" href="' . $pth['file']['stylesheet'] . '" type="text/css" />' . $hjs;
        }


It seems to work, after about an hour's testing.

If anyone else tries this, let me know how if it works. I personally much prefer this kind of simple editor.

Thanks,
Tim
P.S. This is fun -- I hope it is ok with you, Peter. And thank you Alex for the nice little editor.

Author:  harteg [ Mon Jun 07, 2004 12:55 pm ]
Post subject: 

Quote:
P.S. This is fun -- I hope it is ok with you, Peter.


Cool!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/