Alink with CCK field?

abx - May 18, 2007 - 10:29
Project:Alinks
Version:6.x-1.0-rc1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Is that possible to do alink in CCK field also?

Thank you,

#1

tic2000 - May 18, 2007 - 11:13

Maybe, after I implement all the other features I want to implement. But for now I wouldn't count on it.

#2

abx - May 18, 2007 - 13:58

I'll wait for that :)

#3

NikLP - May 18, 2007 - 15:12

abx, have a look at what I've written here, and voice your support if you like.

http://drupal.org/node/144565

#4

NikLP - May 18, 2007 - 15:12

abx, have a look at what I've written here, and voice your support if you like.

http://drupal.org/node/144565

#5

tourtools - August 1, 2008 - 12:35
Version:5.x-1.3-2» 5.x-1.4-3

+1 subscription for this very useful feature, hope to see it soon ;-)

#6

vstmusic - January 6, 2009 - 13:12

+1 for the 6.x version of alinks !

#7

cssd - February 26, 2009 - 12:31

I have a solution for Drupal 6.x (which may be applicable to 5.x?) - I think... that allows any CCK field with a field type of 'text' to be included in the areas that are searched - to insert links into.

alinks.module modified to change the 'alinks_nodeapi' function as follows;

/**
* Implementation of hook_nodeapi().
*/
function alinks_nodeapi(&$node, $op, $teaser, $page) {
 
  switch ($op) {
    case 'view':
   
      $node_types = in_array($node->type, variable_get('alinks_node_types', array()), TRUE);
     
      if ($node_types) {
        drupal_add_css(drupal_get_path('module', 'alinks').'/alinks.css');
        $words = alinks_get_strings();
      
        if ($words) {
       
          $node->content['body']['#value'] = alinks_make_links($node->content['body']['#value'], $words);

/**
*  find CCK fields (prefix of 'field_') where format == 2 (text fields) and make links on the value of the field
*/
    $cck_fields = get_object_vars($node);
foreach (array_keys($cck_fields) as $cck_field){
  if (substr($cck_field,0,6) == "field_" && $node->{$cck_field}[0]['format'] == 2){

          $node->{$cck_field}[0]['value'] = alinks_make_links($node->{$cck_field}[0]['value'], $words);
  }
}

    }
      }
      break;
  }
}

It is dependent upon the fieldnames being prefixed with 'field_' - which is the way with CCK as far as I can gather.

The only thing I am not sure about is whether the 'format' == 2 will always equate to 'text' field types or if this is dependent upon the installation/configuration of the CCK module.

Perhaps others can give feedback regarding this...?

Hope it is useful.

#8

edgoss - July 2, 2009 - 13:28
Version:5.x-1.4-3» 6.x-1.0-rc1

Thanks for trying to implement a fix for this, but it doesn't work on my site yet.

This could be the 'format' == 2 issue you mentioned above. Having said that I did change the value from 1 - 7 and none of the changes worked. Would be nice to get this working as it would be a great money maker for my site!

Thanks

#9

bmoreinis - September 2, 2009 - 21:01

This patch worked for me. Thank you!

-Bram Moreinis
http://gamefacewebdesign.com

#10

FrancoisL - November 25, 2009 - 08:34

Hi thanks for this patch,

It's globally works for me but I noticed something that seems to be a bug. When you have a link in the first words of a text, the text disappear. This is true for cck fields but not for basic body text.

Hope that can help :)

François

 
 

Drupal is a registered trademark of Dries Buytaert.