Hello and thank you for your module.

Can anyone be so kind as to point at a possible way I might be able to reference other fields that I am mapping to my feed node?

for example, if I have a 'field1' and 'field2', can I use php code (in feeds tamper php) for 'field1', to reference the value I have for 'filed1'?

I know $item and $field are available. But can I do something like:

if field1 == 'news feed' then return '

'.$field.'

';

---

I am trying to use querypath to import html from various pages that each have a unique div structure.

Thanks for reading!

Comments

meSte’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

e.g. if you're importing a CSV file with fields named "Field1" and "Field2", the corresponding values for each line will be available in $item['field1'] and $item['field2']. (Please note that keys in $item are always lowercase!)

Please, read before posting.

Also, it's worth to mention that this module is made for DEVELOPERS, not for end users. You really shouldn't use it unless you know what you're doing.

timfelix’s picture

Status: Closed (works as designed) » Active

Thank you meSte,

I worded my question poorly.

Basically, I'm trying to change my queryPath expression (css selector) based on the value of another filed in my feed node.
so if the node I am updating has another field 'field_feed_type' with value 'NEWS' then my queryPath selector should equal 'div.newsText'.. and if 'field_feed_type' == 'ARTICLE' then queryPath selector is div.articleText

I'll keep looking for an approach.. this may not be related to feeds tamper php.

meSte’s picture

This module just exposes two variables: $field and $item. $field is the current field being tampered and $item is a keyed array with all the fields read by Feeds, altered by Feeds Tamper and about to be imported (created or updated).
I really don't think it's related to your issue.
First of all: are you using Feeds to import those (i guess) HTML pages?
Have you tried QueryPath and Feeds QueryPath Parser?

timfelix’s picture

hey meSte,

Thank you for your advice. This helped.
The $item array has everything I need.

meSte’s picture

Status: Active » Closed (works as designed)
honza pobořil’s picture

Component: Miscellaneous » User interface
Category: Support request » Task
Status: Closed (works as designed) » Active

I think $item should be mentioned in GUI in description of PHP code field. (Currently there is described only $field variable.)

meSte’s picture

Priority: Normal » Minor
Status: Active » Needs work
meSte’s picture

Title: Get value of other fileds » Improve PHP code field description

$item should definitely be mentioned in the PHP code field description.

geek-merlin’s picture

Title: Improve PHP code field description » Mention and explain $item in PHP code field description
Status: Needs work » Active

Yes, really.

Setting active, as needswork implies there is already a patch.

geek-merlin’s picture

Note: this should really be called $fields...

  • meSte committed 246b8d2 on
    Issue #2284761: Mention and explain  in PHP code field description
    
meSte’s picture

Status: Active » Closed (fixed)