Skip to content
Snippets Groups Projects
Commit 9a75d40d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix switching between web sites

parent 525b2cf2
Branches
Tags
No related merge requests found
...@@ -137,6 +137,8 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain ...@@ -137,6 +137,8 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
* Actions * Actions
*/ */
if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
// Add page // Add page
if ($action == 'add') if ($action == 'add')
{ {
...@@ -476,7 +478,7 @@ if (count($object->records) > 0) ...@@ -476,7 +478,7 @@ if (count($object->records) > 0)
} }
$out.='</select>'; $out.='</select>';
print $out; print $out;
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">'; print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Refresh").'">';
if ($website) if ($website)
{ {
...@@ -529,10 +531,19 @@ if (count($object->records) > 0) ...@@ -529,10 +531,19 @@ if (count($object->records) > 0)
$out.='<select name="pageid">'; $out.='<select name="pageid">';
if ($atleastonepage) if ($atleastonepage)
{ {
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage) foreach($array as $key => $valpage)
{ {
if (empty($pageid) && $action != 'create') $pageid=$valpage->id; if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"'; $out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>'; $out.='>';
...@@ -544,7 +555,7 @@ if (count($object->records) > 0) ...@@ -544,7 +555,7 @@ if (count($object->records) > 0)
else $out.='<option value="-1">&nbsp;</option>'; else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>'; $out.='</select>';
print $out; print $out;
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Refresh").'"'.($atleastonepage?'':' disabled="disabled"').'>';
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array); //print $form->selectarray('page', $array);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment