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 .
-
If I were you I would have a look at extensions.joomla.org/extension/aixeena-cck– DesignSubwayDec 23, 2015 at 13:41
1 Answer
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.