| How to create an article with custom fields |
| Content Type Management | |||
| Written by Ercan Özkaya | |||
|
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.
|








Wednesday, 17 December 2008
I've got everything set up fine - but can someone just explain a bit more about how to make the custom field display on the front end after the article text? And how do I add the custom fields to the Create Article front end?
The overrides is a bit confusing - could you explain some more?
Sunday, 05 October 2008
Sunday, 21 September 2008
Just one thing: I wish to create content just articles but with more fields (just like this plugin allows). Then, when I create a menu type to allow me to see all the articles I've created with the extension (menu type=extend>>category list layout), I see the content I created but without the fields I just edited before! How can I have this content available with the fields created? Thanks a lot for this wonderful tool, I was looking for something like this longtime.
Paul
Wednesday, 03 September 2008
thanks
Thursday, 28 August 2008
Marco, just leave the tarball on your own system, and then from the administrator control panel choose
Extensions: Install
Choose Upload a Package File off the menu, and browse to the directory on your system where the tarball is sitting.
It will automagically install the extensions in Joomla, and you can access the extensions from;
Components > Extend menu and submenus.
What an impressive addition! Thanks again!
Monday, 18 August 2008
but how can I install your version?
the tarball drops files on which I have no permission.
what should I do?