I've installed the Drupal 7 port of the Node to Word module for exporting nodes as word or txt documents. The module packs two links - "Save as Word" and "Save as Text" - into the $content['links']
object in the node. I'd like to remove these links and output them as a variable that I can print where I like in my theme.
I've tried:
function mytheme_preprocess_node(&$variables) {
unset($variables['content']['links']['node']['#links']['node_to_word_link']);
}
using my theme name for "mytheme", but it doesn't work.
I also tried:
function mytheme_node_view_alter(&$build) {
unset($build['content']['links']['node']['#links']['node_to_word_link']);
}
but this just proved to me that I have no idea how this hook works.
I believe the module is using the following code to set the links:
function node_to_word_node_view($node, $view_mode, $langcode) {
$links = array();
if (node_to_word_enabled($node->type)) {
if (user_access('access node_to_word docs')) {
$links['node_to_word_link'] = array(
'title' => t('Save as Word'),
'href' => "word/$node->nid",
'attributes' => array('title' => t('Save this document as a Microsoft Word document.'))
);
$links['node_to_word_txt_link'] = array(
'title' => t('Save as text'),
'href' => "txt/$node->nid",
'attributes' => array('title' => t('Save this document as a plain text document.'))
);
$node->content['links'][$node->type] = array(
'#theme' => 'links__node__blog',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
}
}
I don't want to use a css display:none hack, I'm trying hard to learn the php logic for Drupal. Might be an uphill battle - I'm a PHP noob. Any help is deeply appreciated.