Results 1 to 4 of 4

Thread: Contao 5: Templates not showing up in selection

  1. #1
    New user
    Join Date
    08-29-19.
    Posts
    4

    Default Contao 5: Templates not showing up in selection

    Good afternoon gamers,
    got a Contao 5 installation here and love some of the changes.
    But templates are a bit confusing now, as I am struggling to get them to work.

    What I was trying to do:
    Make a template version for the image content element that converts SVG-files into inline code (so it can be dynamically adressed via CSS).
    For that I have created .html5 templates. When trying to select the template for the content element, it wasn't showing up in the list, so I created two twig versions to see if they show up on template selection (the content of the templates is identical so far, unchanged from the original).

    template_folder.jpg

    Here a screenshot of my template selection on the image content element:

    template_selection.jpg

    I cannot figure out how to make use of my custom templates or how to make them show up when trying to select one.

  2. #2
    New user
    Join Date
    08-29-19.
    Posts
    4

    Default

    Been doing some more research on this in the meantime and figured some stuff out.
    So for the uninitiated:
    Contao 5 by default uses twig templates now, however there is a way to enable html5 templates to use still.
    However they are planned to be depricated and removed in Contao 6.
    So in this case I want to roll with the new twig templates.

    I found some documentation on how to set up the structure for twig templates and variants in Contao 5:
    https://docs.contao.org/dev/framewor...ates/#variants

    So, if I want to use a image template, it needs to follow the structure:
    content_element/
    >image.html.twig

    I made some changes to this template and Contao by default uses this one as the global one now.
    Cool!

    For variants to a template the documentation says the structure has to look like this:

    content_element/
    >image/
    >>variant_name.html.twig
    >image.html.twig

    That's what I did now.

    template_folder_twig.jpg

    When I go to my element to select a template tho, it still won't show the variant:

    template_selection_twig.jpg

    Any idea?

  3. #3
    New user
    Join Date
    08-29-19.
    Posts
    4

    Default

    After activating the debug mode the variants show up:

    template_selection_twig.jpg

    Using Debug mode for twig templates was mentioned in the German documentation in its introduction to twig.

    Hope this helps anyone that runs into the same confusion I had!

  4. #4
    New user
    Join Date
    08-29-19.
    Posts
    4

    Default

    And for anyone who is curious about what the new default twig templates look like, you can find them here: https://github.com/contao/contao/tre...templates/_new
    Wish there was a way for loading them in on template creation like Contao did with the html5 templates.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •