This module contains lots of outdated code stemming from the original weburl module, which in turn was based on the original database configuration of CCK. There have been lots of changes to CCK, so I have put together a patch that would align the link module with the latest CCK version. It does the following:

1) Gets rid of the node_field_link_data table which was the old way of storing CCK data in favor of the new data storage method used by all other modules (either node_content_XX or node_data_field_link, depending on whether the field is used in more than one place).

2) Gets rid of all database handling for node loads and updates and hands it off to the content module, as other field modules do.

3) Gets rid of the views tables, letting the content module handle views integration, as other field modules do.

4) Adds in the new formatters, and enables two formatters, the default, which creates a link out of the url, and a plain formatter which just displays the url without making it into a link. The default formatter is used in the view, both formatters are available when the field is added to a views view, and the plain formatter can be used in themes by using something like "print content_format('my_field', $my_field[0], 'plain');".

There might be other things that could be done, but this is at least a starting point. In particular, it would be good to make sure database handling is consistant with other field modules to make the transition to future versions go more smoothly.

CommentFileSizeAuthor
#6 link_3.patch13.93 KBdkruglyak
#1 link_2.patch13.93 KBkarens
link_1.patch13.93 KBkarens

Comments

karens’s picture

StatusFileSize
new13.93 KB

Found a typo, here is an updated version.

quicksketch’s picture

KarenS, this is awesome! Thanks for lending your mad CCK skills to the link project. I've been meaning to update the database schema for quite some time. I'll review the changes and post them asap.

karens’s picture

One thing you need to test is whether the install module is properly converting all possible situations -- i.e. link fields that are shared between two different content types which should go into their own field table instead of the content tables, multiple value link fields, which also should end up in their own field table, and single value non-shared links, which should end up in the content table. I did some quick checking, but probably not enough.

dkruglyak’s picture

I am trying to apply this patch and all the hunks are failing.

Could you post the patched files too or perhaps commit update if it is tested enough?

This patch seems to fix buggy LIKE filter that I need now.

Does it also make this fix (http://drupal.org/node/85996) obsolete with new formatters ?

dkruglyak’s picture

Version: master » 4.7.x-1.x-dev

OK, I did figure out how to apply a patch after all...

However adding a link field to an existing view causes all nodes to disappear when a view is shown.

I did the upgrade of existing nodes with devel module "reinstall" feature and then also ran upgrade.php which showed there is nothing to upgrade in link module.

What could be causing this?

dkruglyak’s picture

StatusFileSize
new13.93 KB

I found a bug in the latest patch. When you create a node with a link field and then try to load it into edit form, the default value is not loaded because of out-of-place unset($node_field);

Attached is a fix that works for me, but should be reviewed further.

dkruglyak’s picture

Final question.

What should be the best way to trim link lengths to certain size? URLs are often very long and likely to overflow / break page layouts. A solution is to display up to fixed number of first URLs characters. What is the best way to implement this?

I understand that in views it can be done via field theming, but is there a better way to do this with CCK field formatters to show both in views and in content and not be dependent on a theme?

dkruglyak’s picture

OK, I found that URLs are already trimmed in link_field_formatter with hardcoded constant of 80 that I can hack.

Perhaps instead of being set as a constant URL maxlength should be exposed into widget configuration screen.

quicksketch’s picture

I'm currently testing/updating the patch for link.module and everything has been running great. There's still a bit of cleanup needed, removing the old database table from .install for instance, but functionality-wise things are working excellent. Thanks again Karen, I'll get the changes up soon.

quicksketch’s picture

Status: Needs review » Fixed

Finished cleanup today and posted final version. These changes are now included in the 1.1 release of link.module.

dkruglyak’s picture

Version: 4.7.x-1.x-dev » 4.7.x-1.1
Status: Fixed » Needs work

Please comment out or remove dsm() in link_validate_link. Debug is spewed out into message area.

quicksketch’s picture

Ew... really? I must've left it in earlier, but all the current tags/branches seem to be free of any debug code. Which branch and version contained the dsm()?

dkruglyak’s picture

Status: Needs work » Fixed

My bad. I grabbed the latest right after you marked the issue as fixed and did not notice you updated to 1.5.2.14

// $Id: link.module,v 1.5.2.13 2006/11/14 21:33:11 quicksketch Exp $

Anonymous’s picture

Status: Fixed » Closed (fixed)