summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhizes2012-09-28 09:26:48 (GMT)
committer Valery L. Lourie2012-09-28 09:26:48 (GMT)
commitccda9157720c48ad692761baa2370ab4e5c4985f (patch)
tree26d1330dc34cde130b24f3b033176eb05b023925
parentfae170b661f4d9015217804343f3b28563e6c2b5 (diff)
Issue #1509632: Show taxonomy term meta tags in views
-rw-r--r--metatags_quick.module23
-rw-r--r--metatags_quick.views.inc25
2 files changed, 41 insertions, 7 deletions
diff --git a/metatags_quick.module b/metatags_quick.module
index daefc9b..c6e9d50 100644
--- a/metatags_quick.module
+++ b/metatags_quick.module
@@ -72,6 +72,15 @@ function metatags_quick_permission() {
}
/**
+ * Implements hook_views_api().
+ */
+function metatags_quick_views_api() {
+ return array(
+ 'api' => 3,
+ );
+}
+
+/**
* Implements hook_entity_info().
*/
function metatags_quick_entity_info() {
@@ -485,7 +494,7 @@ function _metatags_quick_add_head($item = FALSE) {
$content = preg_replace('/<\/a><a/', '<\/a>, <a', $content);
$content = trim(strip_tags($content));
$item['content'] = $content;
- $meta_data[] = $item;
+ $meta_data[] = $item;
if (empty($item['type'])) {
$item['type'] = 'default';
@@ -493,14 +502,14 @@ function _metatags_quick_add_head($item = FALSE) {
switch ($item['type']) {
case 'link' :
- // Unset an existing html head link with the same rel attribute, assuming that
- // the array key has been built by drupal_add_html_head_link().
- $head_elements = &drupal_static('drupal_add_html_head');
+ // Unset an existing html head link with the same rel attribute, assuming that
+ // the array key has been built by drupal_add_html_head_link().
+ $head_elements = &drupal_static('drupal_add_html_head');
foreach ($head_elements as $key => $head_element) {
- // If an existing key starts with 'drupal_add_html_head_link:[name]', unset it.
+ // If an existing key starts with 'drupal_add_html_head_link:[name]', unset it.
if (strpos($key, 'drupal_add_html_head_link:' . $item['name']) === 0) {
- $head_elements[$key]['#access'] = FALSE;
- }
+ $head_elements[$key]['#access'] = FALSE;
+ }
}
$attributes = array(
'rel' => $item['name'],
diff --git a/metatags_quick.views.inc b/metatags_quick.views.inc
new file mode 100644
index 0000000..d6fb30c
--- /dev/null
+++ b/metatags_quick.views.inc
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @file
+ * Views include file for metatags_quick
+ */
+
+/**
+ * Implements hook_views_post_render().
+ */
+function metatags_quick_views_post_render(&$view, $output, $cache) {
+ // If the view is a page display, has a path and it is a taxonomy term path.
+ if (($view->display_handler instanceof views_plugin_display_page) && $view->display_handler->has_path() && ($view->get_path() == 'taxonomy/term/%')) {
+
+ $term = taxonomy_term_load($view->args[0]);
+ $fields = field_info_instances('taxonomy_term', $term->vocabulary_machine_name);
+
+ foreach ($fields as $name => $instance) {
+ $settings = field_get_display($instance, 'full', 'taxonomy_term');
+ // Check for fields which use this module for display, and render them.
+ if ($settings['module'] = 'metatags_quick') {
+ field_view_field('taxonomy_term', $term, $name, $settings);
+ }
+ }
+ }
+}