ContentModelArticle, JTableContent - which should be used to create articles?

30 views
Skip to first unread message

Michelle Martel

unread,
Aug 23, 2021, 3:54:52 PM8/23/21
to Joomla! General Development

Hi, I am developing a plugin that loads data from an external source then creates articles.  Searching for information, I find some about ContentModelArticle and some about JTableContent.  References to ContentModelArticle are in the Joomla installer files, not JTableContentSo I thought ContentModelArticle was the right one, but  then I found (in the Joomla! Documentation) this entry:

JTableContent is the preferred method to add content to the database rather than with direct queries. JTableContent has many benefits which include simplifying the methods to create, read, update, and delete content

Which of these should be used to create articles when building an extension?  Or is there something else?

Hannes Papenberg

unread,
Aug 23, 2021, 4:03:53 PM8/23/21
to Joomla! General Development
ContentModelArticle uses JTableContent to insert an article into the database. Basically, the later is the code to write an entry into the content table. The former also manages content history, tagging, plugin events, etc. What you want to use depends on your circumstances. If you simply want to insert a row into #__content, you can use the table class. If you need plugin events and all that, you use the model.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/b0e262fd-2211-4104-b457-74fe9121c867n%40googlegroups.com.

Michelle Martel

unread,
Aug 23, 2021, 4:08:53 PM8/23/21
to Joomla! General Development
Thank you for the explanation!!
Reply all
Reply to author
Forward
0 new messages