How to dynamically change the default app of a menu?

Based on the value of certain global variables, I would like to change the default application of a menu.

Here are my questions if you can answer any of them I appreciate it:

Q1 - I use the settings to change the default application in a static menu. Anyway to change that as menu initializes?
Q2 - any way to change default menu app later by script or macro?

Q3 - I see how to make a dynamic menu using tables, but how to you set the default on those dynamic menus?

Q4 - as a fall back, can I set default app to a blank app, then use event to test and use sc_redir macro to change to the proper app?

Re: How to dynamically change the default app of a menu?

Hurray! I was able to put a global variable into the default app setting field, instead of just an app name. Now I can change that by my scripts. SC thinks of everything…although I swear I could not find that on any sample, help file, or forum post…

Peace,
Jamie

1 Like

[QUOTE=onmountain;8567]Hurray! I was able to put a global variable into the default app setting field, instead of just an app name. Now I can change that by my scripts. SC thinks of everything…although I swear I could not find that on any sample, help file, or forum post…

Peace,
Jamie[/QUOTE]

Can you explain more detail about how you did this?

Yes please share!!!

I expect you can enter a global variable as the default name like [my_startapplication] ?
To use it you must have set it properly before this action is executed: in another application or in the onscriptinit.

Yes, that’s what I was looking for. I’ve tested aducom’s solution and it works perfectly.

In menu_app I set a global variable as the default app name, example: [default_app]

When I log in, I send one value [default_app]=‘form_one_app’, and if I need to change the menu default application, for exampe using sc_redir macro, I do it like this:

sc_redir(menu_app.php,default_app='form_another_app,"_top");

Interesting!

How can I dynamically change the image in my menu header (Layout -> Header & Footer)
This is urgent please help!

in onLoad of Menu App

/* load CompanyLogo from table Company */

$CompanyLogo=’’;
sc_set_global($CompanyLogo);

// site_table has a blob field called mylogo loaded with an image
$sql_command = “SELECT CompanyLogo from Company”; // using the session variable set elsewhere (or could be passed into this app)
sc_lookup(my_data, $sql_command); // make sure this app has the connection to your DB setup in one of the settings

if ({my_data} == false)
{
echo “Access error Message=”.{my_data_erro}; // haven’t tested this but I want to not crash later
[CompanyLogo] = NULL;
}
elseif (empty({my_data})) // same, not tested but should prevent later crash if no value in table
{
[CompanyLogo] = NULL;
}
else
{
// this loads the variable with the html AND the blob image data, so it works in the header later
[CompanyLogo] = ‘<img src="data:image/jpeg;base64,’ . base64_encode( {my_data[0][0]} ) . ‘" />’;
}

in the Menu/Layout/Header give the global Variable ‘[CompanyLogo]’

Hi, can we use the same solution in scriptcase 9?