Answers.Body: <p>Try inside this in the main template file:</p>
  <pre><code>{% block access %}  
      {% requireLogin %}
  {% endblock %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-29T11:11:49.073Z
Answers.Text: I am afraid this didn't work either @pavelpavlovich
Answers.UserDisplayName: Terry Upton
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-18T20:15:17.707Z
Answers.LastActivityDate: 2020-07-18T20:15:17.707Z
Answers.UserDisplayName: Pavel Pavlovich
Body: <p>Is there a reason <code>{% requireLogin %}</code> is not firing when using in a parent include?</p>
  <p>if I place <code>{% requireLogin %}</code> inside the main template file and then use this like so:</p>
  <p>homework.twig<br />
  <code>{% extends &quot;_layouts/members-page-layout.twig&quot; %}</code></p>
  <p>It is not firing? But if I put it inside the homework.twig file directly it fires....
  Was hoping t avoid having to add it to multiple templates and just add it to a 'members' parent layout template.</p>
  <p><strong>EDIT 18 July 2020</strong><br />
  Editing the post to include more information
  Here is the parent template I am trying to include the <code>{% requireLogin %}</code> that is not firing.</p>
  <pre><code>{# -- Layout template for HTML pages -- #}
  {% extends &quot;_boilerplate/_layouts/base-html-layout.twig&quot; %}
  
  {# -- Any &lt;meta&gt; tags that should be included in the &lt;head&gt; #}
  {% block headMeta %}
  {% endblock headMeta %}
  
  {# -- Any &lt;link&gt; tags that should be included in the &lt;head&gt; #}
  {% block headLinks %}
  {% endblock headLinks %}
  
  {# -- Any CSS that should be included before &lt;/head&gt; -- #}
  {% block headCss %}
    {# Google fonts #}
    &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
    
    {% include &quot;_inline-css/site-fonts.css&quot; %}
  {% endblock headCss %}
  
  {% requireLogin %}
  
  {# -- Page body -- #}
  {% block bodyHtml %}
    {% set primarySectionColor      = 'navy' %}
    {% set secondarySectionColor    = 'pink' %}
    
    {% if currentUser.admin %}
      {#    TODO: Make this hide#}
      &lt;div class=&quot;max-w-2xl fixed bottom-0 left-0 border border-green-400 m-2&quot;&gt;
        &lt;div class=&quot;flex&quot;&gt;
          &lt;div class=&quot;bg-green-100 p-3 text-green-500 text-sm flex&quot;&gt;
            {{ svg('@icons/bx/bx-info-circle.svg', class=&quot;w-5 h-5 flex-shrink-0 fill-current mr-1&quot;) }}
            You are currently logged in as an admin role so you have unrestricted access and therefore you will not see the filtering of content and homework like a member user
            (parent) would see.
          &lt;/div&gt;
          &lt;button class=&quot;bg-green-500 text-white p-2&quot;&gt;
            {{ svg('@icons/bx/bx-info-circle.svg', class=&quot;w-8 h-8 flex-shrink-0 fill-current&quot;) }}
          &lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    {% endif %}
    
    &lt;div id=&quot;page-container&quot;&gt;
      {# -- Info header, including _navbar.twig -- #}
      {% include &quot;_globals/header.twig&quot; %}
      
      {# - IE notice for Old browsers - #}
      {% include '_globals/ie-notice.twig' %}
      
      &lt;main&gt;
        {# -- Primary content block -- #}
        {% block content %}
        {% endblock %}
      &lt;/main&gt;
      
      {# -- Content that appears below the primary content block -- #}
      {% block subcontent %}
      {% endblock %}
      
      {# -- Info footer -- #}
      {% include &quot;_globals/footer.twig&quot; %}
    
    &lt;/div&gt;
  {% endblock bodyHtml %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-14T08:51:18.443Z
Comments.Text: Sorry this is not going to be very helpful for you, but I can say: It Works OK For Me. Do you maybe have some kind of caching going on?
Comments.UserDisplayName: James Smith
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-14T12:19:06.843Z
Comments.Text: No caching as local development at this stage. 
  I will have another look then, at least you've confirmed it _should_ work ok.
  Thanks.
Comments.UserDisplayName: Terry Upton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-15T15:39:53.067Z
Comments.Text: What's in your main template file?
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-18T16:17:41.443Z
Comments.Text: I have added more information to the original question. @RitterKnight
Comments.UserDisplayName: Terry Upton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-18T20:28:23.627Z
Comments.Text: @TerryUpton: if you move the ``{% requireLogin %}`` tag before ``{% extends %}`` does it work?
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-29T11:12:24.463Z
Comments.Text: @RitterKnight nope it's the same even if before the `{% extends %}`
Comments.UserDisplayName: Terry Upton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-29T15:00:03.153Z
Comments.Text: What's inside ``base-html-layout.twig``? Sounds like you may have too many extends going on? You could end up in a situation where you think a tag is going to fire but it's never going to because something else is actually extending it.  That sounds like what could be happening. I would also make sure you're actually not logged in while testing.
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-05T10:35:27.047Z
Comments.Text: Funny how these things come around again... 4 years after my first comment on this question saying it works ok for me, I'm now running into this problem myself! Did you ever get it resolved?!
Comments.UserDisplayName: James Smith
Tags: <templating><requirelogin>
Title: {% requireLogin %} not working on extended (layout template) files?
ThreadText: # {% requireLogin %} not working on extended (layout template) files?
  
  (Asked by: username_0 on 2020-07-14)
  
  Is there a reason `{% requireLogin %}` is not firing when using in a parent include?
  
  if I place `{% requireLogin %}` inside the main template file and then use this like so:
  
  homework.twig  
  `{% extends "_layouts/members-page-layout.twig" %}`
  
  It is not firing? But if I put it inside the homework.twig file directly it fires....
  Was hoping t avoid having to add it to multiple templates and just add it to a 'members' parent layout template.
  
  **EDIT 18 July 2020**  
  Editing the post to include more information
  Here is the parent template I am trying to include the `{% requireLogin %}` that is not firing.
  
  ```
  {# -- Layout template for HTML pages -- #}
  {% extends "_boilerplate/_layouts/base-html-layout.twig" %}
  
  {# -- Any <meta> tags that should be included in the <head> #}
  {% block headMeta %}
  {% endblock headMeta %}
  
  {# -- Any <link> tags that should be included in the <head> #}
  {% block headLinks %}
  {% endblock headLinks %}
  
  {# -- Any CSS that should be included before </head> -- #}
  {% block headCss %}
    {# Google fonts #}
    <link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    {% include "_inline-css/site-fonts.css" %}
  {% endblock headCss %}
  
  {% requireLogin %}
  
  {# -- Page body -- #}
  {% block bodyHtml %}
    {% set primarySectionColor      = 'navy' %}
    {% set secondarySectionColor    = 'pink' %}
    
    {% if currentUser.admin %}
      {#    TODO: Make this hide#}
      <div class="max-w-2xl fixed bottom-0 left-0 border border-green-400 m-2">
        <div class="flex">
          <div class="bg-green-100 p-3 text-green-500 text-sm flex">
            {{ svg('@icons/bx/bx-info-circle.svg', class="w-5 h-5 flex-shrink-0 fill-current mr-1") }}
            You are currently logged in as an admin role so you have unrestricted access and therefore you will not see the filtering of content and homework like a member user
            (parent) would see.
          </div>
          <button class="bg-green-500 text-white p-2">
            {{ svg('@icons/bx/bx-info-circle.svg', class="w-8 h-8 flex-shrink-0 fill-current") }}
          </button>
        </div>
      </div>
    {% endif %}
    
    <div id="page-container">
      {# -- Info header, including _navbar.twig -- #}
      {% include "_globals/header.twig" %}
      
      {# - IE notice for Old browsers - #}
      {% include '_globals/ie-notice.twig' %}
      
      <main>
        {# -- Primary content block -- #}
        {% block content %}
        {% endblock %}
      </main>
      
      {# -- Content that appears below the primary content block -- #}
      {% block subcontent %}
      {% endblock %}
      
      {# -- Info footer -- #}
      {% include "_globals/footer.twig" %}
    
    </div>
  {% endblock bodyHtml %}
  
  ```
  
  **Tags:** templating, requirelogin
  
  > **Comments:**
  > **username_1**: Sorry this is not going to be very helpful for you, but I can say: It Works OK For Me. Do you maybe have some kind of caching going on?  
  > **username_0**: No caching as local development at this stage.  I will have another look then, at least you've confirmed it _should_ work ok. Thanks.  
  > **username_2**: What's in your main template file?  
  > **username_0**: I have added more information to the original question. @username_2  
  > **username_2**: @username_0: if you move the ``{% requireLogin %}`` tag before ``{% extends %}`` does it work?  
  > **username_0**: @username_2 nope it's the same even if before the `{% extends %}`  
  > **username_2**: What's inside ``base-html-layout.twig``? Sounds like you may have too many extends going on? You could end up in a situation where you think a tag is going to fire but it's never going to because something else is actually extending it.  That sounds like what could be happening. I would also make sure you're actually not logged in while testing.  
  > **username_1**: Funny how these things come around again... 4 years after my first comment on this question saying it works ok for me, I'm now running into this problem myself! Did you ever get it resolved?!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-07-18. Score: 1
  
  Try inside this in the main template file:
  
  ```
  {% block access %}  
      {% requireLogin %}
  {% endblock %}
  
  ```
  
  > **Comments:**
  > **username_0**: I am afraid this didn't work either @username_3  
  
  ---
  
  