Archive for February, 2010

Eat Your Heart Out, George Orwell

You may have met Goldie-Arf in yesterday’s post. Well, Goldie likes to bark: at cars passing, at the cats, for no good reason other than she’s a dog, and so on. But what I heard around 5pm last night was not a bark. It was a growl—and despite never having heard such a snarl from her, I knew it was Goldie. Goldie doesn’t growl unless something is awry.

So, I looked outside, and there they were. In all their splendor, rooting about near the door of the house the pigs chortled with the cry of freedom.

Here they are, the glib porkers:

Pigs on the loose

I sighed with relief; Goldie wasn’t caviling with a coyote or exchanging words with a wolf. I called Tony and after giving me clear directions about what to do, I wound up doing something entirely different.

To help explain you’ll need to know two things:

  1. Pigs do not like snow
  2. The layout of the farm. And what better to show that than a photo or two?

where the pigs live, and the farm from the sky

Except, during winter, it looks like this:

Winter at the Farm

On the phone, Tony told me to lure the pigs with their food pail (the pink path) to the Northern pasture door, shown in red below.

The Pork Plan

The pigs weren’t having it! In the Summer, the pigs pasture West of the machine shed, and North of their stable area; they are free to come and go inside and out, whenever they please. Leading them back inside their pasture area isn’t a big deal during any other season but Winter – then again, I can’t imagine that they have ever left the stable when there was snow high on the ground. I needed a new plan, and fast.

After luring them back into the stable pathway (yellow), I took down the pig pen fence (they must’ve pushed the holding gate over, and hopped over the fence). I made sure the mother was watching – and when she followed me, I led her and her piglets into the pen (green). I nailed the fence back up and secured the gate so they couldn’t push it open again. End of story.

Anyone want some bacon?

Meet the Animals

The family is away, and I’m doing chores in their stead. Really, it’s just feeding the animals, so I figured I’d post some photos:

First and foremost, Goldie the farm dog. She also goes by Goldie Arf. You’re the man now, arf.

Goldie, the farm dog

The cows are very thirsty! And very much ungulates. They nudge and moo if one cow is taking too long at the watering area. Reminds me of kindergarten. Large, hairy, hay-eating, wet-nosed kindergarten.

Cows drinking waterMore cows, drinking water

And now, the pigs. Also ungulates, and quite smelly. Soon they’ll have their own portable A-frame shelter for the spring/summer/fall. I’m not sure if they’ll come in for winter as they do now, but all the farm animals are pastured. For some animals, like the cows, this means they just eat the grass. The chickens get to dig around for grubs and insects, and also are supplemented with organic grain feed (seeds, corn, etc). The pigs pasture as well and get scraps from here an there. No meat though, especially not other pigs.

The big mama

I don’t know their names yet, but the mother above is bred every year. Most of the resulting piglets (usually 8-10) are sold off, but they keep two or three for food. Its processed at Dayland Meats, where they cut it into chops, bacon, hams, shoulder, and other tasty morsels of piggy goodness.

There are currently three pigs, and we’re actively looking for a boar with which to breed the mother. This means either we buy the boar, or a fee is charged for breeding. If the farm does buy one, it will most likely be sold off – granted a profit is made on the sale of the resultant piglets. Enough talk. Here’s another pig photo:

Piglet and mama

And now, my favorites: the baby chicks. These little ones are about 3 weeks old. In a factory farm, that means they’ve reached middle age. Most factory farmed chickens don’t make it past the 6 week mark. Stoney Acres carefully chooses the breeds of chicken, selecting from rare breeds specialized for meat, eggs, or both. This year, the farm is producing eggs as well as chickens for meat, so we’ve got a few varieties of chickens. I’ll write a more specific chicken post in the weeks to come. For now, cute photos:

chickletslittle baby chickschicks eatingorganic chicken feed

There will definitely be more to come. I will probably start blogging about farm stuff on the farm’s website, http://www.stoneyacresfarm.net. In addition to the photographed animals, there are also goats, getting honey bees shipped soon, and there’s talk of sheep for meat and wool. Lots to learn and look forward to.

A Quick Note on Image Visibility in Drupal’s Views_Gallery Module

For anyone whose views_gallery module seems to be installed and configured correctly:

Don’t forget to enable anonymous user permissions. This goes for most uploaded content, including attachments.

Inserting a span element into an anchor via Drupal’s $primary_links

I previously wrote about how to insert a span into a link, but after testing this method quickly failed when coupled with the Views module. When a Page view is created and assigned to a node url, everything is fine and dandy. The issues arise when you want a link to use an alias. Luckily, I’ve devised a really simple work around:

use the same code to generate your menu:

