User tests: Successful: Unsuccessful:
This PR adds a new property to JModelAdmin categoriesContext
.
The porpose of this new property is to be able to define the categories context (aka extension) in the item model.
This is useful when you have several items with categories in the same component. Examples:
If empty or null one assume we are using the default context for that component, ie, the component (ex: com_mycomponent).
Just a new property. Code review.
Don't really know...
mantainers, if ok i can add this property to all models that use categories for code consistency.
This is needed for the GsoC multilingual project where we need to know when a component uses several items, if those each of those items support categories and with what context.
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Title |
|
I have tested this item
mantainers, if ok i can add this property to all models that use categories for code consistency.
I am afraid but I can't see the need for this property, why this can't be defined at the concrete class level?
This is needed for the GsoC multilingual project where we need to know when a component uses several items, if those each of those items support categories and with what context.
How else can we know this?
@andrepereiradasilva show me the code, because you are not doing anything with the property on this level why do you need to declare it on this level
hmm sorry to ask that, but can't you add just an test if that variable exists on the child of JModelAdmin?
isset(it[$key]->model->get('categoryContext')) && $it[$key]->model->get('categoryContext') ? ..
then you won't need to introduce another property, where people wonder what it's all about :-)
Keep up your good work! Really awesome how much work you put into that project!
Let me try to explain this better:
Just for the sake of an example, imagine a component for some library (com_library), we will have something like this:
&extension=com_library.authors
)&extension=com_library.books
)As you can see in this case you can't use only &extension=com_library
for the categories because you have two categories contexts.
That is how it works now.
Now, in com_associations, if those items support language associations we need to get all those item types and theit correct category contexts (aka extension). Because categories support associations too.
So, for com_associations to support components with multiple itemtypes (each one using categories) we need to know the category context (aka extension) of each item type.
That i know of this isn't declared anywhere in joomla, ie, the category context (aka extension) is always hardcoded in links or xml files).
So this new property would allow extension developers to do just that by overriding the property in their model.
And, for code consistency, i proposed also to add this property to all models that use categories.
Where is the place you will set the property?
For example here: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/models/contact.php#L31
For contacts there is only one item type (contact
) so there is no need for that (if null or empty it will use the component name com_contact
as the categories context), but in this case we could use:
protected $categoriesContext = 'com_contact';
Because the context is already com_contact
/administrator/index.php?option=com_categories&extension=com_contact
OK, so why not declaring the property there. You have to set it there anyway.
Please see the associationsContext property in JModelAdmin (https://github.com/joomla/joomla-cms/blob/staging/libraries/legacy/model/admin.php#L88) ...
that is overrided by the Item Type Model (https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/models/contact.php#L32).
I just followed the same principle...
This is different, associationsContext is used in the class. I don't think it is right to define properties at a certain level when we don't use them at a certain level.
ok i see now what you mean.
i'm going to close this them.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-14 19:07:11 |
Closed_By | ⇒ | andrepereiradasilva |
I have tested this item✅ successfully on
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11590.