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 |
Jump to:
Description
Is that possible to do alink in CCK field also?
Thank you,

#1
Maybe, after I implement all the other features I want to implement. But for now I wouldn't count on it.
#2
I'll wait for that :)
#3
abx, have a look at what I've written here, and voice your support if you like.
http://drupal.org/node/144565
#4
abx, have a look at what I've written here, and voice your support if you like.
http://drupal.org/node/144565
#5
+1 subscription for this very useful feature, hope to see it soon ;-)
#6
+1 for the 6.x version of alinks !
#7
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
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
This patch worked for me. Thank you!
-Bram Moreinis
http://gamefacewebdesign.com
#10
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