Joomla fields and category field don't cooperate #561

Closed
opened 2020-05-27 11:08:43 +00:00 by Nikos111 · 10 comments
Nikos111 commented 2020-05-27 11:08:43 +00:00 (Migrated from github.com)

Steps to reproduce the issue

I created a view with list and edit instance and among other things, it includes a category field. In addition, the view was set to have custom Joomla fields.
After my component installation, when i set the view categories and go to add custom joomla fields, the Category Field does not appear.
After a quick investigation, I found that in order for the category field to appear, it would be necessary to:

  1. Set "Edit/Create Site View" in component view settings
    2a. Change the "context" in the address bar from "?option=com_fields&view=
    field&layout=edit&context=#mycomponent#.#VIEW#" to "?option=com_fields&view=
    field&layout=edit&context=#mycomponent#.#VIEWS#"
    OR
    2b. Change the class in components\com_componentbuilder\compiler\joomla_3 -> Helper_category_view.php, in to points:
    • In line 23 {class ###Component######Views###Categories extends JCategories} changes to {class ###Component######View###Categories extends JCategories}
    • In line 34 {$options['extension'] = 'com_###component###.###views###';} changes to {$options['extension'] = 'com_###component###.###view###';}

Expected result

appear

Actual result

not

Additional comments

Is this a CB error or have I misunderstood something?

Thanks

### Steps to reproduce the issue I created a view with list and edit instance and among other things, it includes a category field. In addition, the view was set to have custom Joomla fields. After my component installation, when i set the view categories and go to add custom joomla fields, the Category Field does not appear. After a quick investigation, I found that in order for the category field to appear, it would be necessary to: 1. Set "Edit/Create Site View" in component view settings 2a. Change the "context" in the address bar from "?option=com_fields&view= field&layout=edit&context=#mycomponent#.#VIEW#" to "?option=com_fields&view= field&layout=edit&context=#mycomponent#.#VIEWS#" OR 2b. Change the class in components\com_componentbuilder\compiler\joomla_3 -> Helper_category_view.php, in to points: * In line 23 {class ###Component######Views###Categories extends JCategories} changes to {class ###Component######View###Categories extends JCategories} * In line 34 {$options['extension'] = 'com_###component###.###views###';} changes to {$options['extension'] = 'com_###component###.###view###';} ### Expected result ![appear](https://user-images.githubusercontent.com/25500384/83011772-1e3f8400-a023-11ea-8136-6a7da84d3576.JPG) ### Actual result ![not](https://user-images.githubusercontent.com/25500384/83011815-2eeffa00-a023-11ea-8c82-fce249ab970d.JPG) ### Additional comments Is this a CB error or have I misunderstood something? Thanks

The Category field behavior is really fully managed by Joomla. This is the documentation, but to see it work, or to see the best practice you should import the SermonDistributor JCB package. The SD use the category field in a very strait forward way.

You can also see it in action in JCB itself outsource, and there is this turorial.

So let me know if you have any further issue, if not please close the issue.

The Category field behavior is really fully managed by Joomla. This is the [documentation](https://docs.joomla.org/Category_form_field_type), but to see it work, or to see the best practice you should import the [SermonDistributor](https://github.com/SermonDistributor/Joomla-3-Component/blob/master/admin/models/forms/sermon.xml#L158) [JCB](https://vdm.bz/how-to-install-jcb-packages) package. The SD use the category field in a very strait forward way. You can also see it in [action in JCB itself outsource](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/models/forms/field.xml#L225), and there [is this turorial](https://youtu.be/9NO2rKnC6Ug?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=29m24s). So let me know if you have any further issue, if not please close the issue.
Nikos111 commented 2020-05-27 15:29:46 +00:00 (Migrated from github.com)

Concerns arise in the occurrence of a category field in a custom joomla field. Otherwise the item works just fine
I insist on that and I warmly ask you to see it in action.

Concerns arise in the occurrence of a category field in a custom joomla field. Otherwise the item works just fine I insist on that and I warmly ask you to see it in action.

The category field is one of those type of fields that has a number of constraints. The moment you need to have something more then is allowed within those constraints, then you must create your own "type" view and use it instead.

So the first and most important feature constraint is the there can only be one category field per/view. So adding it to the repeatable field will cause all kind of conflict.

So I would advise to build a type (custom category) view, and use it instead. I use that approach all the time, and since we can in JCB do this so easy there is really no down side, but this in fact gives you a far greater control over the behavior.

These constraints were realized due to integration with the Joomla category component, and how it works in relationship with the router and all sorts of other areas in Joomla, like even the history mapping.

The category field is one of those type of fields that has a number of constraints. The moment you need to have something more then is allowed within those constraints, then you must create your own "type" view and use it instead. So the first and most important feature constraint is the there can only be **one category field per/view**. So adding it to the repeatable field will cause all kind of conflict. So I would advise to build a type (custom category) view, and use it instead. I use that approach all the time, and since we can in JCB do this so easy there is really no down side, but this in fact gives you a far greater control over the behavior. These constraints were realized due to integration with the Joomla category component, and how it works in relationship with the router and all sorts of other areas in Joomla, like even the history mapping.
Nikos111 commented 2020-05-28 08:02:17 +00:00 (Migrated from github.com)

I think there has been a misunderstanding. Please follow the procedure below:

  1. Create a view, with list and edit appearance ( Also state that it will have a site edit / view)
    siteview

  2. create a category field and include it in the view.
    fieldcat
    view

  3. State that the view will also have custom joomla fields (see first image)

  4. installation
    menu

  5. Add categories for view
    editcat

  6. Try to create a joomla field

  7. This is where you will see that there is NO category field while it should be !!
    jfield

  8. See how the category field appears in custom fields for joomla's com_content
    articles
    article

Here are the comparative files (joomla core and CB produced)
contentcategoryphp
myclass
Καταγραφή

I hope I raised the issue precisely

I think there has been a misunderstanding. Please follow the procedure below: 1. Create a view, with list and edit appearance ( Also state that it will have a site edit / view) ![siteview](https://user-images.githubusercontent.com/25500384/83112926-8f3c7580-a0cf-11ea-85b0-0c3d4c5f3367.JPG) 2. create a category field and include it in the view. ![fieldcat](https://user-images.githubusercontent.com/25500384/83112970-a2e7dc00-a0cf-11ea-9401-e400b29276de.JPG) ![view](https://user-images.githubusercontent.com/25500384/83113255-12f66200-a0d0-11ea-88c9-8e724e6d0d5b.JPG) 3. State that the view will also have custom joomla fields (see first image) 4. installation ![menu](https://user-images.githubusercontent.com/25500384/83113599-8dbf7d00-a0d0-11ea-8565-90bd69cb55e3.JPG) 5. Add categories for view ![editcat](https://user-images.githubusercontent.com/25500384/83113488-649eec80-a0d0-11ea-8e15-d26ecdbd987d.JPG) 6. Try to create a joomla field 7. This is where you will see that there is NO category field while it should be !! ![jfield](https://user-images.githubusercontent.com/25500384/83113615-9617b800-a0d0-11ea-8304-1871d30fb6d8.JPG) 8. See how the category field appears in custom fields for joomla's com_content ![articles](https://user-images.githubusercontent.com/25500384/83113638-9dd75c80-a0d0-11ea-80b7-59073c602cef.JPG) ![article](https://user-images.githubusercontent.com/25500384/83114085-2d7d0b00-a0d1-11ea-98d0-e3bb842ef176.JPG) Here are the comparative files (joomla core and CB produced) ![contentcategoryphp](https://user-images.githubusercontent.com/25500384/83115041-78e3e900-a0d2-11ea-981f-0d8487f5154e.JPG) ![myclass](https://user-images.githubusercontent.com/25500384/83115057-7f726080-a0d2-11ea-9c2c-b597afc6ddf8.JPG) ![Καταγραφή](https://user-images.githubusercontent.com/25500384/83115069-839e7e00-a0d2-11ea-89ad-3cbb0cfd054b.JPG) I hope I raised the issue precisely

The category field has different implementation options and it is all determined by how you set it up. So since you setup the category field, JCB just builds what you asked for. Categories can be linked to one view, or it could be linked to the whole component. This options of linking it to the whole component is how the content area in Joomla core is setup.

So just for you I make this quick tutorial. Please take a look, as I will push a fix to address the problem of the sub-menu, but you must understand the implementation.

The category field has different implementation options and it is all determined by how you set it up. So since you setup the category field, JCB just builds what you asked for. Categories can be linked to one view, or it could be linked to the whole component. This options of linking it to the whole component is how the content area in Joomla core is setup. So just for you I make this [quick tutorial](https://youtu.be/MMrHDUNBhsk). Please take a look, as I will push a fix to address the problem of the sub-menu, but you must understand the implementation.
Nikos111 commented 2020-05-28 20:57:27 +00:00 (Migrated from github.com)

Good evening dear Llewellynvdm.
First of all, all of the above is already known to me. Forgive me for putting you in the process of devoting time to the seminar.
But...
Because I found very useful to match custom joomla fields with targeted view with categorized data, I did a deeper search for why you don't see the view-related category in the view-related joomla custom fields.
So I found that:
The submenu (eg Items Fields) creates a link with content "? Option = com_fields & view = fields & context = com_mycomponenet.item" in a list view ('item' is one view of my componenet).
When I type "New Field" (or Edit) the link becomes "? Option = com_fields & view = field & layout = edit & context = com_mycomponenent.item". In fact! I am in the process of adding a new joomla field. But the coveted Category Select field is missing !! (Of course, I made sure to create some categories for this view earlier).
Well, I found that joomla uses "context = com_mycomponenent.item" and is looking to find a class called "MycomponentItemCategories" in helpers in the Site part of the component. Really, there CB has made the categoryitems.php in which, however, there is the MycomponentItemsCategories class and not MycomponentItemCategories (one s does the damage !!!).
Then I said, let's look to see how this class is created. And I saw that it is created from the frame-file -> components \ com_componentbuilder \ compiler \ joomla_3 \ Helper_category_view.php. So I thought, let's see what happens if I modify it so that it matches what joomla wants. So I made the two changes I suggested in my first post and Here it, People enjoy it.
neo
I may be making a big mistake and this is causing a stroke elsewhere, but it works ... And maybe it's very, very useful for everyone. And the reason is that this way I can match specific custom fields to specific categories in individual view.
You know better.
Thank you for your patience

Good evening dear Llewellynvdm. First of all, all of the above is already known to me. Forgive me for putting you in the process of devoting time to the seminar. But... Because I found very useful to match custom joomla fields with targeted view with categorized data, I did a deeper search for why you don't see the view-related category in the view-related joomla custom fields. So I found that: The submenu (eg Items Fields) creates a link with content "? Option = com_fields & view = fields & context = com_mycomponenet.item" in a list view ('item' is one view of my componenet). When I type "New Field" (or Edit) the link becomes "? Option = com_fields & view = field & layout = edit & context = com_mycomponenent.item". In fact! I am in the process of adding a new joomla field. But the coveted Category Select field is missing !! (Of course, I made sure to create some categories for this view earlier). Well, I found that joomla uses "context = com_mycomponenent.item" and is looking to find a class called "MycomponentItemCategories" in helpers in the Site part of the component. Really, there CB has made the categoryitems.php in which, however, there is the MycomponentItemsCategories class and not MycomponentItemCategories (one s does the damage !!!). Then I said, let's look to see how this class is created. And I saw that it is created from the frame-file -> components \ com_componentbuilder \ compiler \ joomla_3 \ Helper_category_view.php. So I thought, let's see what happens if I modify it so that it matches what joomla wants. So I made the two changes I suggested in my first post and Here it, People enjoy it. ![neo](https://user-images.githubusercontent.com/25500384/83192119-c8133380-a13d-11ea-8f64-2af5203fce93.JPG) I may be making a big mistake and this is causing a stroke elsewhere, but it works ... And maybe it's very, very useful for everyone. And the reason is that this way I can match specific custom fields to specific categories in individual view. You know better. Thank you for your patience

@Nikos111 yes I noticed this issue, I did not mention it in the seminar... but I will in fixing the sub-menu also try to address that issue. We basically need to make sure the com_mycomponenent.item is set correctly everywhere in its relationships. Believe me I understand the pain of bringing all this to work as expected. JCB is trying to take care of everything, without taking over Joomla's work.

What you should also take into account is that Joomla has also been improving, changing and what worked a few months ago could now be broken. Yet that is why JCB is in the community so that other can help me keep an eye on all the changes.

Then there is the actual edge cases issue. Meaning that everyone using JCB has there own way of using it, and I have been supersized to see how different it is from how I use it. SO without being selfish I must admit I am still developing JCB to work well for me. This said I am always open to code contributors who can proof that they understood the problem (in issues like these), and has in solving this one issue did not cause ten more.

So well done, I will take your contribution and code it into JCB best I can, when I can. Should you feel at liberty to commit the code, go head and make a pull request.

@Nikos111 yes I noticed this issue, I did not mention it in the seminar... but I will in fixing the sub-menu also try to address that issue. We basically need to make sure the `com_mycomponenent.item` is set correctly everywhere in its relationships. Believe me I understand the pain of bringing all this to work as expected. JCB is trying to take care of everything, without taking over Joomla's work. What you should also take into account is that Joomla has also been improving, changing and what worked a few months ago could now be broken. Yet that is why JCB is in the community so that other can **help me** keep an eye on all the changes. Then there is the actual edge cases issue. Meaning that everyone using JCB has there own way of using it, and I have been supersized to see how different it is from how I use it. SO without being selfish I must admit I am still developing JCB to work well for me. This said I am always open to code contributors who can proof that they understood the problem (in issues like these), and has in solving this one issue did not cause ten more. So well done, I will take your contribution and code it into JCB best I can, when I can. Should you feel at liberty to commit the code, go head and make a pull request.

@Nikos111 I have pushed the changes to the staging branch, please test and let me know. This first round I just fixed the category naming issue that seemed like the main object of your focus. I will still fix the sub-menu issue in the next few days.

@Nikos111 I have pushed the changes to the staging branch, please test and let me know. This first round I just fixed the category naming issue that seemed like the main object of your focus. I will still fix the sub-menu issue in the next few days.

@Nikos111 I have added further notice to the compiler where it detects mismatching, see latest push to staging branch. I made this quick tutorial to guide all to fix their category mix-up (Joomla changed). Looking at the latest code change, and this tutorial you will realize this is not small issue to fix, but I took this moment to jump at it. There may still be more small changes need, I will appreciate if you can test and check if you still find some inconsistency.

@Nikos111 I have added further notice to the compiler where it detects mismatching, see latest push to staging branch. I made this [quick tutorial](https://youtu.be/R4WQgcu6Xns) to guide all to [fix their category mix-up](https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95) (Joomla changed). Looking at the [latest code change](https://github.com/vdm-io/Joomla-Component-Builder/commit/70635ff6f06b3d6123060ff18430a584cf26f529), and this tutorial you will realize this is not small issue to fix, but I took this moment to jump at it. There may still be more small changes need, I will appreciate if you can test and check if you still find some inconsistency.
dformdotdk commented 2021-03-26 15:14:35 +00:00 (Migrated from github.com)

Just tried to add Joomla fields to multiple admin views, and noticed the same behavior, so I guess this is still an issue?

Skærmbillede 2021-03-26 kl  16 08 05
Just tried to add Joomla fields to multiple admin views, and noticed the same behavior, so I guess this is still an issue? <img width="327" alt="Skærmbillede 2021-03-26 kl 16 08 05" src="https://user-images.githubusercontent.com/6020984/112652894-2f793d00-8e4e-11eb-8a73-a829c9ec307a.png">
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#561
No description provided.