Skip to content

Instantly share code, notes, and snippets.

@soulston
Last active December 20, 2015 18:28
Show Gist options
  • Save soulston/6175686 to your computer and use it in GitHub Desktop.
Save soulston/6175686 to your computer and use it in GitHub Desktop.
/**
* Override or insert variables into the node template.
*/
function MYTHEME_preprocess_node(&$variables) {
if ($variables['node']->type == 'article') {
kpr($variables['node']);
$node = $variables['node'];
if (isset($variables['node']->field_file)) {
$file = field_get_items('node', $node, 'field_file');
$file = reset($file);
kpr($file);
$file = file_load($file['fid']);
$file_uri = drupal_realpath($file->uri);
kpr($file_uri);
$variables['download_link'] = l('Download', $file_uri);
kpr($variables['download_link']);
}
}
}
@soulston
Copy link
Author

soulston commented Aug 7, 2013

Remove the kpr's and change:

"article" to "developments"

"field_file" to "field_development_brochure"

print render the newly created $download_link variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment