You are here:  » Filter - If Contains Then Text After


Filter - If Contains Then Text After

Submitted by chessyb on Wed, 2016-01-06 11:22 in

Hello,

Is there any filter that can be added that looks for a certain word in the 'Buy URL' and appends a click ref to the end of the link depending on what affiliate network the 'Buy URL' is?

Thanks,

- Quentin

Submitted by support on Wed, 2016-01-06 11:59

Hello Quentin,

A "Text After If" filter would be straight forward to implement - add the following to includes/filter.php to add to your installation...

  /*************************************************/
  /* textAfterIf */
  /*************************************************/
  $filter_names["textAfterIf"] = "Text After If";
  function filter_textAfterIfConfigure($filter_data)
  {
    widget_textBox("If Contains","search",TRUE,$filter_data["search"],"",3);
    widget_textBox("Text","text",TRUE,$filter_data["text"],"",3);
  }
  function filter_textAfterIfValidate($filter_data)
  {
    if (!$filter_data["search"])
    {
      widget_errorSet("search","required field");
    }
    if (!$filter_data["text"])
    {
      widget_errorSet("text","required field");
    }
  }
  function filter_textAfterIfExec($filter_data,$text)
  {
    if (strpos($text,$filter_data["search"])!==FALSE)
    {
      return $text.filter_recordPlaceholders($filter_data["text"]);
    }
    else
    {
      return $text;
    }
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by chessyb on Wed, 2016-01-06 14:44

Hi David,

That was quick and it works perfectly. Thank you for providing such great support!

- Quentin