<?php if (!empty($primary_links)): ?>
<?php print theme('links', $primary_links, array('id' => 'nav')); ?>
<?php endif; ?>

this calls the links() function inside of includes/theme.inc, which triggers the l() function in the includes/common.inc to write the primary links menu. We can’t override the l() entirely because other code uses it, so we’ll copy the code from theme.inc and override the l() function with a site template specific one. Here’s my code:

theme.inc

function mytheme_links($links, $attributes = array('class' => 'links')) {
 global $language;
 $output = '';
 $options = array(
 'class' => '',
 'html' => FALSE,
 );

 if (count($links) > 0) {
 $output = '<ul' . drupal_attributes($attributes) .'>';

 $num_links = count($links);
 $i = 1;

 foreach ($links as $key => $link) {
 $class = $key;

 $links['attributes']['title'] = $link['title'];
 // Add first, last and active classes to the list of links to help out themers.
 if ($i == 1) {
 $class .= ' first';
 }
 if ($i == $num_links) {
 $class .= ' signup last';
 $links['attributes']['class'] .= $class;
 }
 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
 && (empty($link['language']) || $link['language']->language == $language->language)) {
 $class .= ' active';
 }
 $output .= '<li' . drupal_attributes(array('class' => $class)) .'>';

 if (isset($link['href'])) {
 // Pass in $link as $options, they share the same keys.

//here's my call to the overridden function
 $output .= mytheme_l($link['title'], $link['href'], $links);
 }
 else if (!empty($link['title'])) {
 // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
 if (empty($link['html'])) {
 $link['title'] = check_plain($link['title']);
 }
 $span_attributes = '';
 if (isset($link['attributes'])) {
 $span_attributes = drupal_attributes($link['attributes']);
 }
 $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
 }

 $i++;
 $output .= "</li>\n";
 }

 $output .= '</ul>';
 }

 return $output;
}

and now the l() function in common.inc gets changed to mytheme_l():

function mytheme_l($text, $path, $options = array()) {
 global $language;

 // Merge in defaults.
 $options += array(
 'attributes' => array(),
 'html' => FALSE,
 );

 // Append active class.
 if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
 (empty($options['language']) || $options['language']->language == $language->language)) {
 if (isset($options['attributes']['class'])) {
 $options['attributes']['class'] .= ' active';
 }
 else {
 $options['attributes']['class'] = 'active';
 }
 }

 // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
 // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
 if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
 $options['attributes']['title'] = strip_tags($options['attributes']['title']);
 }
 // Inject a span inside the anchor tag for the purposes of this theme - NOTE - May have to remove check_plain() around
 // the $text variable
 return '<a href="'. check_url(url($path, $options)) .'"'. drupal_attributes($options['attributes']) .'><span>'. ($options['html'] ? $text : check_plain($text)) .'</span></a>';
}

You can see that all I did was include the span element inside the anchor tag using simple php string concatenation. Until I can find a better solution, this does the trick. Don’t ask me about benchmarking, though…

Conservation of Energy and Baby Animals

I just came back inside from turning the heat lamp for the baby chicks. They arrived a week or so ago and are already significantly larger than when they arrived. As I stumbled through the dark greenhouse, fumbling for the power cord, I anticipated seeing their warm bodies huddled in a feathery flock. When I finally managed to fit the cords together, there they were.

What I didn’t anticipate was them being piled on top of one another, asleep, conserving heat. This lead me to thinking: how exactly is it that broods of baby animals know to huddle together to stay warm? This isn’t about them trying different things out until they collectively realize that they stay warmer when together. Somehow, they inherently know to do just that, as soon as they’re out of the egg.

I’m guessing it’s simply genetically passed “instinct”, just as we are wired for language. I’ll do more investigating, but if anyone knows – throw some sources at me.

Returning an Alias from primary_links’s links['href'] – or – How I became a Drupal Wizard

I’m building a custom template in Drupal for the farm, and needed a way to spit out a custom implementation of primary_links navigation unordered list. I needed something like this:

<ul id="nav">
  <li class="first"><a href="link-goes-here" title="wow, how descriptive"><span>link 1 copy</span></a></li>
  <li><a href="link-goes-here2" title="round 2, FIGHT!"><span>link 2 copy</span></a></li>
</ul>

The spans inside the anchor tag are valid xhtml strict, and necessary for the nested/floating backgrounds. The l() function in drupal does a fine job of spitting out valid code, but I also haven’t found anything to delimit the angle brackets in the span element.
Here’s how I solved the problem.

First, I added a preprocess function in template.php and copied this chunk of code from root/includes/theme.inc:

