Big news! At long last, the DP has launched it’s first public web site on Drupal at http://34st.com for our weekly arts and entertainment magazine, 34th Street. We’ve been working on developing an alternative to College Publisher since I started my term as Web Editor-in-Chief at The Daily Pennsylvanian in January. After months of waffling and pressure we decided to move ahead with development and committed to launching a new website. And finally, we’re here.

Theming with Zen

Last time, I wrote about the data structure underlying our website running on Drupal and promised that I would write again about theming.

The Drupal theming layer is quite powerful, but can also quickly become incredibly complex. It also depends on module developers to play nicely and make all their code easily themable. It also requires a designer to learn how to work with Drupal and all it’s eccentricities.

Drupal themes depend on layers of overrides and hooks. Drupal core provides a default layout, which can then be modified by modules, then the template engine, then the theme and finally an optional subtheme. At each layer the previous output can be modified or overridden. That way, if someone were designing a set of themes or wanted to present options for a user to customize the site’s look and feel it could degrade gracefully.

Since we weren’t worrying about any of those things, we did nearly everything in the top-most sub-theme layer.


Luckily for us the Zen starter theme makes much of this easier.

To develop our theme, we were lucky enough to have a great starting point in the amazing Zen starter template and it’s great documentation. We made a Zen subtheme as a folder within Zen with their Starter Kit.

Note: One big mistake I made when we started working on our subtheme was naming it “34st”. As it turns out, many of the theme override functions require you to name them THEMENAME_functionname. Unfortunately, PHP variables can’t start with numbers so after some frustration and griping I had to rename the subtheme.

node-type.tpl.php

Content Templates provides a view of all available variables and example values.

Many places advise themers to use the Content Templates module to theme different content types. With Zen however, I found it much easier to just create files in the sub-template directory with certain naming conventions. For our article content type, a file named node-article.tpl.php themes it. For an issue, node-issue.tpl.php contains the theme. Since these files are theming a node, it’s possible to see all the variables in the array by simply doing a <?php print_r($node); ?> in a human-readable format. Content Templates, however can do the same thing, and with a much nicer interface.

For the most part, after finding all the appropriate variables, we simply plopped them into the appropriate places in the template. But, within these template files, we still have complete access to PHP and the entire Drupal API. Which of course means that I get lazy.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php 
//Covering all the different numbers of bylines
if (($node->field_byline[0]['view'] != '') && ($node->field_byline[1]['view'] == '')): ?>
<div class="article-byline">
	<div class="author-teaser-name-nodelink">By <?php print $node->field_byline[0]['view'] ?></div>
</div>
<?php elseif (($node->field_byline[0]['view'] != '') && ($node->field_byline[1]['view'] != '') && ($node->field_byline[2]['view'] == '')): ?>
<div class="article-byline">
	<div class="author-teaser-name-nodelink">By <?php print $node->field_byline[0]['view'] . ' and ' . $node->field_byline[1]['view']; ?></div>
</div>
<?php elseif (($node->field_byline[0]['view'] != '') && ($node->field_byline[1]['view'] != '') && ($node->field_byline[2]['view'] != '')): ?>
<div class="article-byline">
	<div class="author-teaser-name-nodelink">By <?php 
	$numauthors = count($node->field_byline);
	print $node->field_byline[0]['view'];
	for ($i=0;$i<$numauthors-1;$i++) {
		print ', ' . $node->field_byline[$i]['view']; 
	}
	print ' and ' . $node->field_byline[$numauthors-1]['view'];
	?>
	</div>
</div>
<?php endif; ?>

That’s my code for handling all the different possibilities for multiple authors on a single article. For more elegant code, this should be higher up in the templating than the .tpl.php file, but it’s much easier this way.

Teaser versus Full views
For each field, one chooses how it will be displayed in the teaser, and in the full node.

For each field, one chooses how it will be displayed in the teaser, and in the full node.

