choose the first page to open on after login

drashrafsabry

Well-known member
hello
dadabik 8.1 pro always opens on the first alphabetical table in my list , lets say i have certificates table and patients table, after login it automatically goes to certificate table as it is alphabetically the first. I want to assign which table shows first when i login
 

eugenio

Administrator
Staff member
Hello,
if you have an homepage set (from custom pages you can set one of the custom pages as home) DaDaBIK after login shows that page, otherwise you are right, it uses the first table available.

A workaround is the following: open /include/check_table.php and change this line:

$table_name = $tables_names_ar[0];

with:

$table_name = 'name of the table you want to be the first';

Best,
 
Hi Eugenio,
thanks for the hint, unfortunately it is not working though.

/include/check_table.php:
Line 91:
Before: $table_name = $tables_names_ar[0];

Now: $table_name = "daten_gesamt";

Nevertheless the first available table (named "betriebsdaten") is still shown immediately after login, like before.

Do you have any clue how to solve this?

Best wishes
Andreas
 

eugenio

Administrator
Staff member
Sorry, you are right, just leave

$table_name = $tables_names_ar[0];

as it is and add:

$table_name = "daten_gesamt";

after the few lines of code that start with:

// override if there is at least one non-admin

so before:

} // end if

Best,
 

eugenio

Administrator
Staff member
Hello,
not possible in 9.0; in 9.1, however, you will be able to add custom code to a STARTUP function; you can use this function for several things, including redirect to a specific table if the table is not set.

DaDaBIK 9.1 should be available very soon, if you write back here after its release I can give a one-line code that does the trick.

Best,
 

eugenio

Administrator
Staff member
Hello,
for example you can write this simple code in the startup function to redirect to the table "products", assuming you didn't change the parameter $dadabik_main_file in config.php

global $site_url;

if (!isset($_GET['tablename']) && basename($_SERVER['SCRIPT_NAME'], '.php') === 'index'){
$my_table = 'products';
header('location:'.$site_url.'index.php?tablename='.urlencode($my_table).'&function=search');

}


eugenio Wrote:
-------------------------------------------------------
> Hello,
> not possible in 9.0; in 9.1, however, you will be
> able to add custom code to a STARTUP function; you
> can use this function for several things, includin
> g redirect to a specific table if the table is not
> set.
>
> DaDaBIK 9.1 should be available very soon, if you
> write back here after its release I can give a one
> -line code that does the trick.
>
> Best,
 

FRW

Well-known member
Thank you for this.
And if you add an order statement after [pre]
'&function=search'
[/pre]
f.e.: [pre]
'&function=search&order=date&order_type=DESC'
[/pre]
we''ve got solved another feature request:)-D
 

FRW

Well-known member
I put this in custom_functions.php:

[pre]
$custom_startup_function = 'dadabik_startup';

function dadabik_startup()
{
global $site_url;

if (!isset($_GET['tablename']) && basename($_SERVER['SCRIPT_NAME'], '.php') === 'index'){
$my_table = 'Erklaerung';
header('location:'.$site_url.'index.php?tablename='.urlencode($my_table).'&function=search');
}
}
[/pre]

from now on I cannot open my custom (html-) page. The link in menu is shown, but the page wont. Commented it out and everything works.
 

eugenio

Administrator
Staff member
Hello,
I thought you didn't have any custom page, if you also have custom pages probably you can fix that by adding an additional condition to the if statement:


if (!isset($_GET['tablename']) && (!isset($_GET['function']) || $_GET['function'] !== 'show_static_page') && basename($_SERVER['SCRIPT_NAME'], '.php') === 'index'){
 

FRW

Well-known member
Little error left for "Your Account":

This will help:
[pre]
if (!isset($_GET['tablename']) && (!isset($_GET['function']) || $_GET['function'] !== 'show_static_page') && ($_GET['function'] !== 'edit_account') && basename($_SERVER['SCRIPT_NAME'], '.php') === 'index'){
[/pre]
 

eugenio

Administrator
Staff member
Right!

You should also consider the case function is not set, so

(!isset($_GET['function']) || $_GET['function'] !== 'edit_account')

is better than

($_GET['function'] !== 'edit_account')

Best,
 
Top