Obviously, modifying these files is not ideal and without some kind of conditionals you won't be able to reuse playa field types for anything else, but if you must here is what I did.
The 3 files that I needed to modify:
- system/expressionengine/third_party/playa/ft.playa.php
- system/expressionengine/third_party/playa/helper.php
- system/expressionengine/third_party/playa/views/entry.php
First, in ft.playa.php
in the display_field
method you need to change the query:
$query = $this->EE->db->query(
'SELECT * FROM exp_channel_titles
WHERE entry_id '.$this->helper->param2sql($vars['selected_entry_ids']));
to join on the exp_channel_data
table and select your custom field. This is for your saved selected item(s).
Next, in helper.php
in the entries_query
method you need to change the query being built in a few places to join on the exp_channel_data
table and select your field. This is for the available unselected options. Also, in the same method under
if (isset($params['keywords']) && $params['keywords'])
you have to add a search for your custom field. This code is executed when a user is typing in the multi-select playa field via ajax to filter out entries. The filter for the single select playa field is just a javascript regex so, in that case, you need not worry about this.
Finally, you need to print your custom field in the entry.php
file.
/themes/third_party/playa/scripts/droppanes.js
. Can you elaborate a bit on how it breaks (JS erros, behavior, etc)?filter_entries()
method insystem/expressionengine/third_party/playa/mcp.playa.php
. This gets called every time you type to filter.system/expressionengine/third_party/playa/helper.php
. ...Still beyond my expertise. Maybe someone withPHP
chops can chime in.