Answers.Body: <p>There is ONE tiny difference between Craft 3.x and Craft 4.x!</p>
  <p><code>{% extends &quot;_layouts/cp.html&quot; %}</code> for Craft 3</p>
  <p><code>{% extends &quot;_layouts/cp.twig&quot; %}</code> for Craft 4</p>
  <p>and to avoid a future breakage on update, I did find that
  <code>{% extends &quot;_layouts/cp&quot; %}</code> works for both.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-28T05:09:26.223Z
Answers.LastActivityDate: 2023-12-28T05:09:26.223Z
Answers.UserDisplayName: cherrykoda
Body: <p>I have a module that's meant to add a section to the CP.</p>
  <pre><code>class Reports extends Module
  {
      // Public Methods
      // =========================================================================
  
      /**
       * @inheritdoc
       */
      public function init()
      {
          parent::init();
  
          Event::on(
              Cp::class,
              Cp::EVENT_REGISTER_CP_NAV_ITEMS,
              function (RegisterCpNavItemsEvent $event) {
                  $event-&gt;navItems[] = [
                      'url' =&gt; 'reports',
                      'label' =&gt; 'Reports',
                      //'icon' =&gt; '@mynamespace/path/to/icon.svg',
                      'subnav' =&gt; [
                          'vat' =&gt; ['label' =&gt; 'VAT', 'url' =&gt; 'reports/vat']
                      ],
                  ];
              }
          );
  
          Event::on(
              View::class,
              View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
              function (RegisterTemplateRootsEvent $event) {
                  $event-&gt;roots['reports'] = __DIR__ . '/templates';
              }
          );
  
      }
  }
  </code></pre>
  <p>Inside of my module is a templates folder, and the templates are being reached, however the <code>{% extends &quot;_layouts/cp.twig&quot; %}</code> is erroring from my template files. This is index.twig:</p>
  <pre><code>{% extends &quot;_layouts/cp.twig&quot; %}
  {% set title = &quot;Reports&quot; %}
  
  {% block content %}
      &lt;p&gt;Reports&lt;/p&gt;
  {% endblock %}
  </code></pre>
  <p>and this is the error:
  <a href="https://i.sstatic.net/AD3jW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AD3jW.png" alt="enter image description here" /></a></p>
  <p>The code is straight from Craft 4.x and 3.x Docs (same for both), so I'm not sure what's wrong.</p>
  
Tags: <craft3><control-panel><modules><craft4>
Title: _layouts/cp.twig cannot be found
ThreadText: # _layouts/cp.twig cannot be found
  
  (Asked by: username_0 on 2023-12-28)
  
  I have a module that's meant to add a section to the CP.
  
  ```
  class Reports extends Module
  {
      // Public Methods
      // =========================================================================
  
      /**
       * @inheritdoc
       */
      public function init()
      {
          parent::init();
  
          Event::on(
              Cp::class,
              Cp::EVENT_REGISTER_CP_NAV_ITEMS,
              function (RegisterCpNavItemsEvent $event) {
                  $event->navItems[] = [
                      'url' => 'reports',
                      'label' => 'Reports',
                      //'icon' => '@mynamespace/path/to/icon.svg',
                      'subnav' => [
                          'vat' => ['label' => 'VAT', 'url' => 'reports/vat']
                      ],
                  ];
              }
          );
  
          Event::on(
              View::class,
              View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
              function (RegisterTemplateRootsEvent $event) {
                  $event->roots['reports'] = __DIR__ . '/templates';
              }
          );
  
      }
  }
  
  ```
  
  Inside of my module is a templates folder, and the templates are being reached, however the `{% extends "_layouts/cp.twig" %}` is erroring from my template files. This is index.twig:
  
  ```
  {% extends "_layouts/cp.twig" %}
  {% set title = "Reports" %}
  
  {% block content %}
      <p>Reports</p>
  {% endblock %}
  
  ```
  
  and this is the error:
  [![enter image description here](https://i.sstatic.net/AD3jW.png)](https://i.sstatic.net/AD3jW.png)
  
  The code is straight from Craft 4.x and 3.x Docs (same for both), so I'm not sure what's wrong.
  
  **Tags:** craft3, control-panel, modules, craft4
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-12-28. Score: 2 | Accepted answer
  
  There is ONE tiny difference between Craft 3.x and Craft 4.x!
  
  `{% extends "_layouts/cp.html" %}` for Craft 3
  
  `{% extends "_layouts/cp.twig" %}` for Craft 4
  
  and to avoid a future breakage on update, I did find that
  `{% extends "_layouts/cp" %}` works for both.
  
  
  ---
  
  