This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

weather.module hacked to use rssweather.com

As a great fan of the weather module, I was sad to see it continually fail as weatherroom.com failed...

I have updated the module code to use rssweather.com.

Someone with greater xml parsing skills may be able to do a more beautiful job.

Long live regular expressions!!

The main change between the two feeds, is that rssweather.com provides the data in a 'content:encoded' tag. I had to use regular expressions to extract the relevant information from the data as such:


case "CONTENT:ENCODED":
$stuff = preg_replace("/(.*)\

(.*)/i", "$1$2", $data);
while (preg_match("/(.*)\<[^>]+\>(.*)/i", $stuff)) {
$stuff = preg_replace("/(.*)\<[^>]+\>(.*)/i", "$1$2", $stuff);
}
if (strpos($data, "humidity")) {
$this->weather["humidity"] = $stuff;
} else if (strpos($data, "windspeed")) {
$this->weather["wind"] = $this->weather["wind"] . $stuff;
} else if (strpos($data, "winddir")) {
$this->weather["wind"] = $stuff . $this->weather["wind"];
} else if (strpos($data, "pressure")) {
$this->weather["barometer"] = $stuff;
} else if (strpos($data, "dewpoint")) {
$this->weather["dewpoint"] = $stuff;
} else if (strpos($data, "heatindex")) {

Extendable search module

I was wondering if it would be possible the create a search module that can be extended with 'plugins', to allow searches from other search-engines to be included in the results (Google, Yahoo, Phone directories, e-mail searchers, whois, ...)? The point would be to give visistors of a site the possibility to search for people on the internet, but still provide the flexibility to use the module as a simple search engine for either the site only, or the net.

Is it technicly possible?

Everything Module

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;
    }

weblink.module patch - view all weblinks

Just an FYI - there was a Feature request for a feature to the weblink.module - to view all weblinks on one page.

I created a patch for this - details:

http://drupal.org/node/14653#comment-23205

Please note, no pager() support is embedded in this patch - which may be an issue for sites with huge weblinks listings.

For drupal HEAD: Display whether a user is online or not on the user profile page (solution)

Hey everyone,

I heard a few people asking about how to display whether a user is online or not on any user profile display page. Well, here is a version for drupal cvs HEAD (should work with 4.5.2) which allows you to do it!

You can download it from
http://www.jordanwillms.com/index.php?p=27

Cheers!

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions