Problem/Motivation
Links are not currently supported by feeds_et
, meaning you can't import language-aware titles or URLs into link fields.
Proposed resolution
Add a language-aware link override.
Also need to tweak how altering targets is done to take into account the fact that, for links (and other types), the field name is not the target key (the key is field_name:property_key
).
Remaining tasks
Initial patch- Feedback in #4
- Final review and RTBC
- Commit
User interface changes
feeds_et
now presents a target for each language on link fields.
API changes
Adds support for property keys other than 'value'
.
Data model changes
None.
Original report by ottawadeveloper
Links are not currently supported by feeds_et, meaning you can't import language-aware titles or URLs into link fields.
The solution to this is to add a language-aware link override. Also need to tweak how the targets alter is done to take into account the fact that, for links (and other types), the field name is not the target key (the key is field_name:property_key).
Comment | File | Size | Author |
---|---|---|---|
#7 | feeds_et_link_support-2078069-7.patch | 4.43 KB | mparker17 |
Comments
Comment #1
ottawadeveloper CreditAttribution: ottawadeveloper commentedThis patch does the following:
* Adds the callback _feeds_et_link_feeds_set_target
* Changes the _feeds_et_field_feeds_set_target function to have a $target_key parameter that lets us put the value in another field other than "value" (necessary for links as we need to target "title" or "url").
* Reworked feeds_et_feeds_processor_targets_alter to handle link and date fields (which don't just use field name as the key for targets). This is a temporary fix to get it working for now - really, the whole concept needs to be revisited to use hooks to allow modules that define custom fields to supply their own settings (like hook_feeds_et_field_keys($field_type) returns an array of keys and the proper handler function for them).
Comment #2
wimpie3 CreditAttribution: wimpie3 commentedPatch not working anymore, code in "feeds_et.module" has been changed in the mean while...
Comment #3
ZeiP CreditAttribution: ZeiP at Avoltus Oy commentedAttached is the same patch against current VCS 7.x-1.x HEAD. I also fixed a few coding style issues.
The patch works fine for me, it'd be great if we could get it committed.
Comment #4
mparker17I need to import link fields using feeds too; I'll see what I can do to help this patch along.
***
The patch still applies as of commit
bf0d6d0
.***
Overall, the patch in #3 appears to use the API well. I do have a few small questions / coding-standards nit-picks:
I know the other callbacks don't do this, but for clarity, I would add...
...to the docblock, to indicate the functions responsible for adding this function to the list of callbacks, and the function that actually calls the callback respectively.
I'd argue that this chunk of code is unnecessary, because the
feeds_tamper
already provides a "Filter empty items" (machine name:array_filter
) tamper which does this, and can be turned on or off at the site builder's discretion depending on their needs.If this is absolutely necessary (i.e.: to prevent fatal errors), then there are two problems:
unset($value[$k])
.The fact that "the second parameter is the target key" is re-stated in the code on the next line. It's more important that the target key can be either
title
orurl
for links.Coding standards say that there needs to be a blank line before this type of comment, and comments should start with a capital letter.
I would add the blank line before the comment and re-word the comment to say "The target key will be either 'title' or 'url' for links."
This patch is focused on adding support for link fields, not date fields. Maybe this change was part of another patch that crept into this one? If this was intentionally included in this patch (i.e.: throw in support for date fields because it's easy to do) then this issue title and summary should be updated to clarify this.
Comment #5
mparker17Issue housekeeping
Comment #6
Zalak CreditAttribution: Zalak at Northern Commerce commentedI am working on this issue currently.
Comment #7
mparker17@Zalak and I discussed this in Slack, and because the changes in this patch provide a great basis for #1850930: Support multilingual File fields (which we also need done for our client and I was already working on), I'm going to continue working on this. Thus, by mutual agreement, I am reassigning this issue to myself.
***
I have attached a patch that fixes the issues I identified in #4.
Note that I removed the Date field key definitions because there is no corresponding
_feeds_et_date_feeds_set_target()
(i.e.: the callback for the mappings, set in_feeds_et_process_targets()
). Also, the ET mappings do not show up (not sure if that is because Feeds can't find the callback, or some other reason).Comment #8
mparker17Sorry for the delay on this. I seem to be able to choose in the "target configuration" column which language a mapping targets for multilingual file fields, so I'm not really sure there's any reason for me to leave this assigned to myself.