Build a Book Library with the Records Macro

Last modified by Eleni Cojocariu on 2026/11/25 11:30

Tutorial

XWiki 18.10.0+

In this tutorial, you will learn how to build a small library application, a table of books that readers can sort, filter and extend. You describe what a book is with an object type, then list the books with the Records Macro.

  1. Create a Page named "My Library", and a Page named "Book Class" under it, as described in Create a Page.
  2. Open "Book Class" with the Class editor, as described in Edit a Page with the Class Editor.
  3. Add the four fields of a book, one by one: type author in "Add new property", select the "String" type and click "Add", then add genre and status as "Static List", and year as "Number".

    The Class editor of Book Class, with the Add new property row highlighted above the Author, Genre, Status and Year fields

  4. Expand each field and set its "Pretty Name" to "Author", "Genre", "Status" and "Year".

    The author field expanded in the Class editor, with Author typed as its Pretty Name

  5. Type Novel|Essay|Poetry in the "Values" of "Genre", and To read|Reading|Read in those of "Status", then click "Save & View".

    The Values setting of a Static List field, holding Novel, Essay and Poetry separated by vertical bars

  6. Edit "My Library" with the WYSIWYG editor and insert the "Records" Macro, as described in Insert a Macro with the WYSIWYG Editor.
  7. Pick "Book Class" in "Object type".

    The Records Macro dialog with Book Class picked as Object type

  8. Check "Allow edit mode" in the "Editing" tab, and pick "Use user-submitted title as page name" as "Creation strategy".

    The Editing tab of the Records Macro dialog, with Allow edit mode checked and the creation strategy naming pages after their title

  9. Click "Submit", then save the Page.
  10. Click the "Edit mode" button, showing a pencil icon, at the top of the table, click "Add entry", and type The Name of the Rose.

    The empty table in Edit mode, with a new row holding the title The Name of the Rose being typed

  11. Fill the other cells of the row, moving between them with the Tab key, then add the other books the same way:
    TitleAuthorGenreStatusYear
    The Name of the RoseUmberto EcoNovelRead1980
    A Room of One's OwnVirginia WoolfEssayReading1929
    Leaves of GrassWalt WhitmanPoetryTo read1855
    Invisible CitiesItalo CalvinoNovelTo read1972
  12. Click the "Edit mode" button again.
  13. The library lists your books, which readers can sort and filter, as follows:

    The My Library page listing four books with their title, author, genre, status and year

FAQ

Where are the books stored?

Each book is a Page under "My Library", named after its title, next to "Book Class".

Which rights do readers need to add books?

The Edit right on the children of "My Library", where the books are created. Readers without it can still sort and filter the table, but get no "Add entry" button.

Related

Get Connected