php - TYPO3 7.6.10: How to extend the felogin extension? -
i tried extend core extension felogin
extension called "feloginextended".
i want add first_name
, last_name
property of current user logout formular.
this overridden template (only 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 added controller classes\xclass\frontendlogincontroller
extension.
i copied original file , add changes in showlogout function, set markers:
<?php namespace typo3\feloginextended\xclass; use \typo3\cms\frontend\plugin\abstractplugin; /** * plugin 'website user login' 'felogin' extension. */ class frontendlogincontroller extends abstractplugin { /** * shows logout form * * @return string 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; // 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 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 register template in ext_typoscript_setup.txt
file:
plugin.tx_felogin_pi1 { templatefile = ext:feloginextended/resources/private/templates/frontendlogin.html }
and final step registration of controller in 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 changes original files of felogin extension, have solution.
but way dirty , in future can't update felogin extension easily.
i found "solution": https://forum.typo3.org/index.php/t/202500/ don't work me.
have idea or have other way bring first , last name of current user logout formular?
edit: everytime http error 500!
thanks felix
the solution pretty simple. can add markers ###feuser_first_name###
, ###feuser_last_name###
template , replaced right values. schema general , can used on fields of user:
###feuser_{db field in uppercase}###
. note fields used underscores , not lower camelcase.
this works in typo3 6.x , code looks same in 7.6 should work too.
Comments
Post a Comment