1

I am creating my own custom field type, and my replace_tag function is as follows:

function replace_tag($data, $params = array(), $tagdata = FALSE) {

    return $data; // NULL

}

The problem, as noted in the code, is that $data has no value. I have verified that the channel entry i'm display is correct, that field's data is properly stored in the database, and that if I manually set a value for $data inside the replace_tag() function, it prints to the template just fine.

Any suggestions as to what could be going wrong?

Thanks!

P.S. I started a thread here but never got responses. Trying this instead.

2
  • Are you using a pre_process function in your fieldtype? If so, you might check to ensure that it's not returning null. Aug 12, 2013 at 18:35
  • That ended up being the cause of the problem. Thanks!
    – ridgehkr
    Aug 13, 2013 at 16:44

1 Answer 1

1

As pointed out by Rob Sanchez, my pre_process function wasn't returning field data.

If you have the pre_process function in your fieldtype class file but it doesn't return the $data parameter that it accepts, nothing will get passed to the replace_tag() function.

(Edit: clarity)

3
  • Please consider adding more information to your answer to help future users if they come across the same problem.
    – Anna_MediaGirl
    Aug 13, 2013 at 16:56
  • 1
    Okay, thanks for the tip. Just added more to this post.
    – ridgehkr
    Aug 19, 2013 at 19:04
  • Also, you can select your answer as "correct" by clicking on the checkmark screencast.com/t/6Mus8tHrTRN
    – Anna_MediaGirl
    Aug 22, 2013 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.