Joomla Component Fields

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
jm_joomla
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Sun Nov 05, 2017 10:53 pm

Joomla Component Fields

Post by jm_joomla » Mon Jun 18, 2018 10:06 am

Hi,

I have been trying to understand where Joomla sets the values of the following fields (so that I can do something similar in a new type of component):-

created_user_id/created_by
modified_user_id/modified_by

Scanning the complete installation of Joomla for the string "modified_", for example, I find the most likely code to be in:

libraries/src/Table/<component_name>.php

in the "store" method. However, I read there that something about that code is deprecated and is due to disappear "upon completion of transition to UCM", whatever that is.

Q1a) Unless and until such a transition is completed, would it be "in the Joomla way" to create an entry in that "libraries\src/Table" area for my component, with a similar entry for the "store" method, in order to support the capturing of the who/when parameters for creation/modification?

Q1b) If not, where else in the Joomla installation should I look for examples for existing components?

Q2) What is UCM and when will the aforementioned transition be complete (i.e. in which Joomla version and on which timescale)?

Many thanks,

John,
Abingdon, UK.
Last edited by toivo on Mon Jun 18, 2018 12:07 pm, edited 1 time in total.
Reason: mod note: moved to 3.x Coding

User avatar
fcoulter
Joomla! Ace
Joomla! Ace
Posts: 1685
Joined: Thu Sep 13, 2007 11:39 am
Location: UK
Contact:

Re: Joomla Component Fields

Post by fcoulter » Mon Jun 18, 2018 5:36 pm

So far as I know the UCM was a project to have each type of Joomla content, eg articles, contacts, weblinks etc have a unified structure.

But now the working group behind it seems to be inactive, see https://docs.joomla.org/Unified_Content ... king_Group so probably there will not be any further work on this in the near future.

Joomla does include some ucm tables, eg ucm_content, which is used by the tags component (and possibly in other ways). I am not sure that it is the ideal way to do things but it is what it is.

But to answer your actual question, I don't think that there is a problem with doing what you propose.
http://www.spiralscripts.co.uk for Joomla! extensions
http://www.fionacoulter.com/blog my personal website
Security Forum moderator :: VEL team member
"Wearing my tin foil hat with pride"

jm_joomla
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Sun Nov 05, 2017 10:53 pm

Re: Joomla Component Fields

Post by jm_joomla » Tue Jun 19, 2018 9:19 am

Hi fcoulter,

Thank you for your reply.

Not quite sure what the mechanism is for the table class/methods in the files:-

libraries\src\Table\<component>.php

to be called/inherited. Each is introduced by a statement like:-

class Content extends Table

whereas all the files that I have seen in the "tables" subdirectory of components begin with a statement like:-

<subclass> extends JTable

or

<subclass> extends JTable<other_qualifier>

The table class for my new component extends JTable. At present, without any file for that component in the

libraries\src\Table

directory, there do not appear to be any "gaps" in the inheritance chain from JTable down towards Object. At least, no errors are reported.

My question is, how any file I created in that directory for my component would be in any way relevant (i.e. be called/inherited). What additional measures would I have to take so that its class (say, <mynewcomp> extends Table) would appear in the inheritance chain for JTable.

Alternatively, it could be that I am working under a complete misapprehension as to how this should work.

Any light hat you can throw on this would be much appreciated.

Many thanks,

John,
Abingdon, UK.

User avatar
fcoulter
Joomla! Ace
Joomla! Ace
Posts: 1685
Joined: Thu Sep 13, 2007 11:39 am
Location: UK
Contact:

Re: Joomla Component Fields

Post by fcoulter » Tue Jun 19, 2018 10:17 am

Any light hat you can throw on this would be much appreciated.
Would a soft flat cap be any good?

Seriously, there are a few things to understand about Joomla which may help you get to grips with this.

Firstly a lot of Joomla works by using naming conventions to tell it which classes to use and where to find them. This happens behind the scenes so that (often) you just need to make sure that you name things in the expected way and put them in the right place for them to be found and used by the system.

In the case of tables, they are actually loaded by the component model. The model expects the table class to be named for the type of item, and be located in the tables folder of the component administrator section. And the model itself will likely extend a parent class such as AdminModel, or ListModel, which will do a lot of the actual heavy lifting.

Secondly, Joomla is in the process of moving away from the old system of naming classes to a new system of namespaced classes. The old class names such as JTable are actually aliases. If you look in Joomla libraries folder you will see that there is a file called classmap.php, which maps the class names to their actual classes.

You can carry on using JTable etc for now, I think that the plan is that they will be available for the lifetime of Joomla 4, to ensure backwards compatibility, although I may be wrong about that. But if you are writing a new component you would probably do a lot better to use the namespaced classes, because that will be more future-proof. So you might take a look at Joomla 4, and see how the core components handle this.

I hope that this is helpful.
http://www.spiralscripts.co.uk for Joomla! extensions
http://www.fionacoulter.com/blog my personal website
Security Forum moderator :: VEL team member
"Wearing my tin foil hat with pride"

jm_joomla
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Sun Nov 05, 2017 10:53 pm

Re: Joomla Component Fields

Post by jm_joomla » Tue Jun 19, 2018 11:09 am

Hi fcoulter,

I was aware of some of the Joomla naming conventions. In particular:
In the case of tables, they are actually loaded by the component model. The model expects the table class to be named for the type of item, and be located in the tables folder of the component administrator section. And the model itself will likely extend a parent class such as AdminModel, or ListModel, which will do a lot of the actual heavy lifting.
My state of knowledge is such that I could believe that the Table class (component agnostic) might be in the inheritance chain of JTable (also component agnostic). However, my imagination was not rich enough to stretch to the possibility of <mynewcomponent> (a component-specific class and one specialised from the Table class) could be in the inheritance chain of a component agnostic class like JTable.

However, your most recent reply suggests that I should simply suspend my disbelief!

Regards,

John,
Abingdon, UK.


Locked

Return to “Joomla! 3.x Coding”