|
After the first beta release it's time to provide some documentation. I'll provide a brief explanation of backend of the component in this post.
Backend contains 4 different sections in itself: article, category, field and type managers. Let's start with the last 2 ones.
Fields are the things that will do component's magic for storing additional data for articles. And types are the containers for them. So as we are storing and grouping articles in categories, we are grouping fields in different types.
So before creating a field you must have a type to put the field in. Then you can start adding as many fields as you want to that type.
Creating types is a quick process. Just click on New button. Write a name and optinially description for your type and also a table name which will be used as an identifier for that type through system. For example for template overrides. You should only use A-Z or 0-9 characters for table name because that will be used as a table name in MySQL. Note that built-in JavaScript validator will warn you for table names if there is a validation error.

Next part is creating fields. In Fields section if you click the New button it will provide you all the installed field types with their description and when you click on one you will have a form to complete in order to use that field. It's just like the module creation page of Joomla!. Important fields here are column name and type. They won't be changable after saving.

Column name is the name of the column in MySQL table where the storage of data coming from this field type will happen. You should follow PHP variable naming rules. You shouldn't start with a number and you should only use A-Z and 0-9. The only difference is you can't use underscores here.
Then in type dropdown choose the type that we had created a few minutes ago. This will tie this field to the selected article type. So it will be visible in article creation window.
In the right, you can see parameters for validation or if supplied by the choosen field type other things like minimum or maximum length etc.
Now it's time to move on to article creation. Firstly we create a category in categories section in backend. There are two differences here than the core category manager: You are able to create a multi-level category tree and there are default parameters in the right to use when someone reaches that category without a menu item. If there is an active menu item, menu parameters take precedence.

Only thing left is to create the article. In articles section when you click on New button, you will see a list of article types. First one is an article without any fields. Just like Joomla! core content. Others are the types you created with your fields. When you choose a type a classic article edit window will load. Here you enter title, category, text of your article just like com_content. And then in the bottom of the editor you will see your custom fields listed in a box. Other things are not that different from the original.

But I made one last addition to this window. I added a onDisplayForm event to the bottom of the page. So anyone can add a text to this window easily. And if it's a form element, it's possible to catch it using onAfterContentSave event. I hope there will be this kind of event in Joomla! core in a future version.
So this is how you create an article with custom fields. I already explained how to use these fields in frontend in a previous blog post. You can just provide an override and use $this->fields object there. This object is loaded with all your custom field data. Another way of using custom fields will be possible in a near future with the creation of one plugin. You will just add for example {field:email} and it'll show the custom field named email. But this feature does not exist yet on this beta.
My next blog post will be about a more practical example. I'll show how to create an image gallery with categories, captions etc. in a very short time without using any other gallery component.
You can download my latest release here. |