Having JS Toolbar for login and similar purposes along with Flat welcoming message with another login form is overkill.
Is there a code that can display registration form instead of login form?
Modifying com_community\templates\Flat\layouts\frontpage\guest.php is not that much of an issue, few lines of code that displays jomsocial register will do ;)
Loading it as iframe is not elegant way.
Also, Register button from JS Toolbar messes up Register button from Flat guest.php form. Register from Flat guest.php ends with error:
Notice
Login failed
At the same time Register from JS Toolbar works as intended.
To fix this in Flat theme guest.php <button> for Register needs to be coverted to <a> and everything works.
HI, Vladimir.
Thank you for contacting us.
I passed your issue report to our developer.
I hope this will be covered ASAP.
For those interested to implement Register instead of Login in Flat theme this is code for displaying JS Register form:
$view = JRequest::getCmd('view',null);
$layout = JRequest::getCmd('layout',null);
JRequest::setVar('view', 'register');
JRequest::setVar('layout', 'register');
$lang = JFactory::getLanguage();
$lang->load('com_community', JPATH_ADMINISTRATOR);
if (!class_exists('CommunityRegisterController')) {
require_once (JPATH_COMPONENT .DS. 'controllers' .DS. 'register.php');
}
$controller = new CommunityRegisterController();
$controller->execute('display');
if($view != null)
{
JRequest::setVar('view', $view);
}
if($layout != null)
{
JRequest::setVar('layout', $layout);
}
Can some of devs confirm this implementation is correct and not harmful in any way?
Or maybe just this is enough:
$lang = JFactory::getLanguage();
$lang->load('com_community', JPATH_ADMINISTRATOR);
if (!class_exists('CommunityRegisterController')) {
require_once (JPATH_COMPONENT .DS. 'controllers' .DS. 'register.php');
}
$controller = new CommunityRegisterController();
$controller->execute('register');
<script>
// Validate form before submit.
function joms_validate_form( form ) {
if ( window.joms && joms.util && joms.util.validation ) {
// Prevents repeated clicks.
if ( window.joms_validating_form ) return;
window.joms_validating_form = true;
joms.jQuery('.joms-loading').show();
joms.util.validation.validate( form, function( errors ) {
if ( !errors ) {
joms.jQuery( form ).removeAttr('onsubmit');
setTimeout(function() {
joms.jQuery( form ).find('button[type=submit]').click();
}, 500 );
} else {
joms.jQuery('.joms-loading').hide();
window.joms_validating_form = false;
}
});
}
return false;
}
joms.onStart(function( $ ) {
function insertAuthkey() {
joms.ajax({
func: 'register,ajaxGenerateAuthKey',
data: [ '_dummy_' ],
callback: function( json ) {
joms.jQuery('#authenticate').val( 1 );
joms.jQuery('#authkey').val( json.authKey );
joms.jQuery('#login-form input, #form-login input, form[name=login] input').filter(function() {
return this.name.match(/[0-9a-z]{32}/);
}).prop( 'name', json.authKey );
}
});
}
var timer = setInterval(function() {
if ( joms.ajax ) {
clearInterval( timer );
insertAuthkey();
}
}, 100);
});
</script>
And also some modification to base.php needs to be done so copy from jomsocial theme \layouts\register\base.php to Flat same folder structure and modify line 19:
<form method="POST" action="<?php echo CRoute::getURI(); ?>"
onsubmit="return joms_validate_form( this );">
to look like:
<form method="POST" action="<?php echo CRoute::_('index.php?option=com_community&view=register&task=registerProfile&profileType=0'); ?>"
onsubmit="return joms_validate_form( this );">
Some css needs to be corrected to accommodate larger form:
.joms-landing__image {
min-height: 775px;
}
Is this correct implementation of this kind of modification?
HI, Vladimir.
It's fixed in latest version 1.0.1.
Please, download if from here:
www.jomsocial.com/my-downloads
Install it by uploading package content here: ROOT/components/com_community/templates
Then browse to Backend -> Components -> JomSocial -> Theme Designer -> Colors and click SAVE button.
HI, Vladimir.
Thanks for this nice hack.
Not all communities are using JS Toolbar so login for shoudl be displayed in theme.
But you may also disable it Theme Designer.
The rest will be just a customization if you prefer to have registration form there.