We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24530
    • 100 Posts
    Hi!
    The only thing I really don´t like with TinyMCE is the bad integration of internal links ... I will try to improve it, but my knowledge about TinyMCE is really limited - therefore I want to ask for your oppinion first.

    What I want to do:

    Limit the link list to documents with a specific parent id
    this is not too hard - I just have to modify line 39 of assets/plugins/tinymce2111/tinymce.linklist.php
    from
    WHERE sc.published=1 AND sc.deleted=0

    to
    WHERE sc.published=1 AND sc.deleted=0 AND sc.parent=0


    But there are two problems: it is hardcoded, and doesn´t show the child documents.

    show child documents
    There is the need to configure the id and the depth. In order to show the child-documents, the cleanest solution would be to do it in the SQL-Query ... something like
    $sql = "SELECT DISTINCT $fields FROM $tblsc sc
      LEFT JOIN $tbldg dg on dg.document = sc.id
      WHERE sc.published=1 AND sc.deleted=0 AND sc.parent IN
      ( SELECT DISTINCT $fields FROM $tblsc sc
        LEFT JOIN $tbldg dg on dg.document = sc.id
        WHERE sc.published=1 AND sc.deleted=0 AND sc.parent=0
        ORDER BY $sort $dir )
      ORDER BY $sort $dir;";

    But this just covers direct child documents, and not the possibility to choose a depth of n levels. Is there a possibility to solve it within the SQL-Query, or do I have to loop it in PHP?

    defining config-settings for the new linklist
    This is an easy one - just add "&tinyLinkListParent=parent ID for link list;int;0 &tinyLinkListDepth=depth of link list;int;0" to the configuration settings field of the plugin
    &tinyFormats=Block Formats;text;p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address &entity_encoding=Entity Encoding;list;named,numeric,raw;named &entities=Entities;text; &tinyPathOptions=Path Options;list;rootrelative,docrelative,fullpathurl;docrelative &tinyCleanup=Cleanup;list;enabled,disabled;enabled &tinyResizing=Advanced Resizing;list;true,false;false &advimage_styles=Advanced Image Styles;text; &advlink_styles=Advanced Link Styles;text; &disabledButtons=Disabled Buttons;text; &tinyLinkList=Link List;list;enabled,disabled;enabled &tinyLinkListParent=parent ID for link list;int;0 &tinyLinkListDepth=depth of link list;int;0 &webtheme=Web Theme;list;simple,advanced,editor,custom;simple &webPlugins=Web Plugins;text;style,advimage,advlink,searchreplace,print,contextmenu,paste,fullscreen,nonbreaking,xhtmlxtras,visualchars,media &webButtons1=Web Buttons 1;text;undo,redo,selectall,separator,pastetext,pasteword,separator,search,replace,separator,nonbreaking,hr,charmap,separator,image,link,unlink,anchor,media,separator,cleanup,removeformat,separator,fullscreen,print,code,help &webButtons2=Web Buttons 2;text;bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect,separator,styleprops &webButtons3=Web Buttons 3;text; &webButtons4=Web Buttons 4;text; &webAlign=Web Toolbar Alignment;list;ltr,rtl;ltr       


    and add "$tinyLinkListParent, $tinyLinkListDepth" to line 37 of the plugincode (assets/plugins/tinymce2111/plugin.tinymce.php)
    $html = getTinyMCEScript($elementList,$webtheme,$width,$height,$tinymce_language,$frontend,$base_url, $webPlugins, $webButtons1, $webButtons2, $webButtons3, $webButtons4, $disabledButtons, $tinyFormats, $entity_encoding, $entities, $tinyPathOptions, $tinyCleanup, $tinyResizing, $modx->config['editor_css_path'], $modx->config['tinymce_css_selectors'], $modx->config['use_browser'], $webAlign, null, null, $tinyLinkList, $tinyLinkListParent, $tinyLinkListDepth);


    and add "$tinyLinkListParent, $tinyLinkListDepth" to line 89 of assets/plugins/tinymce2111/tinymce.functions.php
    function getTinyMCEScript($elmList, $theme='simple', $width, $height, $language='en', $frontend, $base_url, $plugins, $buttons1, $buttons2, $buttons3, $buttons4, $disabledButtons, $blockFormats, $entity_encoding, $entities, $pathoptions, $cleanup, $resizing, $css_path, $css_selectors, $use_browser, $toolbar_align, $advimage_styles, $advlink_styles, $linklist, $linklistParent, $linklistDepth)


    passing variables within tinyMCE
    ... but I get stuck in line 158 of assets/plugins/tinymce2111/tinymce.functions.php
    $tinymceInit .= ($linklist == 'enabled') ? "		  external_link_list_url : \"".$base_url."assets/plugins/tinymce2111/tinymce.linklist.php\",\n" : "";

    how can I pass $linklistParent and $linklistDepth to tinymce.linklist.php?



    I hope, with your help, these problems are solved soon ...
    There are two other things I would love to see within TinyMCE, but I don´t really know how to accomplish it:
    - multiple link lists with separate parent-id´s (one for the documents of the support area, one with blog documents etc)
    - a dropdownmenu in the "edit/insert link" window to choose custom rel="" atributes (for example lightbox)
    maybee you also have an idea for this ...

    Hope it works soon,
    Tobias
      my newest webpage [url=http://gitarren.zucali.at]Meisterwerkstatt f
      • 4018
      • 1,131 Posts
      Interesting idea. Haven’t thought of this. I’ll play with this and see if I can come up with a solution. smiley

      Jeff
        Jeff Whitfield

        "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
        • 1828
        • 137 Posts
        It would be fantastic if the link list was like a simple, mini doc-tree with expandable ’nodes’ (containers). smiley
          • 24530
          • 100 Posts
          A doc-tree with expandable ’nodes’ will not be too easy to do. At least for me - because it has to be fully integrated in tinyMCE. But it would be the perfect solution ...
          In my case I would still need the capability to reduce the options to one folder, because I would like to limit the options for the customer.

          I will try to realize the linklist as described, at least to learn how tinyMCE works ... BUT: I am happy about each suggestion and idea how to improve the linklist even more.
            my newest webpage [url=http://gitarren.zucali.at]Meisterwerkstatt f
            • 21056
            • 327 Posts
            I posted some code a while ago:

            http://modxcms.com/forums/index.php/topic,15537.0.html

            which changes the display of the link list to match the structure of the document tree. It doesn’t have collapsable nodes, but is a good immediate compromise. No source hacking required.
              Author: ManagerManager plugin - customise your ModX manager interface

              Rckt - web development, Sheffield, UK
              • 309
              • 24 Posts
              This is not really on the same topic, but I just wanted to thank you because reading this post help me realize there was an easy way to solve my problem. I wanted to hide certain pages from the link list to prevent people from linking to them.

              After reading the first post here I discovered how easy this is.

              Original code:
              WHERE sc.published=1 AND sc.deleted=0


              I added sc.searchable=1

              Updated:
              WHERE sc.published=1 AND sc.deleted=0 AND sc.searchable=1
              
              


              I usually uncheck the "searchable" field for files in development or things I don’t want people going to, so this is a perfect solution for me.
                • 1828
                • 137 Posts
                Have there been any further developments with improving the link list? E.g., an expandable tree type list, or the ability to select a link target by simply clicking an item in the main doc tree?