 |
|
Tuesday, July 1. 2008
After spending some time trying to figure out how I could move the 'My Account' menu link from the Navigation Menu within Drupal I soon came to realize that it wasn't budging.
After digging around for some solutions I came across the 'me' Aliases module. I must say, although simply in nature, its a nifty little utility module.
The way that it works is that where ever you place an me within the Path field for menu item the me will reference back to the current users uid.
Example: John Doe has a uid of 30.
In order for John to get to his account to manage his information he must go to:
http://domain.com/user/30 (without the me aliases module)
http://domain.com/user/me (with the me aliases module)
Here is a screen shot of what it will look like when you add a menu item using the module.
For additional information about this module or to download it, please visit Me Aliases Module.
Friday, June 13. 2008
Yahoo!'s Term Extraction Service can be used to extract significant words or phrases from some larger body of text. There are many uses for it, not the least of which is providing keywords, or tags in Web2.0 jargon, to help classify and organize a library of content. The following PHP script uses will use the Term Extraction service to analyze a PDF file. With a little more work, it could be expanded to work with Microsoft Word, Excel, and Powerpoint files. Extracting keywords automatically would be a helpful feature to build into your blog or CMS. There are modules to extract keywords for Drupal and Wordpress.
1:<?php
2:// discover where pdftotext tool is
3:$catpdf = trim(`which pdftotext`);
4:
5:// the PDF file to analyze
6:$source = 'http://example.com/my_file.pdf';
7:
8:// will copy file to a local temporary file
9:$temp_pdf_file = tempnam(sys_get_temp_dir(), "ek");
10:
11:// see below
12:download_file($source, $temp_pdf_file);
13:
14:// save text contents of pdf source to another temp file
15:$extract_file = tempnam(sys_get_temp_dir(), "ek");
16:exec($catpdf . ' ' . escapeshellarg($temp_pdf_file) . ' ' . escapeshellarg($extract_file));
17:
18:// fetch and output terms
19:$contents = file_get_contents($extract_file);
20:if ($terms = get_yahoo_terms($contents))
21:{
22: echo "\nYahoo terms for the file $source";
23: foreach ($terms as $term)
24: {
25: echo "\n$term";
26: }
27: echo "\n";
28:}
29:
30:// hide our footsteps
31:unlink($temp_pdf_file);
32:unlink($extract_file);
33:
34:/**
35: * Uses curl to copy $source to a local file $dest
36: * @param string
37: * @param string
38: */
39:function download_file($source, $dest)
40:{
41: $out = fopen($dest, 'wb');
42:
43: $ch = curl_init();
44:
45: curl_setopt($ch, CURLOPT_FILE, $out);
46: curl_setopt($ch, CURLOPT_HEADER, 0);
47: curl_setopt($ch, CURLOPT_URL, $source);
48:
49: curl_exec($ch);
50:
51: curl_close($ch);
52:}
53:
54:/**
55: * Uses curl to query yahoo term extraction service for meaninful terms
56: * @param string
57: * @return mixed, array on success or null on failure
58: */
59:function get_yahoo_terms($content)
60:{
61: $SERVICE_URL = 'http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction';
62: $app_id = 'F1_Testing';
63:
64: $ch = curl_init();
65: curl_setopt($ch, CURLOPT_URL, $SERVICE_URL);
66: curl_setopt($ch, CURLOPT_POST, 3);
67: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
68:
69: curl_setopt( $ch, CURLOPT_POSTFIELDS, 'appid=' . $app_id . '&context=' . urlencode($content) . '&output=php');
70: $raw = curl_exec($ch);
71: curl_close($ch);
72:
73: if ($raw = unserialize($raw))
74: {
75: if (isset($raw['ResultSet']['Result']))
76: {
77: return $raw['ResultSet']['Result'];
78: }
79: }
80:}
81:?>
As a sample of what to expect, I used the script to look at Calculating CARMA: Global Estimation of CO2 Emissions from the Power Sector - Working Paper 145 and the list of terms returned is below. The list of words is fairly accurate, and even includes the name of one of the authors.
global estimation
geographical scales
carbon emissions
co2 emissions
global citizens
global poverty
david wheeler
rigorous research
power plants
power sector
fossil energy
poverty and inequality
solar wind
energy sources
monitoring system
keystrokes
groundwork
strengths and weaknesses
carbon dioxide
aggregation
Wednesday, May 21. 2008
I have a couple of projects that call for node content to be published outside of the normal center-of-the-page boundary. But the default template override system accounts for individual nodes, or even overriding the node display area for a given content type, but not the whole page. A Google search turned up some possibilities, but based on this page, I was able to find the right answer for Drupal 5.x, in templates.php: <?php function phptemplate_variables($hook, $vars = array()) {
switch ($hook) { case 'page':
if ('node' == arg(0)) { $vars['template_files'] = 'page' . $vars['node']->type; }
break; } return $vars; }
?>
This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page_event.tpl.php. Dunno why this isn't part of the default theme system, but maybe it's an un-Drupal thing to want to do.
Monday, May 19. 2008
We've been using Drupal more and more here at Forum One. One of its nicer aspects is a web interface to some functionality we had for programmers in SyntaxCMS: the ability to set up a "view" of a content type, so that you only got, say, all blog posts tagged with "Environment." This is pretty powerful; it lets a savvy Internet user with no specific programming skills to set up lots of functionality by clicking a few widgets. One such user asked me what I thought was an odd question: "Any idea why one of my terms for the issue taxonomy isn't showing up in filter for a view?" I checked, and sure enough, the first term was missing. It happened to be the longest term, and I immediately hypothesized some sort of character limit. So I tested it by shortening the term. No joy. I then wondered if there were any illegal words, so I tried eliminating "and" from the term. Still nothing. I began to suspect it something about the position or some permission around the term. I deleted and re-added the term. Still nothing. At this point I tried adding a term that came alphabetically before the missing term. Success! All but the new term showed up. But now I had an extraneous term hanging around. Having eliminated configuration errors as a cause, I went to the Views module page, and made sure I had the latest released version for the version of Drupal I was using (5.7) (We make it a policy never to rely on beta or dev versions). I did (1.6 as of this writing). So I started looking at the bug list to find out if anyone had reported this issue--it certainly seemed big enough that someone ought to have noticed. Lo and behold, I found this bug. Turns out it had been discovered in beta testing and a patch applied. But I was using the latest release version...reading further, I found out a change in the taxonomy module itself had obsoleted the fix and a new patch issued, tested, and committed to CVS. It is in the 1.7 pre-release versions, but as I mentioned before, we don't use pre-release software if any alternative is available. However, knowing the patch is applied in the next version siginificantly reduces the effects of applying the patch now. So now I have the patch applied and committed to my local repository for the site. So if you're having problems with disappearing taxonomy terms when building out a view, the patch above should fix it for you for Drupal 5.7 and Views 1.6.
Tuesday, October 9. 2007
Toby Ward makes a compelling argument to not worry about the graphic design of your intranet. Often, the first solid, easy to grasp version of any website will be the graphic design. Its the first one people really get, even if you've led them through paper protoypes, wireframes, or very rough html mock ups. But its dangerous and counter-productive to make design high priority because on an intranet, users are very focused on performing a task, like finding a document or filling out an expense report. Too many images, video, bells and whistles will both distract and slow the downloading and rendering of the page. It all comes back to knowing your site's audience, understanding why they come to the site, and building the site to suit them. Read Toby Ward's article for a complete list of the issues that should be considered.
That’s not to say that design (look-and-feel) doesn’t play a roll and isn’t important to users. Design is important, but it doesn’t crack the top 6 or 7 priorities. On average, based on my experience working with dozens of intranet clients, design is equivalent to between 8 – 12% of the total intranet’s value. What is really important is content (20-30%), search (15-20%), information architecture (20-30%), and governance and planning (20-30%).
Wednesday, October 3. 2007
In the beginning, there were static web pages.
The geek masses cheered at the ability to put information on the web for everyone to see. More and more web pages were built, and with that, a myriad of useless information also began to pile. Search engines started emerging, with the aim of filtering valuable information from the heaps of useless data.
Then, websites started getting progressively more dynamic. Geeks wanted to jump-start their websites by allowing others to interact and participate. The average Joe wanted to be able to have a web presence and express themselves without needing to know HTML or other coding languages. The raw data kept piling.
Sometime in 2001, Jimmy Wales decided to launch a community emphasizing user contributions of structured, meaningful information. Wikipedia users classify their articles, sanity-check other articles, and relate their article to any other articles. Instead of searching through piles of articles, why not get users to incrementally improve each other's articles?
Every Wikipedia article starts off on the same page, no pun intended. To distinguish between different article types, template code is added into the article. If you wanted to add the current population for the "Roanoke, VA" article, you'd have to manually edit the "InfoBox" tag within the article's wiki source. More importantly, since the data is so loosely structured, there's no easy way to pinpoint other cities with a population similar to that of Roanoke, VA.
When information is ideally structured, much of the burden is taken off the search engine. Freebase aims at cauking Wikipedia's flaw by adding numerous "facets" to the search, as well as keeping the data in concise blocks in the database. Freebase claims to allow for deeper searches than ever possible before. Whereas Wikipedia's data structure is mainly fixed, Freebase has what is called an "Open Contribution Model". This means not only that different content types physically exist (without the META-ness) for different articles, but also that users can CREATE new content types, essentially extending the database structure. This concept of a dynamic database is something that has been virtually untapped until now.
Also, Freebase allows users to upload entire data sets, not just individual articles. Suppose I wanted to create a content type for "Squirrels who survived a rattlesnake attack", I would add fields like "Name, Animal type, Location, and Date". "Animal type" could automatically look-up the squirrel's scientific info from a separate content type, "Location" could either pull up other squirrels bitten at this location or the geographic/demographic details of this location, etc. The possibilities are limitless. Oh yeah, and there's an API and even a Query Editor, too.
To show how unbiased this database structure really is, try out this FilmSpin example. Even though it only uses 2 content types, it sleekly shows how meaningful those relationships can be among varying content types. Freebase is still in alpha, and shows great potential of taking the buzz away from Wikipedia and other sector rivals.
|
|
Comments
Tue, 01.07.2008 11:30
Dan, You are absolutely correct and I should have stated this within my post; the described steps within the post [...]
Mon, 30.06.2008 09:45
i wouldnt recomand this at all, because if something happens and the conection is lost u will have your data lost if the [...]
Mon, 09.06.2008 13:42
PDT syntax highlighting support does not seem to work when subclipse is installed, any one else had this problem?
Mon, 09.06.2008 11:56
I didn't mean to imply that you were bashing unit tests.
Mon, 09.06.2008 11:52
My point isn't to bash unit tests, but rather to say there are a bunch of things you should be doing before you get [...]
Mon, 09.06.2008 11:43
I agree with, what I think is, the gist of your argument. That is, if you don't write code that anticipates failure, [...]
Mon, 09.06.2008 08:58
clipse is an open source IDE — or as they put it themselves: “universal toolset for development”. It [...]
Tue, 27.05.2008 12:17
Navigation links should fill their container to ensure ease of selection. A good method for that is to make them [...]
Thu, 22.05.2008 10:35
One of the better comments I've seen in a while: "Although I like PHP, I agree the language is only as good as the [...]
Tue, 20.05.2008 14:03
Oscar, Yahoo's Term Extraction service takes an entire article and returns a few of (what it thinks are) the most [...]
Tue, 20.05.2008 13:13
Hi, Tom Tague from Calais here. First, thanks for taking note of Calais. And integrating an example right within the [...]
Tue, 20.05.2008 13:03
How does this compare to Yahoo!'s Term Extraction Service?
Thu, 15.05.2008 14:37
I rounded up useful links over on the Forum One Tech blog: Getting your Organization on Facebook
Mon, 21.04.2008 13:43
Hi Vikram-- Have you set up your repository in Subversive and successfully connected?
Mon, 21.04.2008 12:56
On checkout as.. dialog you asked to choose "Check out as a project configured using the New Project Wizard." That [...]