Content Studio and content types

Contents

In this chapter, you’ll open Content Studio, explore the sample content your app imported, and create content of your own from the app’s content types.

Content Studio

Content Studio is the editorial interface of Enonic XP. The first time your app starts, it creates a content project called My First Site and imports sample content into it.

Task: Explore the sample content

  1. Open Content Studio - Open the XP menu on the right-hand side, and select Content Studio. You should see some of the imported content:

    Tree structure showing countries and cities in Content Studio
  2. Expand the content tree - The root item of the tree is Hello World. Its icon shows that it is a site. Expand it to reveal Columbia, Norway, USA, and Templates as child items.

Ignore the Templates folder for now. You’ll get back to it in the page templates chapter.

Sites and apps

A site is a content item with one or more apps assigned to it. Assigning an app gives the site, and Content Studio, access to what the app contains, such as content types and components.

Task: Find the app on the site

  1. Open the site - Select the Hello World content and click Edit.

  2. Verify the assigned app - In the form on the left-hand side, your app My First Site is listed under Applications:

    The Hello World site content, with the My First Site app assigned to it

Content types

Every content item has a content type.

XP ships with a set of standard content types: Shortcut, Folder, Site, and a selection of media types that handle different kinds of files.

Apps can define their own content types. Your app contains two, Country and City, defined under src/main/resources/site/content-types/. A content type is defined in a descriptor file. This is the descriptor of City:

src/main/resources/site/content-types/city/city.xml
<content-type xmlns="urn:enonic:xp:model:1.0">
  <display-name>City</display-name>
  <description>Place where many people live</description>
  <super-type>base:structured</super-type>
  <form>
    <input type="ImageSelector" name="photo">
      <label>Photo</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
    <input type="TextLine" name="slogan">
      <label>City slogan</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
    <input type="Long" name="population">
      <label>Population</label>
      <occurrences minimum="1" maximum="1"/>
      <config>
          <min>1</min>
      </config>
    </input>
  </form>
</content-type>

Content Studio turns the descriptor into an editing form:

Form for the city content type

Task: Create your own content

  1. Create a country - Select the Hello World site, click New, and select the Country content type. Fill in the form with a country of your choosing, and save it.

  2. Add a city - Select your new country, click New, and select the City content type. Fill in the form, and save it. Add more cities if you like.

  3. Verify the result - Your country is listed in the content tree below Hello World, with its cities as child items.

Summary

You’ve explored the sample content, seen how an app is assigned to a site, and created content from the two content types in your app.

For more details, visit the reference documentation for content types and the schema system.

Contents

Contents