I'm having trouble populating multi-value cck fields using concat.
Example
<items>
<item>
<firstname>John</firstname>
<lastname>Doe</lastname>
</item>
<item>
<firstname>Max</firstname>
<lastname>Mustermann</lastname>
</item>
</items>
This will only populate the first field with "John Doe":
context = //item
field_fullname = concat(//firstname ' ', //lastname)
With out concat it works fine. This adds "John" to the first field and "Max" to the second:
context = //item
field_fullname = //firstname
Not sure if it is even supposed to work or pre-processing of the data is necessary to achieve this?
Using latest .dev
Comments
Comment #1
Countzero commentedI'm interested in this question too.
More generally, does the module allow the use of functions like "concat", "replace" and their siblings in the expressions ?
Comment #2
twistor commentedYes the dev version supports the use of concat, et al.
@andreas_jonsson,
Might this be what you're looking for?
Comment #3
Countzero commentedUpgraded to dev version but can't get replace to function as of : http://www.w3.org/TR/xpath-functions/#func-replace.
Just trying a basic :
replace(GpsLatitudeExacte,",",".")gives an unregistered function error.
Comment #4
twistor commentedPHP only supports XPath 1.0. Replace is in 2.0.
See http://www.w3.org/TR/xpath/
Comment #5
Countzero commentedOK, "translate" did the trick.
Thanks for your help.
Comment #6
twistor commentedMarking this as fixed. Feel free to reopen.
Comment #7
shadybar commentedHaving trouble here with a feed which imports profiles, and each profile can have different positions in various departments.
We need to import the position info into a multivalue cck field and concat the values as "position::rank::dept" in each field.
The following:
Works well to populate just one value in the CCK multivalue field, but not the others. Is there something else I can try?
Thank you for your help.
Comment #8
Countzero commentedI have exactly the same problem : I discovered with amazement that the parser imports multiple values seemlessly and it 's really really great.
But unfortunately, I have to rewrite some image paths to avoid the curl error messages saying it cannot find the pictures.
As of now, I use
concat("http://example.com/sites/default/files/mypath/", Photo)to build the correct path, but as stated by the previous poster, it prevents the multivalue feature from working.Any help on this would be greatly appreciated.
Comment #9
Countzero commentedI tried to do something with Feeds Tamper but the curl error comes up before it applies its modifications, so it doesn't seem to be a solution.
Comment #10
Countzero commentedI solved my problem with some sed parsing of the original file, as I understand the implementation logic of the module is not suited for this kind of cases.
Just in case it could help some readers of this thread, here's how I rewrote the paths of my images :
This bash code will append 'new_path' before any jpg filename in original_file.xml and save it to new_file.xml. This could be done in a bash script executed in cron.
The same logic could perhaps be used to structure the source file differently.
Comment #11
shadybar commentedThank you for the posts, this is helpful.
What we ended up doing was we installed CCK 6.x-3.0-alpha3, which has the content multigroup module. Then we just created separate fields for each value, and let multigroup take care of the display.
Comment #12
twistor commentedComment #13
kenpeter commentedBased on this: http://stackoverflow.com/questions/24013046/xpath-how-to-run-concat-for-...
field_fullname: concat(firstname, ' ', lastname)will only return the first result. We need to use php to iternate.field_fullname: concat(firstname[n], ' ', lastname[n])