1

(I have already posted this question on StackOverflow, but I then discovered this forum, which seems to be a more appropriate place for this question.)

I have also read all the similar questions on StackOverflow, without luck.

In my Drupal 7 site I use the Printer, email and PDF versions module. I want to show the printer link on some specific pages of a specific content type. So I have enabled the link in that content type, which include a boolean field (field_printable) where the admin should be able to choose to include the link or not. In my template.php file I try to figure out how to work this out. This is what I have got so far in my template.php file:

function mytheme_preprocess_node(&$variables) {
    if($variables['type'] == "mycontenttype"){
        // boolean field that returns 1 if checked
        if($node->field_printable['und'][0]['value'] == 1){
                 what to put here ...?
        }
    }
}

I should probably use print_insert_link(); to insert the link, but I cannot figure out how. Can anyone point me in the right direction? I have spent hours googling on similar questions, but I am stuck right now.

Any help would be very appreciated, thanks in advance.

0

Well If I understood your question properly, you want to show the print link only on specific nodes right? This is straightforward, by default if you enable print links for a content type, then the print links will be displayed on all the nodes of the content type.

For those nodes which you don't want the print links to be displayed, you can disable the print links option in the node-edit page itself.

enter image description here

| improve this answer | |
  • Wow, that was painful to read. Don't know how I could miss that :-). I went through and made a function to actually add the link on certain pages, which worked fine. And it turns out that spent an hour for nothing. Well, maybe I learned something in the process. Thanks :-) – TBJ Jan 19 '16 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.