Skip to content

Commit 7e52a31

Browse files
travisrisnerbrianteemanQuyTon
authored
[5.4] Add support for custom registration menu link in com_users login menu item (joomla#45715)
* Add custom registration link to login menu --------- Co-authored-by: Brian Teeman <[email protected]> Co-authored-by: Quy Ton <[email protected]>
1 parent 595008c commit 7e52a31

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

administrator/language/en-GB/com_users.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ COM_USERS_FIELD_LOGOUT_REDIRECTMENU_LABEL="Menu Item Logout Redirect"
127127
COM_USERS_FIELD_LOGOUT_REDIRECT_CHOICE_DESC="'Internal URL' lets you manually enter any internal URL in the Redirect field. 'Menu Item' lets you directly select an existing menu item.<br>For a multilingual site, it is recommended to use 'Menu Item'."
128128
COM_USERS_FIELD_LOGOUT_REDIRECT_CHOICE_LABEL="Choose Logout Redirect Type"
129129
COM_USERS_FIELD_LOGOUT_REDIRECT_ERROR="Only one of the logout redirect fields should have a value."
130+
COM_USERS_FIELD_REGISTRATION_DESC="Set a Menu Item to utilize a custom registration page."
131+
COM_USERS_FIELD_REGISTRATION_LABEL="Registration Page"
130132
COM_USERS_FIELD_NOTEBODY_LABEL="Note"
131133
COM_USERS_FIELD_OPTIONS_LOGIN="Login"
132134
COM_USERS_FIELD_OPTIONS_LOGOUT="Logout"
135+
COM_USERS_FIELD_OPTIONS_REGISTRATION="Registration"
133136
COM_USERS_FIELD_REVIEW_TIME_LABEL="Review Date"
134137
COM_USERS_FIELD_SUBJECT_LABEL="Subject"
135138
COM_USERS_FIELD_USER_ID_LABEL="User"

components/com_users/tmpl/login/default.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@
180180
description="COM_USERS_FIELD_IMAGE_ALT_EMPTY_DESC"
181181
/>
182182
</fieldset>
183+
184+
<fieldset name="registration" label="COM_USERS_FIELD_OPTIONS_REGISTRATION">
185+
<field
186+
name="customRegLinkMenu"
187+
type="modal_menu"
188+
label="COM_USERS_FIELD_REGISTRATION_LABEL"
189+
description="COM_USERS_FIELD_REGISTRATION_DESC"
190+
disable="separator,alias,heading,url"
191+
select="true"
192+
new="true"
193+
edit="true"
194+
clear="true"
195+
>
196+
<option value="">JOPTION_SELECT_MENU_ITEM</option>
197+
</field>
198+
</fieldset>
183199
</fieldset>
184200
</fields>
185-
</metadata>
201+
</metadata>

components/com_users/tmpl/login/default_login.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
defined('_JEXEC') or die;
1212

1313
use Joomla\CMS\Component\ComponentHelper;
14+
use Joomla\CMS\Factory;
1415
use Joomla\CMS\HTML\HTMLHelper;
1516
use Joomla\CMS\Language\Text;
1617
use Joomla\CMS\Plugin\PluginHelper;
@@ -120,8 +121,21 @@ class="btn btn-secondary w-100 <?php echo $button['class'] ?? '' ?>"
120121
<a class="com-users-login__remind list-group-item" href="<?php echo Route::_('index.php?option=com_users&view=remind'); ?>">
121122
<?php echo Text::_('COM_USERS_LOGIN_REMIND'); ?>
122123
</a>
123-
<?php if ($usersConfig->get('allowUserRegistration')) : ?>
124-
<a class="com-users-login__register list-group-item" href="<?php echo Route::_('index.php?option=com_users&view=registration'); ?>">
124+
<?php
125+
if ($usersConfig->get('allowUserRegistration')) :
126+
$regLinkMenuId = $this->params->get('customRegLinkMenu');
127+
$regLink = 'index.php?option=com_users&view=registration';
128+
129+
if ($regLinkMenuId) {
130+
$menu = Factory::getApplication()->getMenu();
131+
$item = $menu->getItem($regLinkMenuId);
132+
133+
if ($item) {
134+
$regLink = 'index.php?Itemid=' . $regLinkMenuId;
135+
}
136+
}
137+
?>
138+
<a class="com-users-login__register list-group-item" href="<?php echo Route::_($regLink); ?>">
125139
<?php echo Text::_('COM_USERS_LOGIN_REGISTER'); ?>
126140
</a>
127141
<?php endif; ?>

0 commit comments

Comments
 (0)