Integration with nodeteaser

VladSavitsky - May 29, 2008 - 16:10
Project:Meta tags
Version:5.x-1.8
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi!
Thanks for useful module
To make it working with nodeteaser.module do a hack in /sites/all/modules/nodewords/metatags/description.inc

<?php
function nodewords_description_prepare($type, $ids, $value, $settings) {
  if ((!isset(
$value) || empty($value)) && $settings['use_teaser'] && count($ids) == 1) {
    switch (
$type) {
      case
'node':
       
$node = node_load($ids[0]);
        if (
$node && node_access('view', $node)) {
         
// HACK: see <a href="http://drupal.org/node/79315" title="http://drupal.org/node/79315" rel="nofollow">http://drupal.org/node/79315</a> (can't use php functions in
          // body of nodes). Note that this still won't work if you have a
          // CCK field with PHP format.
         
if (filter_format_allowcache($node->format)) {
           
// We would like to use node_view($node, TRUE, FALSE), unfortunately
            // this uses theme_node() which, by default, adds 'Posted by ...'
            // information (which we don't want). The code below calls all
            // functions node_view() does, without the theme.
           
$node = node_build_content($node, TRUE, FALSE);
           
$content = drupal_render($node->content);
           
$node->teaser = $content;
           
node_invoke_nodeapi($node, 'alter', TRUE, FALSE);
           
$value = $node->teaser;
          }
// Start of hack
         
elseif ($node->format!=2) {//Not PHP filter format
           
$node = node_build_content($node, TRUE, FALSE);
           
$content = drupal_render($node->content);
           
$node->teaser = $content;
           
node_invoke_nodeapi($node, 'alter', TRUE, FALSE);
           
$value = $node->teaser;
          }
// End of hack
       
}
        break;

      case
'term':
       
// TODO: probably we have to do a db_rewrite_sql() query here so access is restricted
       
$term = taxonomy_get_term($ids[0]);
        if (
$term) {
         
$value = $term->description;
        }
        break;
      case
'vocabulary':
       
// TODO: probably we have to do a db_rewrite_sql() query here so access is restricted
       
$voc = taxonomy_get_vocabulary($ids[0]);
        if (
$voc) {
         
$value = $voc->description;
        }
        break;
    }
  }
  return
$value;
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.