0

I'm using the 'AddThis' sharing module with Facebook and Twitter so that when a user is on a page of the site they will be able to share it with others. This would include the front page.

The problem I'm discovering is that to use this module you have to add it as a field for a content type...so I can basically add it to all pages EXCEPT the home page.

Putting aside the issue with the front page for a moment, I'd like the sharing buttons to actually appear in the footer, not in the node body itself. The footer is a totally different region. Would this entail me using my .tpl files to change where this specific field appears (ie. hiding it and then showing it again but in the footer for the node)?

Or is there a better way to handle this?

1 Answer 1

1

If you aim to keep your footer region's wrappers in page.tpl.php your only option is to:

  1. hide field in node.tpl (tpl file or field display settings)

  2. render the field in page.tpl.php where you want it.

    a) use hook_preprocess_page in tepmlate.php to set page=variable = field value (if exists); then print/render that variable in page.tpl.php b) less elegant and more error prone: render field from page's $node variable

The above is assuming you're using standard drupal's theming system.

  1. THE QUICKEST: Alternatively you can use something like: https://www.drupal.org/project/fieldblock to expose your value as a block a,d them place it in whatever region. this one is compatible with whatever you use; panels DS; stabdrad block stystem; Context....
1
  • Thank you for the thorough explanation of the options. For time constraints I just used the module you recommended. It worked VERY easily. For anyone else: just make sure to read the directions on the module page for using Field as Block module. It's simple but it's a few steps. Thanks again!
    – Sage
    Commented Dec 12, 2015 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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