Customizing the Reading Experience

Book List

The page that shows all your books is fully customizable with a Lava template. But before you go and write your own Lava, know that books now have an attribute in which you can upload a custom cover image. If you do so then it will be displayed instead of the generic cover image. So even without writing any custom Lava you can make your books page look much nicer.

There is a single variable available to you, but it's the only one that counts.

  • Books - An array of all the books to be displayed.

Book View

The page that lets you actually read books has a number of block settings to let you customize the look.

First, under the normal block settings there are templates for both Article Header and Article Footer. These are displayed just before the article content and just after the article content. Both are rendered in the middle column between the two TOC sections on the left and right.

The lava variables available in these templates are:

  • Article - The article currently being rendered.
  • Book - The book the article is a part of.
  • IsPrinting - Will be true if the render is being performed as a multi-article print request.
  • IsFirstArticle - Will be true if this is the first article being rendered.
  • IsLastArticle - Will be true if this is the last article being rendered.

Some of those might be a completely new concept. First off, if you specify "print=1" in the query string then the system will enter print mode. Since that causes multiple articles to be rendered, we provide the last two values as well. Between these three you can decide how you want to handle any custom rendering options during printing.

Tip

These Lava variables, along with CurrentPerson, are also available anywhere in the article when Merge Content has been enabled.

Next, under the Advanced Settings tab of the block settings are some additional settings you might want to make use of.

The first is the Show Panel option. When enabled, this will enclose the entire article (including both TOCs) inside a standard block panel. The book name will be used for the heading text.

The other two settings you can make use of are Page Header Template and Page Footer Template. These allow you to customize what is displayed at the very top and very bottom of the page. These would, for example allow you to render your own custom paneled look.

The lava variables available on these templates are:

  • Article - The main (first) article being rendered.
  • Book - The book the article belongs to.
  • IsPrinting - Will be true if this is a print request.

Full Lava Template

Under the Advanced Settings tab you will also find a Template setting. This handles rendering the entire book view page, including the table of contents. This is a very advanced customization, but it does allow you to have full control of the process. The following merge fields are available.

  • Article - The main (first) article being rendered.
  • Content - The rendered content of the article (or possibly an error message).
  • FooterContent - The rendered Page Footer Template.
  • HeaderContent - The rendered Page Header Template.
  • IsAdministrator - This will be true if the current person has Administrate access to the article.
  • IsEditor - This will be true if the current person has Edit access to the article.
  • IsLocked - This will be true if the book version has been locked to prevent further editing.
  • IsPrinting - This will be true if this is a print request.
  • IsSearchable - This will be true if searching has been enabled.
  • IsViewAllowed - This will be true if the current person has View access to the article.
  • Navigation - An object that contains information to help with navigation between articles.
    • NextArticle - The article that has been determined to be the next article after this one.
    • NextArticleLink - The full URL link to the next article.
    • PreviousArticle - The article that has been determined to be the previous article before this one.
    • PreviousArticleLink - The full URL link to the previous article.
  • Slug - The slug of the current article.
  • TableOfContents - A string of HTML that represents the table of contents for the book.
  • Title - The title of the current article.
  • Versions - An array of items that represent the versions available. The full array of version objects can be found in Article.Book.Versions.
    • Value - A link to this same article (if possible) for the version.
    • Text - The version number as a string.

Browser Bus Messages

The Book View block supports a number of custom browser bus messages that can be used to customize the experience further.

  • plugin.block.copyArticleSlug - This will copy the current article slug into the clipboard.
  • plugin.block.editArticle - This will begin editing the current article.
  • plugin.block.editArticleChildren - This will open the modal to edit the list of child articles.
  • plugin.block.editArticleSecurity - This will open the modal to edit the security for the current article.
  • plugin.block.printArticle - This will open the modal to print the current article.

Essentially, this is everything in the action menu. This allows you to hide the default action menu and create your own completely custom action menu.

Using Lava

Each article can have Lava enabled or disabled (the default). If you enable the article's Merge Content setting then the entire rendered article will have a Lava merge performed on it.

This allows you to make your articles dynamic. For example, you could check for a specific attribute value on the current person and add in some extra text or links to other pages that they should read.

While you can use Lava anywhere in the structured editor, the way some of the blocks function may cause issues. For example, you try to use a paragraph block with line feeds, those get translated to HTML breaks which might mess up your Lava. But if you are using a simple one-liner, such as {{ CurrentPerson.NickName }}, you should be fine. For more advanced Lava, you can use the Raw HTML / Lava block.

Warning

While you can use the Raw HTML / Lava blocks to conditionally show or hide content by using {% if %} statements and {% endif %} statements in different blocks, care should be taken. The pre-merged content will be used for search results which might cause some information to be visible you didn't intend.