2

Am a beginner to joomla development ,id like to add extra fields to the article (com_content)component. I have read this article https://docs.joomla.org/Adding_custom_fields_to_the_article_component However it does not fully answer my question on when / how to add the extra fields to the table _content table , and when to add the inserted data .Any help is greatly appreciated .

2

The easiest approach is to simply add the fields as additional properties of the attribs, so you don't need to handle database changes; the additional properties will be stored as a string representing a json object.

As you can see in the document you linked, <fields name="attribs"> is the container of all custom properties in the manifest file (the .xml), and it will automatically handle the persistance for you.

Positive connsiderations:

  • you only create and inject the manifest, the framework handles the rest;
  • there is no need for database changes

Negative considerations:

  • Search requires you to handle the json structure of the attribs field
  • Search will be incredibly slower unless you add json support to your database, and implement the proper indexes, which will put you in a non-default situation. This only applies with 1000+ articles or very slow hosting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.