*** INSTALLATION ***

1. Enable the module
2. Enable the Content Browser filter.
3. Enable the Content Browser WYSIWYG plugin (only support for TinyMCE at the moment)
4. Select insertable content types at admin/settings/contentbrowser
5. Enable the two blocks if you want to (read about them in the next section)

*** THE BLOCKS ***
Content Browser related data:
  This block is visible (if enabled) on nodes which have inserted content. ie) Node X is using Node Y.
  
Content Browser used by:
  This block is visible (if enabled) on nodes which is inserted into other nodes.
  ie) Node X is used by Node Y.


*** BUILDING YOUR OWN TEMPLATE FOR YOUR CONTENT TYPE ***

1. Create a file in your theme directory with the name content-CONTENTTYPE.tpl.php
2. Flush the theme registry.
3. Your template is assigned the following variables:
   $node - The node object
   $tag - The decoded tag.
   $from_editor - If TRUE we are withing the scope of the editor. Javascript etc shouldnt be rendered.
   $caption_data - Array with extra fields.
   
   A <?php print "<pre>" . print_r($variable, true) . "</pre>"; ?> is recommended on $tag and $caption_data to
   se exactly what it contains. Look in the example_templates directory.
4. All done.


*** FOR DEVELOPERS / EXTENDING CONTENTBROWSER ***

- Hooks / alters invoked
  contentbrowser_alter_node(&$node):
    Triggered by the used_by_nodes block.
  
  contentbrowser_used_by_node($node, $nids):
    Triggers when a node is about to be saved. Add more nids to $nids if they should turn up as 'used by' $node.
  
  contentbrowser_extra_fields():
    Adds support for 3rd party modules to add fields to Content Browser. In example, you have implemented
    a module which as a field Y to nodes. On nodes inserted by CB you want in to be displayed in the
    caption you need to implemented this hook. Example:
  
      function mymodule_contentbrowser_extra_fields() {
        return array(
          'mymodule_field' => array('name' => 'My Field', 'callback' => 'momodule_render_myfield', 'field' => 'mymodule_field');
        );
      }
  
  contentbrowser_alter_query(&$query = String, &$joins = Array, &$where = Array):
    Makes it possible to alter the search query.

  drupal_alter('contentbrowser_inserted_nodes', $rows, $nid);
  drupal_alter('contentbrowser_insertion_types', $available);

Question: I need to add insertions / I want to remove a insertion type X. How?
Answer: Implement contentbrowser_insertion_types_alter(&$insertions). Then you have to enable it in the settings and implement how it should be handled in the template.


Question: I need to extend the tags with field foobar, how?
Answer: You need to implement contentbrowser_available_attributes_alter(&$attributes) and hook_form_alter(). The form_id which needs to be altered is "contentbrowser_get_details_form".
NOTE! The form-element needs the class 'postable'.

  Example - add the attribute "coolness":
  //Let contentbrowser know of our new attribute "coolness"
  function mymodule_contentbrowser_available_attributes_alter(&$attributes) {
    $attributes[] = 'coolness';
  }

  function mymodyle_form_alter(&$form, &$form_state, $form_id)) {
    if($form_id == 'contentbrowser_get_details_form') {
      $form['coolness'] = array(
        '#type' => 'textfield',
        '#title' => t('How cool is this?),
        '#default_value' => $form['#tag]['coolness];
        '#attributes' => array('class' => 'postable'), //Class postable needs to be set, else it wont be posted in the form
        );
      }
    }
  }
  
  After this the new attribute 'coolness' will be available in the $tag variable in the templates.

