Skip to content

Boards

Intro

XalokNext allows making different blocks of the website editable. These blocks are called boards. Internally, XalokNext uses the same code that it uses to edit articles for editing boards too, so the code of these boards is written in the same wf-html format as they are for articles. The main difference being that the twig files for the boards is located in the App/Bundle/CmsBundle/Resources/views/TemplateModules directory. You can choose to hardcode an editable piece (e.g.: the breaking news board, if there should be one and just one occurrence), or you can use a board group in which the editor can add multiple instances of the same board(s).

The code for using a board hasn't changed since v6, follow the v6 documentation page for details.

Board fixtures

Board fixtures is used to render default data to the user when a board is not created. To set the fixtures, when rendering the board on your template, you have to add the attribute "fixture". Inside it, add the roles of the modules you want to add the default values. This implementation is currently supported to make board and listing fixtures.

Adding fixture to a simple board

To add fixtures to board with only one simple module:

html
{{ wf_cms_render_board('fixture-sample', {
    template: 'board/expander/unit_tests_modules_expander',
    title: 'Fixture sample',
    fixture: {
        text: 'value'
    }
}) }}

The attribute text inside attribute fixture is the role's name of a module inside the template.

The result of the code will be:

json
{
  "__roles": [
    "text"
  ],
  "text": {
    "content": "value"
  }
}

Adding fixtures with a list of modules

In cases where it's necessary to have same modules multiple times, it is required to add them in an array.

Let's say you have the following template and you want 2 composite modules, and in the first one you want another 2 modules:

html
<div
    wf-role="composite_text"
    wf-new>
    <h3
        wf-role="text"
        wf-new
        wf-toolbar-position="top"
        wf-allow=""
    ></h3>
</div>

So your fixtures has to be added like this:

{{ wf_cms_render_board('fixture-sample-multiple-modules', {
    template: 'board/expander/unit_tests_modules_expander',
    title: 'Fixture sample',
    fixture: {
        composite_text: 
        [
            {
                text: 
                [
                    '1st sub item in 1st item', 
                    '2nd sub item in 1st item'
                ]
            },
            {
                text: '2nd item'
            }
        ]
    }
}) }}

This results in:

json
{
  "__roles": [
    "composite_text",
    "composite_text--1"
  ],
  "composite_text": {
    "__roles": [
      "text",
      "text--1"
    ],
    "text": {
      "content": "1st sub item in 1st item"
    },
    "text--1": {
      "content": "2nd sub item in 1st item"
    }
  },
  "composite_text--1": {
    "__roles": [
      "text"
    ],
    "text": {
      "content": "2nd item"
    }
  }
}

Adding fixtures to a listing module

In case of a module of type listing, the values for the listing will be its settings, an example could be:

{{ wf_cms_render_board('category-secondary', {
    template: 'board/category/secondary',
    title: 'board-title.category-secondary'|trans,
    entity: category,
    fixture: {
        listing: {
            listingTitle: 'listing.category-secondary.title'|trans,
            content: 'contentNews',
            template: 'AppCmsBundle:Listing:secondary.html.twig',
        }
    }
}) }}

NOTE: listingTitle refers to the title used internally for the listing (to generate its slug), there's also a title property that refers to the title that appears above the listing on the public side.

Have a look at vendor/wfcms/standard/Wf/Bundle/CmsBaseBundle/Entity/Traits/PageListingTrait::getDefaultSettings to see a list of default settings that will be used if you don't specify them in the fixture".

Adding an entity to your fixture

To add an entity to your fixture, you have to define the "__contentModels" attribute to the fixture object. To achieve this, there are two possibles implementations, with structured data or inline:

An example with structured data:

{{ wf_cms_render_board('main-menu', {
    template: 'board/menu/main',
    title: 'Entity sample',
    fixture: {
        menu_item: [
            {
                menu_link: 'My category',
                __contentModels: {
                    type: 'category',
                    slug: 'my-category'
                }
            }
        ]
    }
}) }}

And with inline:

{{ wf_cms_render_board('main-menu', {
    template: 'board/menu/main',
    title: 'Entity sample',
    fixture: {
        menu_item: [
            {
                menu_link: 'My category',
                __contentModels: 'category:my-category'
            }
        ]
    }
}) }}

In both cases, you must specify the entity type, and its slug.