I would like to redirect customers after login to custom url according to a parameter.
Now, I can do custom redirection, as follows.
In /XLite/Module/VendorID/ModuleID/Controller/Customer/Login.php
Code:
<?php
namespace XLite\Module\VendorID\ModuleID\Controller\Customer;
class Login extends \XLite\Controller\Customer\Login implements \XLite\Base\IDecorator
{
protected function loginBody()
{
{
$this->profile = $this->performLogin();
$profileCart = $this->getCart();
$this->setReturnURL(
\XLite\Core\Converter::buildFullURL('mypage')
);
$this->setHardRedirect();
}
}
}
(This time, I didn't forget "implements \XLite\Base\IDecorator" part).
However, the following code doesn't work.
Code:
<?php
namespace XLite\Module\VendorID\ModuleID\Controller\Customer;
class Login extends \XLite\Controller\Customer\Login implements \XLite\Base\IDecorator
{
protected function loginBody()
{
if(\XLite\Core\Request::getInstance()->param == "myparam")
{
$this->profile = $this->performLogin();
$profileCart = $this->getCart();
$this->setReturnURL(
\XLite\Core\Converter::buildFullURL('mypage')
);
$this->setHardRedirect();
}
else
{
parent::loginBody()
}
}
}
and the customer logs in to cart.php?target=login¶m=myparam,
the customer doesn't get redirected to cart.php?target=mypage, instead
the customer gets redirected to cart.php (?target=main is implicit).
What am I doing here this time?
Of course, I could write another class, say mylogin.php so that the customer can
log in to cart.php?target=mylogin to get redirected to cart.php?target=mypage,
but this is not elegant or economic. Furthermore, in the module I am currently
working with, there are only two pages to redirect, but in another module in my project, there are more pages and I would rather not write one class for each page
to redirect... Would anyone have an idea?