Custom field php code #95

Closed
opened 2017-06-01 14:44:14 +00:00 by JohnnyMcWeed · 3 comments
JohnnyMcWeed commented 2017-06-01 14:44:14 +00:00 (Migrated from github.com)

Could somebody tell me, when/where the php code in custom fields is being used by the compiler? Because at the moment I don't know why my field is not behaving as expected by me. Moreover I couldn't find anything in 07 Advanced Fields

  • Take the Sermon Preacher field
  • Change the php line $query->where($db->quoteName('a.published') . ' = 1'); to $query->where($db->quoteName('a.published') . ' = 5');
  • Re-install component

My expected behaviour:
Even if I have got any preachers, I should not be able to see them when creating a sermon, as their published state is not 5.

Result:
It still uses $db->quoteName('a.published') . ' = 1'

Could somebody tell me, when/where the php code in custom fields is being used by the compiler? Because at the moment I don't know why my field is not behaving as expected by me. Moreover I couldn't find anything in [07 Advanced Fields](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=7) - Take the `Sermon Preacher` field - Change the php line `$query->where($db->quoteName('a.published') . ' = 1');` to `$query->where($db->quoteName('a.published') . ' = 5');` - Re-install component My expected behaviour: Even if I have got any preachers, I should not be able to see them when creating a sermon, as their published state is not 5. Result: It still uses `$db->quoteName('a.published') . ' = 1'`
ro-ot commented 2017-06-01 21:06:07 +00:00 (Migrated from github.com)

I am not sure I understand what you are trying to do. To show you how the compiler adds and uses the custom code in the custom fields is easy.

c_Fields.php line 1934 is where the custom field gets build, or lets say where it gets added to one of the JFormField files. There are four JFormField files/options at this time:

In the tutorials only some of this is explained, but enough that if you know how Joomla usually builds custom fields you will easily be able to understand what is being done.

Then are you sure that you are editing the correct field, I know Sermon Distributor has two custom field for Sermon Preacher and I am not sure which one gets used to build the JFormField for Preachers. JCB does not change the custom code on compilation, it simply adds it. So you should check preachers.php line 150 to see the custom code.

I am not sure I understand what you are trying to do. To show you how the compiler adds and uses the custom code in the custom fields is easy. [c_Fields.php line 1934](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/helpers/compiler/c_Fields.php#L1934) is where the custom field gets build, or lets say where it gets added to one of the JFormField files. There are four JFormField files/options at this time: - [JFormFieldCheckboxes.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JFormFieldCheckboxes.php) - [JFormFieldList.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JFormFieldList.php) - [JFormFieldRadio.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JFormFieldRadio.php) - [JFormFieldUser.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JFormFieldUser.php) In the tutorials only some of this is explained, but enough that if you know how Joomla usually builds custom fields you will easily be able to understand what is being done. Then are you sure that you are editing the correct field, I know Sermon Distributor has two custom field for _Sermon Preacher_ and I am not sure which one gets used to build the JFormField for Preachers. JCB does not change the custom code on compilation, it simply adds it. So you should check [preachers.php line 150](https://github.com/SermonDistributor/Joomla-3-Component/blob/master/admin/models/fields/preachers.php#L150) to see the custom code.
JohnnyMcWeed commented 2017-06-02 06:35:12 +00:00 (Migrated from github.com)

What I finally like to achieve is a customization of my query. So finally I'd like to adjust the where clause.
But at the moment, if I adjust the Sermon Preacher custom php, it's not taken into account when compiling the component.

(To explain better: The field is Sermon Preacher, the same as is listed in the admin view Above the tabs. Therefore I think that it should use the new php line entered above. But it's not.
The other one you mean is Sermon Preacher (request id), but I'm sure I used the right one, as it links to the right field from the view)
bildschirmfoto vom 2017-06-02 08-32-15
bildschirmfoto vom 2017-06-02 08-30-46
bildschirmfoto vom 2017-06-02 08-30-11

What I finally like to achieve is a customization of my query. So finally I'd like to adjust the where clause. But at the moment, if I adjust the Sermon Preacher custom php, it's not taken into account when compiling the component. (To explain better: The field is _Sermon Preacher_, the same as is listed in the admin view _Above the tabs_. Therefore I think that it should use the new php line entered above. But it's not. The other one you mean is _Sermon Preacher (request id)_, but I'm sure I used the right one, as it links to the right field from the view) ![bildschirmfoto vom 2017-06-02 08-32-15](https://cloud.githubusercontent.com/assets/9844452/26713717/4bdd20b8-476e-11e7-9e49-6a795bfca086.png) ![bildschirmfoto vom 2017-06-02 08-30-46](https://cloud.githubusercontent.com/assets/9844452/26713718/4bddbe74-476e-11e7-8399-5f8f938960b6.png) ![bildschirmfoto vom 2017-06-02 08-30-11](https://cloud.githubusercontent.com/assets/9844452/26713719/4be3d688-476e-11e7-8ee1-0bae52d5e14c.png)

Okay give me a Teamviewer access to take a look, this has never happened with me that I change those values an then they don't get used.... strange issue really. You can email the details when you are ready.

Okay give me a Teamviewer access to take a look, this has never happened with me that I change those values an then they don't get used.... strange issue really. You can email the details when you are ready.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#95
No description provided.