Custom login page from package

Permalink
Is it possible to either replace the existing login page or create a new login page, when installing a package.
To be a bit more clear I want to install a custom login page when the package is installed.

mikeyt55
 
JohntheFish replied on at Permalink Reply
JohntheFish
See
http://www.concrete5.org/documentation/how-tos/designers/themimg-sy...

You will need to create the single page at the correct path in your package single pages directory and possibly also a corresponding controller.

I think the stuff about setting theme paths can be run once from the package install, though if you are mapping multiple themes about between pages you may need to do it in an on_start or on_before_render.

There is some other useful code in @mnkras' theme switcher block.
mikeyt55 replied on at Permalink Reply
mikeyt55
ah ok, any idea how I would do that on the installation of a package?
I tried
public function install() {
  $pkg = parent::install();
$v = View::getInstance();
$v->setThemeByPath('/login', "mytheme");
}

but no success,
Any idea where this should be? for the package install
JohntheFish replied on at Permalink Reply
JohntheFish
If it doesn't behave in install, I would try in an on_start event handler, or maybe an on_before_render handler.
freakpants replied on at Permalink Reply
A working version for 2020 is the following in the package controller:

public function on_start()
{
$app = Application::getFacadeApplication();
$app->make(\Concrete\Core\Page\Theme\ThemeRouteCollection::class)>setThemeByRoute("/login", 'my_theme');
}
omars786 replied on at Permalink Reply
omars786
Thanks Freakpants - this info was very useful to me..

By the way you missed a hyphen in the code

$app->make(\Concrete\Core\Page\Theme\ThemeRouteCollection::class)->setThemeByRoute("/login", 'my_theme');
simonchilton replied on at Permalink Reply
simonchilton
v8.5 code, in your package controller:
public function on_start()
{
    $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
    $app->make(\Concrete\Core\Page\Theme\ThemeRouteCollection::class)->setThemeByRoute("/login", 'my_theme');
}