Skip to content

Article templates

Intro

You can define one or more article templates that the editors use to publish contents. The article templates are configured by default in app/config/cms/templates.yml

yaml
wf_cms_base_admin:
    article_templates:
        default: ~
        opinion:
          category_bound: opinion
        mam:
            category_bound: 
              - live
              - mam
        special_article:
           category_bound:
              main: video
              secondary:
                 - deportes
                 - politica
        static:
            type: static

There are various types of article templates (in the example above):

  • generic: the default type of articles, used if you don't specify anything

  • category_bound: the editor can choose only a subcategory of the category with slug specified as category_bound option. If that category has no subcategories, the category dropdown won't be displayed at all - it's being replaced with a hidden input.

    The value for the category_bound can be:

    • a string: the category slug to which the bind the template - this will allow selecting children of the given category
    • an array of strings: the category slugs to which to bind the template - this will allow selecting children of any of the given categories
    • an array with main (required) and secondary (optional) keys. Both these keys can have either a string value or an array of strings value. This allows binding the template to the category or categories specified in main, but also adds the secondaryCategories field and binds them to the category or categories specified in the secondary key
  • static: a special type of category_bound article, bound to category pages. MAKE SURE you have a category with slug pages when enabling this option. Besides being bound to this category, the articles also have some options on whether to display or not the title and the sidebar.

The templates will be looked for in App/Bundle/CmsBundle/Resources/views/Templates/Article/__TEMPLATE_ID__.html.twig.

One important requirement is that the article templates must have a title module:

html
<h1 wf-role="title"></h1>

Find out the form type used for an article

In Symfony's debug toolbar there's an icon for the forms panel: form type icon

Clicking on it reveals the form type class used on that page: form type pane

Note: The class listed there is a class that Symfony creates automatically and stores in the cache folder, but its name is the same as the one in XalokNext, having a _UNIQUE_HASH suffix.