Packt Media Site's content class

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.

Creating the profile content class

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.

Creating the profile content class

The first thing we have to choose are the main properties of the content class. We will add them as shown here:

Creating the profile content class

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:

Creating the profile content class

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.

Creating the profile content class

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:

Creating the profile content class

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.

Creating the profile content class

Tip

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.

Creating the profile content class

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.

Creating the profile content class

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.

Creating the profile content class

If you miss some steps, you can click on the Edit button and modify the created class again.

Extending the Article class

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.

Extending the Article class

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.

The other content classes

We will now create more content classes to manage the forum and the feedback form.

But luckily, eZ Publish is very helpful and exposes some ready-to-use classes that we can use without a need to modify them in any way. These classes are the forum, the forum reply, and the feedback form classes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.139