Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for EE4 #63

Open
pixelclef opened this issue Feb 23, 2018 · 1 comment
Open

Support for EE4 #63

pixelclef opened this issue Feb 23, 2018 · 1 comment

Comments

@pixelclef
Copy link

Would love some discussion on making this work in EE4.

I've made the modifications in Support for EE3. That resolves installing the plugin as before, but there is a new error being thrown as a result of the database structure changes.

error-message

@Zignature
Copy link

Zignature commented May 7, 2020

I got it working on EE 4.3.8 :)

I'm not much of a PHP programmer or a SQL master let alone an EE developer, so it took me all day...

The SQL SELECT statement on line 117 in pi.json.php is obsolete.
There have been database changes since EE 2.11.9, so the SQL statement queries fields that aren't present anymore.
The original SQL statement queried two tables with a single JOIN. The SQL statement I created queries four (!) tables with three (!) joins.

To make it work on EE 4.3.8:
First you need to apply the modifications mentioned here: Support for EE3

Then you need to replace this code that starts around line 117:
$this->entries_custom_fields = ee()->db->select('channel_fields.*, channels.channel_id') ->from('channel_fields') ->join('channels', 'channel_fields.group_id = channels.field_group') ->where('channels.site_id', ee()->config->item('site_id')) ->where_in('channels.channel_name', explode('|', ee()->TMPL->fetch_param('channel'))) ->get() ->result_array();

With:
$this->entries_custom_fields = ee()->db->select('channel_fields.*') ->from('channel_fields') ->join('channel_field_groups_fields', 'channel_fields.field_id = channel_field_groups_fields.field_id') ->join('channels_channel_field_groups', 'channel_field_groups_fields.group_id = channels_channel_field_groups.group_id') ->join('channels', 'channels_channel_field_groups.channel_id = channels.channel_id') ->where('channels.site_id', ee()->config->item('site_id')) ->where_in('channels.channel_name', explode('|', ee()->TMPL->fetch_param('channel'))) ->get() ->result_array();

It works like a charm so far on my EE 4.3.8 box. It may even work for EE5.

Since I haven't done any thorough testing I do not recommend using this on a production site, and I certainly won't accept any liability for any damages or what have you.

I'd love to get feedback on this, cause it may be improved by some better developer/coder than me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants