Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:51+00:00 2026-06-08T18:32:51+00:00

I have different layouts depending on the user. This triggers the following error: Multiple

  • 0

I have different layouts depending on the user. This triggers the following error:
"Multiple extends tags are forbidden". How can I manage to use different layouts depending on the role of the user?

{% if is_granted('ROLE_USER_ONE') %}

{% extends "AcmeUserBundle::layout_user_one.html.twig" %}

{% elseif is_granted('ROLE_USER_TWO') %}

{% extends "AcmeUserBundle::layout_user_two.html.twig" %}

{% endif %}

EDIT

Here is the answer. I will use the case of 3 users in case people wonder how to do this. In this case admin has also userOne and userTwo privileges in case someone wonders about the else statement. I use Conditional Inheritance in this case, but as suggested in one of the answer, Dynamic Inheritance might be more readable.

{% set admin = false %}

{% set userOne = false %}

{% set userTwo = false %}

{% if is_granted('ROLE_ADMIN') %}

    {% set admin = true %}

{% else %}

    {% if is_granted('ROLE_USER_ONE') %}

        {% set userOne = true %}

    {% elseif is_granted('ROLE_USER_TWO') %}

        {% set userTwo = true %}

    {% endif %}

{% endif %}

{% extends admin ? "AcmeUserBundle::layout_admin.html.twig" : userTwo ? "AcmeUserBundle::layout_user_two.html.twig" : "AcmeUserBundle::layout_user_one.html.twig" %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:32:52+00:00Added an answer on June 8, 2026 at 6:32 pm

    Check out the Conditional Inheritance section in the docs.

    If you need more than two options, see the Dynamic Inheritance section:

    {% set parent = 'defaultLayout.html.twig' %}
    {% if is_granted('ROLE_USER') %}
        {% set parent = 'userLayout.html.twig' %}
    {% elseif is_granted('ROLE_ADMIN') %}
        {% set parent = 'adminLayout.html.twig' %}
    {% endif %}
    
    {% extends parent %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I have a completely different layout depending on wether a user is
in my application, I have a User model. Each user can have multiple (email)
I have the following ClickListener code. It will do different stuff depending on what
I want to have different layouts like [left|content|right] and [left|content] or [content|right] when using
I have two Android applications with a similar functionality but different drawables and layouts.
I have a basic layout where different components can be selected using a tree
I have multiple similar sites (same layout, just different data), and each of them
I have different php output in jQuery-based tabs. This output is formed from database
I would like to have different views of a webpage depending on certain attributes
I have android application that is written regular way. layouts, java, APK. Now, depending

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.