DRUPAL NODE PICKER PLUGIN FOR TINYMCE - Jonathan Yankovich - 7/29/09

-- REQUIREMENTS --

* Javascript-enabled web browser

* Views module <http://drupal.org/project/views>

* WYSIWYG module  <http://drupal.org/project/location>

* TinyMCE editor for drupal wysiwig module <http://tinymce.moxiecode.com/download.php>

* Read all the directions, there are a lot.


-- PRE-REQUISITES --

  - Install the required modules, above.
  
  - You can download the TinyMCE editor from the Site Configuration -> Wysiwyg

  - You're going to want to install tinymce into sites/all/libraries, a new folder that you'll create
  
  - If this is the first time you're installing tinymce, you'll have to set the profiles for the input
    types (full html, filtered html) to tinymce so thee editor will be used when you edit content.
    Wysiwyg's config screen will let you do this at admin/settings/wysiwyg
    
  - Test your editor to make sure tinymce is working before installing the plugin! You can do this at
    node/add/story or node/add/page in a default drupal install
    
  - Enable the Inline Popups plugin under admin/settings/wysiwyg/profile/1/edit
  
  - IF YOUR DRUPAL SITE IS NOT INSTALLED AT THE ROOT OF YOUR SERVER (/), YOU HAVE TO
    EDIT LINE 35 OF tinymce_link_picker/linkpicker/editor_plugin.js (line 35)
    See instructions in the source lines 31-35.
    

-- INSTALLATION --

The installation consists of 2 parts: The drupal module and theme files, and the tinymce button plugin.

-- TINYMCE NODE PICKER DRUPAL MODULE INSTALLATION --

* Place the entire tinymce_node_picker directory into a modules directory of your
  choice, in most cases: sites/all/modules.

* Enable the TinyMCE Node Picker module by navigating to:

  Administer > Site building > Modules

* The module is now enabled and drupal will display the node picker to editor
  but the editor needs to be made aware of the button.

* The views that the theme displays need to me themed.  From the theme directory, copy:

	page-tinymce_linkpicker_search.tpl.php
	page-tinymce_linkpicker.tpl.php
	
into your site's theme directory.

	(Note: the requirement to manually copy these theme templates will be removed
	 if the author can determine how to tell drupal to include them.  If you know,
	 please email me below!)
	
	
-- TINYMCE NODE PICKER BUTTON PLUGIN INSTALLATION --

You must install the drupal node picking button in TinyMCE so the editor will
display a button to display the node picker.

  - IF YOUR DRUPAL SITE IS NOT INSTALLED AT THE ROOT OF YOUR SERVER (/), YOU HAVE TO
    EDIT LINE 35 OF tinymce_link_picker/linkpicker/editor_plugin.js (line 35)
    See instructions in the source lines 31-35.
 
* Move or copy the folder 'linkpicker' in the tinymce_node_picker directory to

  [sites/all/]libraries/tinymce/jscripts/tiny_mce/plugins/linkpicker

or 

(in some cases the correct path might be 

	 [sites/all/]modules/tinymce/tinymce/jscripts/tiny_mce/plugins/
)
   
  Edit the file plugin_reg.php in the tinymce directory. It's located in:

  [sites/all/]/modules/wysiwyg/editors/tinymce.inc

  Add the following section of code anywhere above the 'return' statement (without the
  <code> tags):
<code>

   $plugins['linkpicker'] = array(
      'path' => $editor['library path'] .'/plugins/linkpicker',
      'buttons' => array('linkpicker' => t('Drupal Link Picker')),
      'url' => 'http://drupal.org/node/534856',
      'internal' => TRUE,
      'load' => TRUE,
    );  
      
</code>

I put it after the "safari" plugin around line 578 and the end of my file looked like this:
line 570 of 
    $plugins['safari'] = array(
      'path' => $editor['library path'] . '/plugins/safari',
      'extensions' => array('safari' => t('Safari compatibility')),
      'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',
      'internal' => TRUE,
      'load' => TRUE,
    );
  }


   $plugins['linkpicker'] = array(
      'path' => $editor['library path'] .'/plugins/linkpicker',
      'buttons' => array('linkpicker' => t('Drupal Link Picker')),
      'url' => 'http://drupal.org/node/534856',
      'internal' => TRUE,
      'load' => TRUE,
    );  

  return $plugins;
}


* Next, go to

  Administer > Site configuration > WYSIWYG and edit the profiles that use TinyMCE
  (admin/settings/wysiwyg/profile/1/edit)
  
  - Enable the the Drupal Link Picker under "Buttons and plugins" for each TinyMCE profile.
  - Also the Inline Popups plugin
  - Save the configuration.

* Test the link picker by going to create a new node for a content type that uses TinyMCE,
  under Content -> Create Content -> Page, for example (node/add/page)
	
-- AUTHOR --

Created by Jonathan Yankovich http://tronathan.com http://bucketworks.org
Sponsored by Bucketworks.org

