I cannot find a way to render templates from a plugin controller in Craft 3. I feel as though I've tried every variation advised online but for some reason this still isn't working.
<?php
namespace abc\members\controllers;
class LoginController extends \craft\web\Controller
{
public function actionForm()
{
$this->renderTemplate('abc-members/login.html');
}
}
The plugin handle is "abc-members".
The plugin has a "templates" directory with "login.html".
I've tried the following, with and without the .html extension, but none can find the template:
$this->renderTemplate('abc-members/login.html');
$this->renderTemplate('abc-members/templates/login.html');
$this->renderTemplate('abc-members/src/templates/login.html');
$this->renderTemplate('abc/members/src/templates/login.html');
$this->renderTemplate('plugins/abc/members/src/templates/login.html');
The following works fine but then I cannot include templates from the installation's main template directory.
<?php
namespace abc\members\controllers;
class LoginController extends \craft\web\Controller
{
public function actionForm()
{
\Craft::$app->view->setTemplatesPath(__DIR__ . '/../templates');
$this->renderTemplate('login.html');
}
}
Any suggestions as to where I'm going wrong? I find the Craft 3 docs are a bit lacking in the whole area of plugin controllers, routing and templates other than in the Craft 2 => Craft 3 upgrade guide.
Thanks