For each field in a content type, you can choose two ways of displaying it. The Teaser is used when the node is being viewed on the front page, or in a section listing, and Full is the whole article is being read. Pretty self-explanatory. But it does mean that in each .tpl.php file you have to theme both. Here’s a sample.

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php 
if (($teaser) && (!$page)): 
	/*
	 * This case governs how articles show up in section page views, in the nodereferrer on authors,
	 * and everywhere else an article teaser (not on the front) is shown.
	 *
	 */
elseif (($page) && (!$teaser)):
	/*
	 * This case is for displaying the whole article on its own page.
	 *
	 */
endif; ?>

We also get other fun template variables like $is_front so we can do things like so.

1
2
3
4
5
6
7
elseif ((($teaser) && (!$page) && ($is_front)) || (($page) && ($teaser))):
	/*
	 * This first case is for articles that are on the front page or in the sidebar.
	 * articles in the current issue. The second half of the OR only happens when node_view is
	 * manually called like node_view($node_object,$page=TRUE,$teaser=TRUE);
	 *
	 */

For reference, here’s the three different views of a single article.

if ((($teaser) && (!$page) && ($is_front)) || (($page) && ($teaser))):

if ((($teaser) && (!$page) && ($is_front)) || (($page) && ($teaser))):

if (($teaser) && (!$page)):

if (($teaser) && (!$page)):

if (($page) && (!$teaser)):

if (($page) && (!$teaser)):

Importing Data

We received our archives from College Publisher as a set of CSV files. My next post will address how we imported those archives.

What did you think of this post? Got more questions about our Drupal install? Leave a comment. The new website is 34th Street Magazine, poke around and leave us some feedback!

How we did it in Drupal, Part 2 of X
  1. How we did it in Drupal, Pt. 1 of X - The Data Structure
  2. How we did it in Drupal, Pt. 2 of X - Theming with Zen

Joshua Benton of the Nieman Journalism Lab at Harvard just coined a new term, ““Holovaty’s Law”, that I really like. Well, I believe he coined it because Google turns up no results for “Holovaty’s Law”.

The post linked as Holovaty’s Law, by the way, is a classic. If you haven’t read it and you’re interested in news and journalism at all, you need to.

Let me take the concept and run a little further with it. And thanks to Benton, the law already has it’s first corollary!

Theorem: Holovaty’s (First) Law of Online News
Adding structure to information makes it more valuable
1st Corollary
Adding structure to comments generates interesting data

Thoughts? Refinements? Other corollaries?

It seems like there’s a dearth of math geeks interested in journalism. Searches for “law of online news”, “fundamental theorem of online news”, “fundamental theorem of online journalism”, and “law of online journalism” all turn up nothing.


I wrote before about the new 34th Street Magazine website being in Alpha.

This is the first post of a series on what we did to Drupal to make it behave the way we want it to, how we implemented different features and to ask for feedback and advice on how to do future features.