function theme_links($links, $attributes = array('class' => 'links')) {
 global $language;
 $output = '';

 if (count($links) > 0) {
 $output = '<ul'. drupal_attributes($attributes) .'>';

 $num_links = count($links);
 $i = 1;

 foreach ($links as $key => $link) {
 $class = $key;

 // Add first, last and active classes to the list of links to help out themers.
 if ($i == 1) {
 $class .= ' first';
 }
 if ($i == $num_links) {
 $class .= ' last';
 }
 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
 && (empty($link['language']) || $link['language']->language == $language->language)) {
 $class .= ' active';
 }
 $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

 if (isset($link['href'])) {
 // Pass in $link as $options, they share the same keys.
 $output .= l($link['title'], $link['href'], $link);
 }
 else if (!empty($link['title'])) {
 // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
 if (empty($link['html'])) {
 $link['title'] = check_plain($link['title']);
 }
 $span_attributes = '';
 if (isset($link['attributes'])) {
 $span_attributes = drupal_attributes($link['attributes']);
 }
 $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
 }

 $i++;
 $output .= "</li>\n";
 }

 $output .= '</ul>';
 }

 return $output;
}

I then modified the code as follows:

function stoneyacresfarm_links($links, $attributes = array('class' => 'links')) {
 global $language;
 $output = '';

 if (count($links) > 0) {
 $output = '<ul'. drupal_attributes($attributes) .'>';

 $num_links = count($links);
 $i = 1;

 foreach ($links as $key => $link) {
 $class = $key;

 // Add first, last and active classes to the list of links to help out themers.
 if ($i == 1) {
 $class .= ' first';
 }
 if ($i == $num_links) {
 $class .= ' last';
 }
 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
 && (empty($link['language']) || $link['language']->language == $language->language)) {
 $class .= ' active';
 }
 $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

 if (isset($link['href'])) {
 // Pass in $link as $options, they share the same keys.
 // here are the modifications
 $temphref = drupal_lookup_path('alias', $link['href'], '');
 $output .= '<a href="' . $temphref . '" title="' . $link['title'] . '"> <span>' . $link['title'] . '</span></a>';
 }
 else if (!empty($link['title'])) {
 // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
 if (empty($link['html'])) {
 $link['title'] = check_plain($link['title']);
 }
 $span_attributes = '';
 if (isset($link['attributes'])) {
 $span_attributes = drupal_attributes($link['attributes']);
 }
 $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
 }

 $i++;
 $output .= "</li>\n";
 }

 $output .= '</ul>';
 }

 return $output;
}

Lines 29 & 30 are the brilliant bits. I scoured api.drupal.org till I found the  drupal_lookup_path function. Follow the link for the arguments that can be passed in. I specified that I wanted an alias, gave it the path ( links['href'] ), and passed in a blank character for language.

This is all rendered out in my page-front.tpl.php and page.tpl.php files in the standard fashion:

<?php if (!empty($primary_links)): ?>
  <?php print theme('links', $primary_links, array('id' => 'nav')); ?>
<?php endif; ?>

I hope this helps!

Logging, Logging & Mushrooms

I went out to the woods today, beyond the pasture, to haul back some oak with Tony & Big Ed, the midnight ploughboy. The plan is to let them incubate a bit, build a rack for them to stand in, and come spring, drill them out for shiitake spores.

We clung to the rickety wagon as Ed’s duct-taped gloves loosely clutched the steering wheel of an old, but still bright green tractor. Tony has probably done this a million times, but it was entirely new to me. The floorboards of the agrarian chariot were rotting and the metal carriage was loosely held together by ancient bolts – the flex would prove crucial on our return, wagon brimming with several thousand pounds of wood. Ed hopped off to fell an enormous oak, probably a good 80 plus footer. We went on to collect from a different section of woods before heading back.

There was a slight gap in the forest where the tree had been, as well as the other trees it leveled with it. It was all planned of course – Ed is a master. He knows the trees like an addict knows veins. The man is over six-foot-six and weighs a good 240 pounds. He is lean but colossal and muscular, as is Tony. Standing beside them, my six-foot-two frame seems diminutive in comparison. They toss logs like toothpicks.

So we loaded wood. Not 5, or 10 logs. Seventy is a low estimate. Five feet in length, 3 to 8 inches in diameter, we stacked them into the wagon steadily over the course of an hour and a half, whilst making a separate pile for firewood and branches that will quickly be consumed, back into the rich forest floor from which they came.

When we returned, we clung to the outside of the wagon, gas can clacking against the rails. A chain connecting the two side walls kept them from breaking from the immense weight of wood. The wheels bulged, almost flat, and the back end dragged through the deep snow troughs along the tractor path.

It was fun. Hard work, but fun – and a great way to stay warm and fit. The mushrooms will be included in the CSA baskets for the season, and sold to restaurants and farmers markets. I can’t wait.