Attached is a patch which makes link-fields supported by the entity property API as introduced by the entity API module. This makes link fields accessible in Rules and any other module relying on that, e.g. search api.

patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

FileSize
2.43 KB

and the same patch with -p0

klausi’s picture

Patch does not apply anymore, new one attached.

dasjo’s picture

Status: Needs review » Reviewed & tested by the community

works for me.

usage example:

  $wrapper = entity_metadata_wrapper('node', $node);
  $wrapper->field_link->set(array('url' => $someUrl));
  entity_save('node', $wrapper);
pfrenssen’s picture

Status: Reviewed & tested by the community » Needs work

Awesome work!!

For completeness, can you please support the 'description' element in the link_field_item_property_info() properties?

fago’s picture

Status: Needs work » Reviewed & tested by the community

The default callback run by the entity API entity_metadata_field_default_property_callback() already takes care of generating a description, so the patch should be fine as is. Thus, setting back to RTBC.

Edit: Realizing you talked about the nested properties. They already have a label which I think say already everything, or what would you suggest to add as description? Anyway, descriptions are not mandatory.

jcfiala’s picture

Status: Reviewed & tested by the community » Needs work

Hm. There's two basic things I need to accept this patch.

1) As best as I can see from looking over the patch, this patch adds support for the 'title' and 'url' parts of the field, but _not_ for the 'attributes' part. I don't think that's a good idea.

2) I'm totally unfamiliar with the Entitly API module, and I'd rather not enter in this functionality without coming up with some sort of simpletest that tests the code. But I don't know enough on how to create a simpletest - I need either some tests, or a suggestion of how to build a test.

Thanks!

drunken monkey’s picture

Patch doesn't apply anymore, attached is a re-roll (but yet without taking the comments in #6 into account).

Anonymous’s picture

I was just looking at whether Entity Property API support was in Link module because I want to add microdata... here's the issue #1267662: Support microdata in link

pfrenssen’s picture

#5 Posted by fago on May 3, 2011 at 9:52am

Edit: Realizing you talked about the nested properties. They already have a label which I think say already everything, or what would you suggest to add as description? Anyway, descriptions are not mandatory.

It's true, the descriptions are not mandatory, but as they are shown in certain forms (such as Search API) it is nice to have.

scor’s picture

Thanks for the patch. I can confirm it does work and we're working on leveraging this functionality in RDF as well: #1273450: Support for link field in the RDF model

klausi’s picture

does not apply anymore, reroll.

dqd’s picture

thx 2 all! I am about to catch up link issue queue. I will commit immediately to prevent another reroll ...

dqd’s picture

1079782-link-entity-property_0.patch:15: new blank line at EOF.
+
Applied patch link.module cleanly.
warning: 1 line adds whitespace errors.
klausi’s picture

Drupal coding standards: "All text files should end in a single newline (\n). This avoids the verbose "\ No newline at end of file" patch warning and makes patches easier to read since it's clearer what is being changed when lines are added to the end of a file." http://drupal.org/node/318#indenting

Should be good, no? Check your git settings.

dqd’s picture

Status: Needs work » Fixed

doesn't matter.
It has created a new empty line @ link.module but I simply removed it and bam ..
committed to latest dev now with your credentials :-P

thx 2 all!++

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

j0rd’s picture

This patch doesn't allow for easy field creation of links.

$wrapper = entity_metadata_wrapper("node", $node);
// Fails a horrible death
$wrapper->field_link = 'http://google.com';

// Works
$wrapper->field_link = array('url' => 'http://google.com', 'title' => '');

Ideally the former would work. Just my 2cents from running into this problem. Posted here for others looking for solution.

tim.plunkett’s picture

Expanded this for attribute support: #2117099: Expose attributes as property info