To start out understanding Drupal, it’s important to understand that Drupal was designed and the developer’s focus is largely on creating flexible websites for communities, NOT for publishing or blogging. For instance, there isn’t a natural distinction between readers and administrators among the user roles. (Adding content is at node/add/* not admin/*) A lot of the work involved in setting up a site on Drupal is to work around the default values and settings and make it behave the way you want to.

Part of the joy of using Wordpress is that it’s defined for a very specific purpose and all the development work that goes into it is designed to make it easier to blog. With Wordpress, it takes very little work to go from a default install to writing your first post.

That’s not true for Drupal. No one would use Drupal with only its core functionality and the default settings. But with a little work, it becomes much, much more powerful and better suited for publishing a news website than Wordpress.

The problem I’m still struggling with now is how to import data into Drupal’s database. The database structure is quite complex compared to our current site, or a Wordpress site, but luckily the Content Construction Kit abstracts all of that when the site is being built. And that’s the topic of today’s post.

Nodes, Users and Custom Content Types!

Everything in our system is a node. Stories. Slideshows. Sections. Authors. Issues.

Content types

Content types

The CCK module lets us define all the different information each node needs and tie authors to articles and articles to sections and issues with node reference fields. Each content type is themed separately with a different template and the different ways that piece of content can be viewed are defined by a set of boolean PHP variables.

Our site uses the following CCK content types.

Article submission

Article submission

  • Article - One article of the magazine. Articles have headlines, sub-headlines, date, image, related file and other fields defined in CCK. Articles also have node reference fields to identify who the authors of the article and what section the article is in.
  • Issue - One issue of the magazine, corresponds to the print issue. An issue is a collection of node reference fields that point to different articles. Certain fields of the issue are mapped to different slots on the front page of the site.
  • Photo Gallery - For photo essays or instances in which the image is the primary focus of the story. Behaves like an article in every other way.
  • Author - Everybody who writes a story is an author node. These are not related to users in the system at all, as not every writer will have an account on the website and not every one with an account on the website will be a writer. It also means that we don’t have to worry about deleting user accounts after writers graduate or leave. And while we haven’t done it yet, it would let us create author profiles so our writers can each have a portfolio page that’s more than just a listing of articles.
  • Section - A section of the website, these are done as nodes instead of as a taxonomy term for largely the same reasons as authors are.
  • Overheard at Penn - Overheard at Penn is a series of short snippets of overheard conversation. This is a very basic content type with just a single text field.
  • PDF Version - A PDF of the print edition of the website. Created using the File Field module.
  • Page - A simple static page.
  • Newsletter Issue - The Simplenews module allows for the creation of newsletters. This content type creates a newsletter with a node reference to the issue to be sent, and generates e-mails. It’s also integrated into the user accounts system, so everyone who is registered to receive the newsletter also has an account on the website to comment or for any user generated content areas we might decide to create in the future. Theming newsletters and HTML emails was an incredible pain in the butt, but that’s the subject of another post.
  • At the database level
    Creating a new field

    Creating a new field

    When creating fields and content types, this is all you see. Pick data types and title them. For the most part, the rest of the process is completely opaque. To learn more about the database structure of CCK, there’s documentation in greater detail here.

    There are several tables that store data for CCK fields.

    • node - This table stores the unique nid of the node, and what type it is.
    • node_revisions - This table stores the body content of the node, as well as data about which user created it, when it was revised and what’s in the teaser.
    • content_type_[type] - If a content type has fields that are only used by that content type, this table contains the values of that field.
    • content_field_[field] - Contains the values of that field.
    Theming

    A lot of the heavy lifting in Drupal is done at the theming layer. Luckily Zen makes it all much easier. That’s what I’ll be writing about next time. Some of the other upcoming posts will address how we handle images (Imagecache and CCK), how we theme our newsletters and how we handle multimedia.

    What did you think of this post? Got more questions about our Drupal install? Leave a comment. The new website is at http://beta.34st.com, poke around and leave us some feedback!

    How we did it in Drupal, Part 1 of X
    1. How we did it in Drupal, Pt. 1 of X - The Data Structure
    2. How we did it in Drupal, Pt. 2 of X - Theming with Zen

    In the course of developing Drupal for the DP, we’ve been fortunate that we’ve had to write very little (themeing layer excepted) from scratch. Chalk it up to to the strength and robustness of the Drupal community that nearly every function we wanted, there was a module for.

    One module that I did have to write from scratch was to replicate a function from College Publisher. After copy and pasting a story into CP’s interface, there was a button run all that doubled the line breaks, among other things.

    Drupal wraps text separated by two line breaks with <p> tags and uses the <br /> tag to in-between text separated by one line break. By default, text copied out of InCopy only has one line break between paragraphs.

    When Sean Blanda posted about the Temple News moving to Wordpress, this was one of the 6 problems he laid out as having.

    Keep reading…


    Exciting news on the CMS front.

    34th Street Alpha

    34th Street Alpha

    As some may know, The Daily Pennsylvanian web staff and I have been working on using Drupal to run our website and as a replacement for College Publisher on and off since the spring. The first part of that process is now nearly done and we have a nearly complete website for our magazine 34th Street!

    We made the decision to go ahead and develop and launch a site in Drupal a few weeks ago and since then have been in a somewhat hectic mode scrambling to get all the launch features ready. A great deal of thanks goes to the folks who made the New York Observer site happen and wrote up how they did it.

    Now it’s on to testing and training the other editors on how to use the system and looking for places to make the site work better, and make publishing easier. We also have to write a complete set of documentation for future and current editors on how to use the system, how to modify it, how to deal with Drupal upgrades and what to do in case things go wrong.

    Keep reading…


    Every post you see before this one (one exception) is imported from my old blog at http://albertgate.blogspot.com. This shiny new site is hosted by WebFaction and I’ve been very happy with them so far even if at $9.50 a month it’s a tad expensive for hosting a personal site. Their servers will let me play around with things like SVN and Django.

    Keep reading…


    Posts from my previous blog at albertgate.blogspot.com are freshly imported! Unfortunately though, no comments from about the middle of 2006 until now were imported.

    This blog still needs lots of work before I start linking it around though.


    Since College Publisher doesn’t give its clients access to their own databases or the web server, to do many things (like adding any new feature) requires working around it on auxiliary servers they provide running LAMP.

    One feature that CP desperately needs is the ability to create a block of related stories.

    So I struggled with the problem a little bit and created a little script to let totally non-tech savvy editors create a block of code to paste in.

    You can see a demo of it here.

    Related links generator

    The source code is here. To run it, your server must allow fopen to open url’s.

    Source

    This is the first time I’ve released the code of anything I’ve written, so give me some feedback!


    The dream jobs for today’s journalists are largely the same as they have always been. The rule was, and still is, the larger the circulation and the more often they publish the better.

    As long as this is the case, that’s where all the young talent will go. Unfortunately, right now those are the worst possible places for them to end up.

    An awkward transition

    In my last post, I wrote recommended some ideas for new revenue to fill the chasm between declining print and rising online ad revenue.

    Now I worry that even with as much innovation as they can muster the valiant struggle to save the medium and the famous mastheads will be a fight that is inevitably lost, and the old media dinosaurs will just die by ice age instead of asteroid.

    Maybe it would just be best to let them die quickly.

    Death of a paper

    I link to Mark Potts a lot, but he is amazingly incisive. He’s written a speculative piece about what will happen in the aftermath of a major metro daily’s bankruptcy.

    What will happen is the other news sources will have to step up and be more entrepreneurial. The bloggers and TV news and the alt weekly will all have to do more original reporting. New startups will spring up, run by the laid off staffers to focus on local news. Most importantly, it will give everyone a sense of entrepreneurial drive that a slowly dying organizing can never have.

    To fill the gap for readers and advertisers left by a newspaper dying a whole new media ecosystem of content producers and distributors will spring up.

    That’s where young journalists should be. We should be at startups, innovating and experimenting and taking stupid risks. Doing exactly the kinds of things a risk averse newspaper bleeding to death and busy slashing jobs won’t do.

    So the biggest challenge facing young journalists is our own mindset prizing the old media over new.


    The business model is still the elephant model in the room, as Ryan Sholin writes.

    All the new media in the world won’t save the media, if they can’t figure out how to make money off of it. Will advertising be enough? At the very least there’s a deep chasm to cross, according to some analysis Mark Potts did.

    And so since social networks and Web 2.0 companies can serve up page views far cheaper than media companies, it’s time to look at some alternate business models.

    1. Merchandising

    2. CNN already does it. Web comics do it. Randall Munroe writer of xkcd and his roommate make a living purely off of merchandising, according to his New York Times profile. xkcd attracts a huge audience but runs no advertising. So sell some t-shirts and sweatshirts with a masthead or a logo on it. Or with headlines. Or let people custom order t-shirts with photos from the paper on it. Or framed copies of stories about them or that they were quoted in. Okay, lots of papers do sell photos, but they’re mostly impossible to find unless you’re specifically looking for them so most readers never find it. There should at least be a link by every photo that runs. The Harvard Crimson does this.

    3. Consulting
    4. Among journalists’ skills is the ability to ferret out and synthesize a lot of information and then package it succinctly. Hey, that sounds like exactly the skills needed for a corporate report or to do background research on a new business proposal. Beyond that, they are supposed to be experts in the fields they cover. So let companies or individuals hire journalists as consultants to provide advice or do research for an hourly rate. a HIGH hourly rate.

    5. Briefings
    6. Similar to number two, journalists are supposed to be good at presenting a lot of information in an easy to digest format. How then, did they give up the ENTIRE market analysis field. GigaOm is getting into it with a briefing on cloud computing priced at $250 a copy. So is paidContent.org with reports on Social Media and Online Gaming in China for $399. Look at MarketResearch.com. They have reports (information) on a huge range of topics that people are buying at prices from several hundred dollars, to several thousand! Think about all the extra information that’s routinely gathered in the course of reporting a big story. While it’s cut to make the final piece easier to read for a mass audience, there’s also an audience that will pay for a much more in depth look.

      Every local newspaper should have a “How to open a retail franchise in X” with information on the retail climate, traffic patterns and other local knowledge. There should be an “Area private schools: where to send your kid”. And more. Compile that information, make it easy to digest, and sell it. But of course, if you’re going to charge it better be damn good.

    7. Sell Timeliness
    8. For some people timeliness of information is absolutely crucial. Think professional investors, politicians, corporate executives.
      So set up a system to let them see any news that is being broken first. Even just a few hours. Let’s say some news organization got a scoop that Steve Jobs’ cancer is returning. That information would be priceless to someone investing in Apple stock. Or if a strike is brewing at XYZ company, or congressman is taking bribes. There are all sorts of information where getting it even a tiny margin sooner than others is invaluable. Or just to brag to friends. Of course, this only works if the newspaper is regularly breaking news.

    9. Deeper sponsorships
    10. There are certain kinds of stories that happen regularly. Crime statistics. Holiday shopping numbers. Weather. So sell advertising tied into it. “This crime report brought to you by Mace” “This consumer spending report brought to you by Target”.

    11. Get serious about local communities
    12. Don’t just sponsor events, organize them. Conferences for local businesses. Food tastings from local restaurants. Reading in the park with local authors. Meet local sports stars. Reunion concert for musical acts that got their start locally. Movie screenings. Class action lawsuits. Debates and townhall meetings. Then sell sponsorships and tickets.

      GigaOm is a great example of this again. They sponsor three conferences in the area they cover to which tickets are quite expensive. But they are good, well produced events that not only generate a ton of buzz for them, but serve an important function in the community. The Wall Street Journal is getting into it too with their All Things D conference.

    13. Get serious about your online community

    14. Look at how Ars Technica does it. They have an amazing online community that has thrived for years and produced millions of posts. The participants on their forums discuss every topic, related to their articles and not. They have classifieds, technical talk, sex, all sorts of random things. People consider the Ars forums their HOME on the internet. That’s because it’s community moderated and idiots get thrown out. Those interested in building online communities would do well to look to the online forums that have been around for so long as a good model. With as much good will as they have from their community, Ars can sell subscriptions giving things that cost Ars NOTHING. Like adding “et Subscriptor” to the end of a profile name. Or posting privileges in a private forum. Or the ability to post in html. People are paying $50 for status symbols in the community.

    15. Pay what you will model
    16. Like Radiohead famously did for their album In Rainbows. “Sell” your subscriptions for online (or Mobile or Kindle or heck, even print) for however much customers decide they want to pay.

    17. Remember customer service
    18. Who are your customers? Advertisers. What service are you providing to them? Reaching their customers. Selling more display ads isn’t always the best way of doing that. If you can help your advertisers succeed you will too.

    Some of these may be infeasible, or even unethical so tear em apart and come up with better ones.