I tried to extend the core extension felogin
with an extra extension called "feloginextended".
I want to add the first_name
and the last_name
property of the current user into my logout formular.
This is my overridden template (only the logout part):
<!--###TEMPLATE_LOGOUT###-->
<form class="login-form" action="###ACTION_URI###" target="_top" method="post">
<div>
<div class="user">###FIRSTNAME### ###LASTNAME###</div>
<a class="page-link-button" href="http://tf.lightblue.eu/index.php?id=14">Meine Siegel</a>
<a class="page-link-button" href="http://tf.lightblue.eu/index.php?id=15">Mein Account</a>
<input class="form-btn" type="submit" name="submit" value="Logout" />
</div>
<div class="felogin-hidden">
<input type="hidden" name="logintype" value="logout" />
<input type="hidden" name="pid" value="###STORAGE_PID###" />
<input type="hidden" name="###PREFIXID###[noredirect]" value="###NOREDIRECT###" />
</div>
</form>
<!--###TEMPLATE_LOGOUT###-->
Then I added the Controller Classes\Xclass\FrontendLoginController
to my extension.
I copied the original file and add some changes in the showLogout function, to set the markers:
<?php
namespace Typo3\feloginextended\Xclass;
use \TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
/**
* Plugin 'Website User Login' for the 'felogin' extension.
*/
class FrontendLoginController extends AbstractPlugin
{
/**
* Shows logout form
*
* @return string The content.
*/
protected function showLogout()
{
$subpart = $this->cObj->getSubpart($this->template, '###TEMPLATE_LOGOUT###');
$subpartArray = ($linkpartArray = array());
$markerArray['###STATUS_HEADER###'] = $this->getDisplayText('status_header', $this->conf['logoutHeader_stdWrap.']);
$markerArray['###STATUS_MESSAGE###'] = $this->getDisplayText('status_message', $this->conf['logoutMessage_stdWrap.']);
$this->cObj->stdWrap($this->flexFormValue('message', 's_status'), $this->conf['logoutMessage_stdWrap.']);
$markerArray['###LEGEND###'] = $this->pi_getLL('logout', '', true);
$markerArray['###ACTION_URI###'] = $this->getPageLink('', array(), true);
$markerArray['###LOGOUT_LABEL###'] = $this->pi_getLL('logout', '', true);
$markerArray['###NAME###'] = htmlspecialchars($this->frontendController->fe_user->user['name']);
$markerArray['###STORAGE_PID###'] = $this->spid;
$markerArray['###USERNAME###'] = htmlspecialchars($this->frontendController->fe_user->user['username']);
$markerArray['###USERNAME_LABEL###'] = $this->pi_getLL('username', '', true);
$markerArray['###NOREDIRECT###'] = $this->noRedirect ? '1' : '0';
$markerArray['###PREFIXID###'] = $this->prefixId;
// my custom changes-----------------------------------
$markerArray['###FIRSTNAME###'] = htmlspecialchars($this->frontendController->fe_user->user['first_name']);
$markerArray['###LASTNAME###'] = htmlspecialchars($this->frontendController->fe_user->user['last_name']);
//------------------------------------------------------
$markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
if ($this->redirectUrl) {
// Use redirectUrl for action tag because of possible access restricted pages
$markerArray['###ACTION_URI###'] = htmlspecialchars($this->redirectUrl);
$this->redirectUrl = '';
}
return $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $linkpartArray);
}
}
Then I register my template in the ext_typoscript_setup.txt
file:
plugin.tx_felogin_pi1 {
templateFile = EXT:feloginextended/Resources/Private/Templates/FrontendLogin.html
}
And my final step was the registration of the controller in the ext_localconf.php
:
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Felogin\\Controller\\FrontendLoginController'] = array(
'className' => 'Typo3\\Feloginextended\\Xclass\\FrontendLoginController',
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['tx_felogin_pi1'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Felogin\\Controller\\FrontendLoginController'];
If add this changes into the original files of the felogin extension, then I have a solution.
But this way is very dirty and in the future I can't update the felogin extension easily.
I found this "solution": https://forum.typo3.org/index.php/t/202500/ But it don't work for me.
Have anyone an idea or have an other way to bring the first and the last name of the current user to the logout formular?
EDIT: I get everytime a http error 500!
Thanks Felix