This is a module which might be regarded as a bit odd as it specifically avoids displaying any of the site/theme stuff. I use a Drupal based site as a collection point for a lot of notes and writing which I do, with mailhandler pulling in emails which I send using a Nokia Communicator. As I travel a lot, this is a great way for me to keep all my writing in one place. I wrote this module as a way to extract ALL nodes form the site in a form which can be directly put into a word processor or saved as a PDF document. I'm not a programmer, so it's probably very rough, but I offer it here just in case anyone else is looking for something similar.


# Module to display all the nodes in the site, 

# Standard module help function - how it appears in admin/modules

function everything_help($section) {
  switch($section) {
    case "admin/system/modules#name":
      $output = "everything";
      break;
    case "admin/system/modules#description":
      $output = "Display all the nodes in the system, in a form suitable for printing or moving to a word processor or PDF file.";
      break;
    default:
      $output = "";
      break;
  }
  return $output;
}

# Standard module description function

function everything_system($field){
  $system["name"] = t("Everything");
  $system["description"] = t("Displays all the nodes in the system");
  return $system[$field];
}

# Link the function into the system

function everything_link($type, $node=0) {
  if (($type == "system")) {
    // URL, page title, func called for page content, arg, 1 = don't disp menu
    menu("everything", t("Everything"), "everything_all", 1, 0);
  }
}

function everything_settings() {
   $output = form_select(t("Body font"), "everything_bfont", variable_get("everything_bfont", "Arial, Verdana, Sans-Serif"),drupal_map_assoc(array("Arial, Verdana, Sans-Serif", "Couier New, Courier")), t("Enter name of the font you want to use"));
   $output .= form_select(t("Body font size"), "everything_bfontsize", variable_get("everything_bfontsize", "4"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal"));
   $output .= form_select(t("Title font size"), "everything_tfontsize", variable_get("everything_tfontsize", "6"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal body text"));
   return $output;
}


# The everything function which selects and displays the nodes

function everything_all() {
    $tfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_tfontsize", 0)."\">";
    $bfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_bfontsize", 0)."\">";
    $efontstr = "</font>";
    $page_content = '';
    $query = "SELECT nid, type FROM {node} WHERE status = 1 ORDER BY nid";
    $result = db_query($query);
    while ($node = db_fetch_object($result)) {
      #$page_content .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 0);
      $node = node_load(array('nid' => $node->nid));
      $title = check_output($node->title);
      $body = check_output($node->body);
      $page_content .= "<b>".$tfontstr.$title.$efontstr."</b><br><br>".$bfontstr.$body.$efontstr."<br><br>";   
    }
    #print theme("page", $page_content);
    print $page_content;
    }

Comments

gábor hojtsy’s picture

This is for a very old drupal base, somewhere around 4.4 or even earlier. At least it seems to be, by the hooks it uses...

plato’s picture

Yes, it is for 4.4.x I realised after I posted it that it was rather old. As I said, I did it for my own use, and just posted it in case there was anyone else looking for something similar. I haven't had time to figure out making something like this in 4.5 or 4.6 - I tried for a couple of hours last night but couldn't figure out how to make a module properly in later codebases. As I also said, I'm not a programmer, just an enthusiastic drupal user. Where would I go to find more information and examples of modules in the later codebase?

plato’s picture

This version seems to work fine with the 4.6 release candidate. It puts a link called 'everything' in the admin menu. This creates a single html document containing only titles and body for all the nodes in the system. The fonts and fontsize used in the document can be selected in admin/modules/everything.

# John Clift
# Everything Module 0.2.0, 06 March 2005
# Version for 4.5/4.6 codebase, based on 'head' function book
# Module to display all the nodes in the site, 
# In a form suitable for printing, export to WP or PDF

# Help Hook
function everything_help($section) {
  switch($section) {
    case 'admin/modules#description':
    return t('Display all the nodes in the system, in a form suitable for printing, or moving to a word processor or PDF file.');
    break;
  }
}


# Menu hook
function everything_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array('path' => 'admin/everything', 'title' => t('everything'),
      'callback' => 'everything_all',
      'access' => user_access('access administration pages')); 
  }
  return $items;
}

# Allow settings to be selected in the admin section
function everything_settings() {
   $output = form_select(t("Body font"), "everything_bfont", variable_get("everything_bfont", "Arial, Verdana, Sans-Serif"),drupal_map_assoc(array("Arial, Verdana, Sans-Serif", "Couier New, Courier")), t("Enter name of the font you want to use"));
   $output .= form_select(t("Body font size"), "everything_bfontsize", variable_get("everything_bfontsize", "4"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal"));
   $output .= form_select(t("Title font size"), "everything_tfontsize", variable_get("everything_tfontsize", "6"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal body text"));
   return $output;
}


# The everything_all function which selects and displays the nodes
function everything_all() {
    $tfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_tfontsize", 0)."\">";
    $bfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_bfontsize", 0)."\">";
    $efontstr = "</font>";
    $page_content = '';
    $query = "SELECT nid, type FROM {node} WHERE status = 1 ORDER BY nid";
    $result = db_query($query);
    while ($node = db_fetch_object($result)) {
      #$page_content .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 0);
      $node = node_load(array('nid' => $node->nid));
      $title = check_output($node->title);
      $body = check_output($node->body);
      $page_content .= "<b>".$tfontstr.$title.$efontstr."</b><br><br>".$bfontstr.$body.$efontstr."<br><br>";   
    }
    #print theme('page', $page_content);
    print $page_content;
    }