diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 5d2dcb9a15f..dff0dd70175 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -825,14 +825,26 @@ if ($action == 'addcontainer')
if (!$error)
{
- $res = $objectpage->create($user);
- if ($res <= 0)
- {
+ $pageid = $objectpage->create($user);
+ if ($pageid <= 0) {
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
$action = 'createcontainer';
}
+ else {
+ // If there is no home page yet, this new page will be set as the home page
+ if (empty($object->fk_default_home)) {
+ $object->fk_default_home = $pageid;
+ $res = $object->update($user);
+ if ($res <= 0)
+ {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+ }
}
+
if (!$error)
{
if (!empty($objectpage->content))
@@ -2891,7 +2903,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '
';
if (!empty($conf->use_javascript_ajax)) print ' ';
- print '
';
+ print '
';
print '
| ';
@@ -2912,7 +2924,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print ' '; if (!empty($conf->use_javascript_ajax)) print ' '; - print ' '; + print ' '; print ' '; } @@ -3015,7 +3027,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ' | |
| '; print $langs->trans('Language'); print ' | '; - print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); + print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200'); print ' |