We learned what content classes are, and now we have to create our own classes by customizing the existing ones, or creating new ones from scratch.
But first, we need to understand what we need in our site.
We will describe the Packt Media Site as the site of a youth magazine that decided to move onto the Web after some years of success in the paper market.
The magazine will publish all of the articles based on a precise editorial program. Moreover, the readers will have the possibility to comment on them in a dedicated forum.
The last point we have to fulfill is that all of the members of the editorial staff want a personal profile page where they can show their own articles and some personal data. With this information, and taking a look at the default content classes that eZ Publish gives us, the only thing we have to do is creating a personal profile page from scratch.
We have to open the browser again and log in to the administration panel. Here, we go to the setup page, click on the Classes link in the sidebar, and enter the content group. On the bottom of the page, we will click on the New class button and start creating our new class.
The first thing we have to choose are the main properties of the content class. We will add them as shown here:
Next, we will add some attributes that will be shown on the site.
The first attribute we will use is the Authors. To choose it, simply select the select menu and then click on the Add attribute button. The result will be similar to the screenshot shown here:
By default, eZ Publish sets a fake name (in this case, new attribute1) as an attribute name. We should change this to one that is easily recognizable when we work in the backend. Moreover, we should select the Required checkbox to be sure that a profile will always be assigned to an existing user.
Now, we will add a new XML block attribute that will enable a WYSIWYG text area editor that we will use to insert the author description. As before, we will change the default values to something more expressive, like the ones shown here:
To complete our work, we need to define some more attributes such as the firstname and lastname of the editor, as well as their birth date, email, and photo.
The date attribute can only store dates from 01/01/1970 to the year 2032. So, if you need to manage an older date for the birthday attribute, you need to use the Birthday Datatype extension (http://projects.ez.no/birthday). We will see how to install and manage extensions in the upcoming chapters.
The last step will be to add a User account attribute. Set this to "not required" (deselect the Required checkbox), to assign an eZ Publish user to that profile, if present.
When we click on the OK button to confirm all of the changes that we applied to the Profile form, we are redirected to the Profile [Class] summary page, where we can see what we have done.
If you miss some steps, you can click on the Edit button and modify the created class again.
Sometimes, the articles of the magazine are written by two or more editors and we want to list all of them on the article's page. Moreover, we also want to show all of the articles written by an author.
Again, click on the Classes link in the sidebar. Now go to the Content
folder, click on the Article class, and then click on the Edit button.
Next, add a new attribute called Object relations, which will enable multiple relations with other predefined objects.
In our case, for the sake of simplicity, we will choose List with checkboxes as the select method. This will display a list of all the authors, preceded by a checkbox to relate one by one to the article, and we will allow only the Profile class.
Now we can save the Article class and go on to create our content classes.
3.147.6.243