<p>To me it looks like something with your sites URL is wrong or your server's configuration and therefore the CSS is not loaded. </p>

<p>Can you take a look into your HTML-Output regarding the Links to the CSS-files? Are they linked correctly? Is both http/s? </p>

CC BY-SA 4.0
2019-01-12T16:45:24.973Z
Thank you for the response - I really appreciate Luke!
That got me on the right path for looking at the \craft\web\Controller that I was extending, and I saw that it a renderTemplate() method that I actually should've been using. I've got it all working now, so I'll go ahead and post the changes I made so that hopefully someone in the future can maybe find some help from my blunders!
Josh Kautz
CC BY-SA 4.0
2019-01-12T12:57:31.457Z
2019-01-12T12:57:31.457Z
Luke
<p>I sincerely appreciate the responses!
I've since resolved this issue, below is the changed code. My controller was extending the Craft web controller (\craft\web\Controller) which has its own renderTemplate() method that I switched to, which fetches the Control Panel assets I wanted for styling the page.</p>

<p>The template twig file remains identical as is above.</p>

<p><strong>(Modified) Controller: Controller.php</strong></p>

<pre><code>class Controller extends \craft\web\Controller
{
    public function actionIndex(){

        Craft::info("hello!", __METHOD__);

        return $this-&gt;renderTemplate('plugin/done');
    }
}
</code></pre>

<p>This did the trick for what I wanted. Thanks again!</p>

CC BY-SA 4.0
2020-03-12T11:28:15.657Z
Wow! That's a good find man!
Tudor-Radu Barbu
CC BY-SA 4.0
2019-01-12T16:51:49.193Z
2019-01-12T16:51:49.193Z
Josh Kautz
<p>I've set up the routing for a specific URL in my plugin to trigger the actionIndex controller method. I after logging a message to the Craft logs, I want to return the rendered twig file as the view, which is supposed to look just like an empty Control Panel page. Pretty simple in theory.</p>

<p>Everything in the twig file seems to render just fine (text &amp; images) except for the CSS.</p>

<p><strong>Controller: Controller.php</strong></p>

<pre><code>class Controller extends \craft\web\Controller
{
    public function actionIndex(){

        Craft::info("hello!", __METHOD__);

        return Craft::$app-&gt;getView()-&gt;renderTemplate('plugin/done');
    }
}
</code></pre>

<p><strong>Template: done.twig</strong></p>

<pre><code>{% extends "_layouts/cp" %}
{% set title = "Manual Sync"|t('plugin') %}

{% block content %}
    &lt;p&gt;Manual Sync Done.&lt;/p&gt;
{% endblock %}
</code></pre>

<p>I've attached a screenshot of the elements that are rendered on the page.
<a href="https://i.sstatic.net/t4lJt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/t4lJt.png" alt="Screenshot of rendered elements"></a></p>

<p>Hopefully that is enough for someone to help bounce some ideas around with me. Any advice and suggestions would be greatly appreciated!</p>

CC BY-SA 4.0
2019-01-17T14:37:07.773Z
Please check on your browser "network request details" window, what files are not found. If the path to your css in the template is correct, please show the part in your "_layouts/cp" file, where and how the css is included and the path of the file, that is not found.
phaetons
<plugin-development><craft3><controller><css>
renderTemplate() renders the twig file without any CSS
# renderTemplate() renders the twig file without any CSS

(Asked by: username_0 on 2019-01-12)

I've set up the routing for a specific URL in my plugin to trigger the actionIndex controller method. I after logging a message to the Craft logs, I want to return the rendered twig file as the view, which is supposed to look just like an empty Control Panel page. Pretty simple in theory.
Everything in the twig file seems to render just fine (text & images) except for the CSS.
Controller: Controller.php
class Controller extends \craft\web\Controller
{
    public function actionIndex(){

        Craft::info("hello!", __METHOD__);

        return Craft::$app->getView()->renderTemplate('plugin/done');
    }
}

Template: done.twig
{% extends "_layouts/cp" %}
{% set title = "Manual Sync"|t('plugin') %}

{% block content %}
    Manual Sync Done.
{% endblock %}

I've attached a screenshot of the elements that are rendered on the page.

Hopefully that is enough for someone to help bounce some ideas around with me. Any advice and suggestions would be greatly appreciated!

**Tags:** plugin-development, craft3, controller, css

> **Comments:**
> **username_1**: Please check on your browser "network request details" window, what files are not found. If the path to your css in the template is correct, please show the part in your "_layouts/cp" file, where and how the css is included and the path of the file, that is not found.  

---

## 2 answers

### Answer by username_0 on 2019-01-12. Score: 6 | Accepted answer

I sincerely appreciate the responses!
I've since resolved this issue, below is the changed code. My controller was extending the Craft web controller (\craft\web\Controller) which has its own renderTemplate() method that I switched to, which fetches the Control Panel assets I wanted for styling the page.
The template twig file remains identical as is above.
(Modified) Controller: Controller.php
class Controller extends \craft\web\Controller
{
    public function actionIndex(){

        Craft::info("hello!", __METHOD__);

        return $this->renderTemplate('plugin/done');
    }
}

This did the trick for what I wanted. Thanks again!

> **Comments:**
> **username_3**: Wow! That's a good find man!  

---

### Answer by username_2 on 2019-01-12. Score: 2

To me it looks like something with your sites URL is wrong or your server's configuration and therefore the CSS is not loaded.

Can you take a look into your HTML-Output regarding the Links to the CSS-files? Are they linked correctly? Is both http/s?

> **Comments:**
> **username_0**: Thank you for the response - I really appreciate username_2! That got me on the right path for looking at the \craft\web\Controller that I was extending, and I saw that it a renderTemplate() method that I actually should've been using. I've got it all working now, so I'll go ahead and post the changes I made so that hopefully someone in the future can maybe find some help from my blunders!  

---

