3

I'm making a Views Plugin, a 'format type', and when I use CiviCRM Contact Gender as a field, it returns a Gender ID. That's to be expected. But when I use the other Views formats (HTML, grid, etc) it shows the actual gender.

Does anyone know why it is changing it to male, female etc on the standard ones, but leaving it as an ID on my new format?

Thanks,

Update - to be clear I understand that this is stored in the contact table as an ID that is looked up elsewhere. My question is - does anyone know how it's being looked up in the options table by standard views plugins, but not by mine?

3
  • 1
    I hope you know that gender_id is stored as numbers in the civicrm_contact table in the database. The actual label of Man and Woman is stored in a different table civicrm_option_value. So probably the pre-existing Views has made that connection already, but not the ones you create
    – Flying
    Sep 26, 2016 at 7:58
  • Updated ticket to answer Flying's question. To confirm, I did understand that. My question is, how do existing Views do that?
    – JohnFF
    Sep 26, 2016 at 8:37
  • I don't know, that is why I din't answer, just commented:-)
    – Flying
    Sep 26, 2016 at 8:39

1 Answer 1

2

Take a look at the file civicrm_handler_field_pseudo_constant.inc - this is what handles the option value lookup.

2
  • Thank you Coleman - I'll accept your answer and give more detail when I've tried it out :)
    – JohnFF
    Sep 26, 2016 at 15:09
  • 1
    In case it's useful to anyone, the exact change I needed was to include $this->render_fields() around $view->result in the render() function of the views_plugin inheriting class. The output is then in views->style_plugin->rendered_fields.
    – JohnFF
    Sep 27, 2016 at 11:20

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.