Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: TinyMCE in Submit Step 2: Small help needed

  1. #1
    Senior Member
    Join Date
    Sep 2009
    Posts
    449
    Thanks
    169
    Thanked 58 Times in 45 Posts

    Default TinyMCE in Submit Step 2: Small help needed

    I've added the following lines of code in submit_step2.php just after line 73 but TinyMCE editor just fails to show up in submit step 2, just wondering where I'm going wrong.

    Line 73 of submit_step2.php

    Code:
    <?php if ($hotaru->post->useContent) { ?>
    The code I have added:

    Code:
    <script language="javascript" type="text/javascript" src="<my tiny_mce js path>/tiny_mce.js"></script>
    <!-- change src according to your needs -->
    
    <script language="javascript" type="text/javascript">
      tinyMCE.init({
        theme : "advanced",
        mode: "exact",
        elements : "elm1",
        theme_advanced_toolbar_location : "top",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,"
        + "justifyleft,justifycenter,justifyright,justifyfull,formatselect,"
        + "bullist,numlist,outdent,indent",
        theme_advanced_buttons2 : "link,unlink,anchor,image,separator,"
        +"undo,redo,cleanup,code,separator,sub,sup,charmap",
        theme_advanced_buttons3 : "",
        height:"350px",
        width:"600px",
        file_browser_callback : 'myFileBrowser'
      });
    
      function myFileBrowser (field_name, url, type, win) {
        var fileBrowserWindow = new Array();
        fileBrowserWindow['title'] = 'File Browser';
        fileBrowserWindow['file'] = "my_cms_script.php" + "?type=" + type;
        fileBrowserWindow['width'] = '420';
        fileBrowserWindow['height'] = '400';
        tinyMCE.openWindow(fileBrowserWindow, { window : win, resizable : 'yes', inline : 'yes' });
        return false;
      }
    </script>

  2. #2
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,863
    Blog Entries
    88
    Thanks
    486
    Thanked 810 Times in 529 Posts

    Default

    Excuse me if I'm stating the obvious, but did you change the src line at the top of the JavaScript?

    Code:
    <script language="javascript" type="text/javascript" src="<my tiny_mce js path>/tiny_mce.js"></script>
    <!-- change src according to your needs -->

  3. #3
    Senior Member
    Join Date
    Sep 2009
    Posts
    449
    Thanks
    169
    Thanked 58 Times in 45 Posts

    Default

    <my tiny_mce js path>
    Yep, put this thing path on purpose

  4. #4
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,863
    Blog Entries
    88
    Thanks
    486
    Thanked 810 Times in 529 Posts

    Default

    Okay, I downloaded TinyMCE and got it working. The tricky part was making sure the file path was correct. I think this would be better as a plugin, but in the meantime...

    1. Download and unzip tinymce_3_27.zip

    2. Open tinymce_3_2_7/tinymce/jscripts/ and you should find a tiny_mce folder.

    3. Move tiny_mce into /content/libs/extensions/ in Hotaru so you have this: /content/libs/extensions/tiny_mce

    4. Open /content/plugins/submit/templates/submit_step2.php and copy it to /content/themes/YOUR_THEME/ so you have this: /content/themes/YOUR_THEME/submit_step2.php

    5. Open that file and find:

    PHP Code:
    <form name
    6. Immediately before that line, paste this:

    PHP Code:
        <script type="text/javascript" src="<?php echo BASEURL?>libs/extensions/tiny_mce/tiny_mce.js"></script>
        
        <script type="text/javascript">
        tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        theme_advanced_buttons3_add : "fullpage"
        });
        </script>
    7. Save and test. You might need to do a hard refresh on the page.

    That worked for me. You'll want to edit the JavaScript with the TinyMCE code you want to use, and you should also add the code to submit_edit_post.php, too.

    Note: If it doesn't work, view the source of the page and find the line which includes the tiny_mce.js file. Check that link in your browser to see if it can find the file or not.
    Last edited by Nick; 10-31-2009 at 10:30 AM. Reason: moved the javascript before the form, not within it.

  5. #5
    Senior Member
    Join Date
    Sep 2009
    Posts
    449
    Thanks
    169
    Thanked 58 Times in 45 Posts

    Default

    Sorry for the delay in replying. Correct me if I'm wrong but in the following should /content/libs/extensions/ be /libs/extensions/ instead? I can't find any libs folder under /content/ *lost look*

    3. Move tiny_mce into /content/libs/extensions/ in Hotaru so you have this: /content/libs/extensions/tiny_mce
    Last edited by nothingman; 10-30-2009 at 08:36 AM.

  6. #6
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,863
    Blog Entries
    88
    Thanks
    486
    Thanked 810 Times in 529 Posts

    Default

    Quote Originally Posted by nothingman View Post
    should /content/libs/extensions/ be /libs/extensions/ instead?
    Yes. Sorry about that.

  7. #7
    Senior Member
    Join Date
    Sep 2009
    Posts
    449
    Thanks
    169
    Thanked 58 Times in 45 Posts

    Default

    Thanks Nick, it worked.
    But:-
    - Using bold/italic HTML tags don't have any effect on the main post (yes, the HTML tags are enabled - i, b, em, strong etc). As an example, I've enabled the 'embed' and img HTML tags but the video/image won't show up in the main post.
    - When I set the mode in TinyMCE to "exact", TinyMCE won't show up (just curious)

  8. #8
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,863
    Blog Entries
    88
    Thanks
    486
    Thanked 810 Times in 529 Posts

    Default

    Hmm, I can see some of the problems:

    Bold is represented by <strong>, but it doesn't show up because <strong> inherits its font-weight from nowhere in reset-fonts-grids.css (Yahoo's css file included in Hotaru's libs/extensions/YUI-CSS/ folder). I'm pretty weak at CSS so am not sure how you'd fix that. Maybe doing this in your theme's style.css file will help?

    Code:
    strong { font-weight: bold; }
    In my test, italics and underline aren't represented by <i> and <u>, but by <em> and <span style="text-decoration: underline">. I haven't checked, but <em> might need declaring in style.css like <strong> above, i.e.

    Code:
    em { font-style: italic; }
    I'm not sure about the <span> for underline. Maybe you can specify in TinyMCE which code is supposed to represent each button. You'd have to read through the TinyMCE manual for that.

    Finally, I tried an IMG tag and it worked okay for me.

    So to summarize, the solution seems to be:
    1. Tell TinyMCE how to repesent each button, e.g. underline as <u>
    2. Allow those HTML tags to be used in the Submit plugin
    3. Specify the CSS for those tags in your stylesheet, or even better in submit.css, so that it doesn't default to Yahoo's reset CSS. Something like this maybe?

    Code:
    .show_post_content strong { font-weight: bold; }
    .show_post_content em { font-style: italic; }
    One final note. If using summaries on list pages (e.g. "Top Stories" and "Latest"), all tags are stripped to prevent broken tags when the content is truncated. They are not stripped from post pages, though.

  9. #9
    Senior Member
    Join Date
    Sep 2009
    Posts
    449
    Thanks
    169
    Thanked 58 Times in 45 Posts

    Default

    Added the following snippets to style.css and bold/italics work fine. I'm still unable to embed Youtube/videos even after adding 'embed' in the list of allowable HTML tags.
    EDIT: I'm using tinymce in my current swcms site and I've enabled <embed> and the videos show fine. I wonder where I'm going wrong.
    Code:
    strong     { font-weight: bold; }
    em     { font-style: italic; }
    Last edited by nothingman; 10-31-2009 at 02:49 PM.

  10. #10
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,863
    Blog Entries
    88
    Thanks
    486
    Thanked 810 Times in 529 Posts

    Default

    Hotaru uses 3rd party htmLawed together with Inspekt to filter and sanitize HTML and any malicious code. The answer to your problem is probably this:

    http://www.bioinformatics.org/phplab...opic.php?id=91

    If you'd like to experiment, this is what you'll need to play with:

    PHP Code:
    class getHtmLawed extends AccessorAbstract {

       
    /**
        * a function to filter HTML
        *
        * @return string
        */
        
    protected function inspekt($text)
        {
            
    $config = array('safe' => 1);
            
            require_once(
    EXTENSIONS 'htmLawed/htmLawed.php');
            
            if (!
    get_magic_quotes_gpc()) {
                return 
    htmLawed($text$config);
            }
            else 
            {
                return 
    htmLawed(stripslashes($text), $config);
            }
            return 
    false;
       }

    You can find that at the bottom of HotaruInspekt.php in the /libs folder.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Testing on 0.7 SVN branch needed
    By Nick in forum How-To and Troubleshooting
    Replies: 13
    Last Post: 10-10-2009, 08:09 AM
  2. Testers Needed for pre-Alpha Version
    By Nick in forum News and Announcements
    Replies: 2
    Last Post: 07-20-2009, 02:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •