You are here:  » How to explode a non-registered field


How to explode a non-registered field

Submitted by Convergence on Thu, 2013-07-25 22:31 in

Greetings,

Is there a way to explode a field that is not registered and in the database?

What we would like to do is a "Text After" with a non-registered field, but explode that non-registered field first.

Possible?

Submitted by support on Fri, 2013-07-26 08:04

Hi Convergence,

Have a go as follows; firstly in admin/feeds_filters.php look for the following code around line 133:

  widget_selectArray("field",$fields,$default,"Select..");
  widget_errorGet("field");

...and REPLACE with:

  widget_selectArray("field",$fields,$default,"Select..");
  widget_errorGet("field");
  print "<br />Or enter absolute field name:<br />";
  print "<input type='text' name='field_abs' value='".widget_safe($filter_data["field"])."' />";

And then the following code at line 27:

    widget_required("field");

...and REPLACE with:

    if ($_POST["field_abs"])
    {
      $_POST["field"] = $_POST["field_abs"];
    }
    else
    {
      widget_required("field");
    }

And for aesthetic reasons, so that you can see field name if added in this way, look for the following code at line 103:

  print "<td>".$fields[$filter["field"]]."</td>";

...and REPLACE with:

  print "<td>".(isset($fields[$filter["field"]])?$fields[$filter["field"]]:$filter["field"])."</td>";

With that in place, you will then be able to add a new filter by either selecting a registered field, or now by entering the field name itself exactly as seen in the sample data record shown on Feed Registration Step 2 (so easiest thing to do would be to open that page in a new window when adding the filter and copy / paste the field names across).

Finally, to get the filter to apply to the non registered field, look for the following code in includes/admin.php around line 225:

  $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);

...and REPLACE with:

  if (isset($importRecord[$filter["field"]]))
  {
    $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);
  }
  else
  {
    $filter_record[$filter["field"]] = $execFunction($filter["data"],$filter_record[$filter["field"]]);
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Sun, 2016-05-29 12:44

Bob L.

Hi David,
Hope all is well and you're in good health.
Haven't been able to use this mod on 15/09A as input for the "field select box" seem to be a required field.
I can enter the field I want in the text area box below this text.
Or enter absolute field name: Example %FIELDNAME%
But when I hit add, I get a notice box saying
"Please select an item in the list."

Submitted by support on Mon, 2016-05-30 13:37

Hello Bob,

15/09A modification to admin/feeds_filters.php for the above; Look for the following code at line 165:

{updated - see below}

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Mon, 2016-05-30 16:46

Bob L.

Still no joy Mr. David.
Just empties the Absolute Field Name and turns the Field above the select Red.

Submitted by support on Tue, 2016-05-31 11:19

Hello Bob,

Sorry about that - here's the complete modification to admin/feeds_filters.php for 15/09A:

Look for the following code at line 169:

  widget_selectArray("Field","field",TRUE,$default,array_merge(array(""=>"Select..."),$fields));

...and REPLACE with:

  widget_selectArray("Field","field",FALSE,$default,array_merge(array(""=>"Select..."),$fields));
  widget_textBox("or Absolute Field Name","field_abs",FALSE,$filter_data["field"]);

Then look for the following code at line 55:

    widget_required("field");

...and REPLACE with:

    if ($_POST["field_abs"])
    {
      $_POST["field"] = $_POST["field_abs"];
    }
    else
    {
      widget_required("field");
    }

And finally (to show the configured field if not a database field) look for the following code at line 147:

      print "<td>".$fields[$filter["field"]]."</td>";

..and REPLACE with:

  print "<td>".(isset($fields[$filter["field"]])?$fields[$filter["field"]]:$filter["field"])."</td>";

Then in admin/feeds_filters_configure.php look for the following code at line 101:

  print "<td>".$fields[$filter["field"]]."</td>";

...and REPLACE with:

  print "<td>".(isset($fields[$filter["field"]])?$fields[$filter["field"]]:$filter["field"])."</td>";

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Tue, 2016-05-31 12:58

Bob L.

Now we have that baby cooking.

Thank you ever so much. Mr. David.