Radix Badge template not found

Created on 17 January 2024, 5 months ago
Updated 27 January 2024, 5 months ago

Hello,

One of the custom themes I'm using, is including @radix/badge/badge.twig in its own twig template like so:

<div{{ attributes.addClass(classes) }}>
    <div{{ title_attributes.addClass(title_classes) }}>
      {{ label }}{% if label_display == 'inline' %}<span class="field__label__suffix mr-1">:</span>{% endif %}
    </div>
    {% if multiple %}
    <div class="field__items">
      {% endif %}
      {% for item in items %}
        {% include '@radix/badge/badge.twig' with {
          type: 'light',
          content: item.content['#title'],
          url: item.content['#url'],
          utility_classes: ['field__item'],
        } %}
      {% endfor %}
      {% if multiple %}
    </div>
    {% endif %}
  </div>

However, when I try to access this part of the code, I get the following error:

The website encountered an unexpected error. Try again later.

Twig\Error\LoaderError: Template "@radix/badge/badge.twig" is not defined in "themes/custom/mi_radix/templates/field/field--field-tags.html.twig" at line 42. in Twig\Loader\ChainLoader->getCacheKey() (line 99 of /var/www/vendor/twig/twig/src/Loader/ChainLoader.php).
Twig\Environment->getTemplateClass('@radix/badge/badge.twig', NULL) (Line: 204)
Drupal\Core\Template\TwigEnvironment->getTemplateClass('@radix/badge/badge.twig') (Line: 319)
Twig\Template->loadTemplate('@radix/badge/badge.twig', 'themes/custom/mi_radix/templates/field/field--field-tags.html.twig', 42) (Line: 140)
__TwigTemplate_96220eb93da234949898488268dde6cd->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('themes/custom/mi_radix/templates/field/field--field-tags.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 74)
__TwigTemplate_bae9db6694635c45b3b9bb0f61fa11fd->block_content(Array, Array) (Line: 171)
Twig\Template->displayBlock('content', Array, Array) (Line: 61)
__TwigTemplate_bae9db6694635c45b3b9bb0f61fa11fd->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array, Array) (Line: 43)
__TwigTemplate_1730a8f2340e7f97fa06263e4fdf67dc->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('themes/custom/mi_radix/templates/content/node.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I would appreciate any help on how I can fix the issue and/or replace the badge template with something else

Thank you i nadvance

💬 Support request
Status

Closed: works as designed

Version

5.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @giosal90
  • 🇮🇳India Tirupati_Singh

    @giosal90, use {% include 'radix:badge' with {} %} instead of {% include '@radix/badge/badge.twig' with {} %} to include component.

  • @Tirupati_Singh, thank you, I've tried it, but still getting the same error, now for radix:badge

  • Sorry for a late reply, you have to check the components directory in Radix 5 and see if there's a badge there at all? not sure if there is, it is in Radix 6

    What @Tirupati_Singh suggested doesn't work on 5.x since it's not SDC compatible

  • Sorry for a late reply, you have to check the components directory in Radix 5 and see if there's a badge there at all? not sure if there is, it is in Radix 6

    What @Tirupati_Singh suggested doesn't work on 5.x since it's not SDC compatible

    @doxigo,
    Thank you for your reply.

    There definitely isn't a badge component. However after upgrading to version 6, the site doesn't load at all with the following error:

    The website encountered an unexpected error. Try again later.
    
    Twig\Error\LoaderError: Template "radix:block" is not defined in "themes/contrib/radix/src/kits/radix_starterkit/templates/block/block.html.twig" at line 29. in Twig\Loader\ChainLoader->getCacheKey() (line 99 of /var/www/vendor/twig/twig/src/Loader/ChainLoader.php).
    Twig\Environment->getTemplateClass('radix:block', NULL) (Line: 204)
    Drupal\Core\Template\TwigEnvironment->getTemplateClass('radix:block') (Line: 319)
    Twig\Template->loadTemplate('radix:block', 'themes/contrib/radix/src/kits/radix_starterkit/templates/block/block.html.twig', 29) (Line: 39)
    __TwigTemplate_6b93572410c1d21d7a43941653e2abae->doDisplay(Array, Array) (Line: 394)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
    Twig\Template->display(Array) (Line: 379)
    Twig\Template->render(Array) (Line: 38)
    Twig\TemplateWrapper->render(Array) (Line: 39)
    twig_render_template('themes/contrib/radix/src/kits/radix_starterkit/templates/block/block.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 480)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array) (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 75)
    __TwigTemplate_0b7f59ae38f7e42bc5518fb48cc176e7->doDisplay(Array, Array) (Line: 394)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
    Twig\Template->display(Array) (Line: 379)
    Twig\Template->render(Array) (Line: 38)
    Twig\TemplateWrapper->render(Array) (Line: 39)
    twig_render_template('modules/custom/naiades_layouts/plugins/layouts/naiades_frontpage/naiades-frontpage.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('naiades_frontpage', Array) (Line: 480)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • And also errors on every page for different components

  • It's a major upgrade, it's not that easy to upgrade, check out the documentation for the upgrade: https://doxigo.gitbook.io/radix/misc/migration-and-upgrading

  • @doxigo,
    I've upgraded everything, including bootstrap and its dependencies.
    However, it appears that somehow my Drupal 10 doesn't support SDCs?

  • Please do read the documentation from the beginning, you need sdc and serialization module enabled as well

    closing this issue as it works as designed

  • @doxigo,
    I was completely right, SDC module was disabled in my Drupal installation.

    Now working on making my custom theme understand SDCs

  • Consider issue closed and resolved.

    Thanks a lot!

  • Status changed to Closed: works as designed 5 months ago
Production build 0.69.0 2024