Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IT-Cru/56beb91b641e47ebb448 to your computer and use it in GitHub Desktop.
Save IT-Cru/56beb91b641e47ebb448 to your computer and use it in GitHub Desktop.
minimal_share-rendering_tokens_in_block_view-12-1.patch
diff --git a/minimal_share.module b/minimal_share.module
index c469409..301420c 100644
--- a/minimal_share.module
+++ b/minimal_share.module
@@ -247,6 +247,11 @@ function minimal_share($url = '', $title = '', $settings = array()) {
$title = drupal_get_title();
}
+ if (arg(0) == 'node') {
+ $entity_type = 'node';
+ $entity = menu_get_object();
+ }
+
$element = array(
'#type' => 'html_tag',
'#tag' => 'p',
@@ -267,6 +272,15 @@ function minimal_share($url = '', $title = '', $settings = array()) {
continue;
}
+ if (!empty($service['params']) && !empty($entity_type)) {
+ foreach ($service['params'] as $param => $value) {
+ // Replace tokens, strip tags and encode string.
+ $value = token_replace($value, array($entity_type => $entity), array('clear' => TRUE));
+ $value = drupal_encode_path(strip_tags($value));
+
+ $service['url'] = str_replace('[' . $param . ']', $value, $service['url']);
+ }
+ }
$service['url'] = str_replace(array('[title]', '[url]'), array($title, drupal_encode_path($url)), $service['url']);
// Set default label type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment