Re: How to display an image on a header value line using a blob myql field
Hi Chris,
This is what I have found works to change the logo in the menu header:
First, I have a SC session global variable called [glo_siteid]. This gets set based on the user login, which site they belong to , etc. Whatever scheme fits your system…
Second, I have a regular menu (could be horizontal or vertical). In that menu app I use the onLoad event to basically preload a global variable for use later. In my case, I want to load the valiable called [glo_logo] using the following code:
// site_table has a blob field called mylogo loaded with an image
$sql_command = “SELECT mylogo from site_table WHERE id = '”.[glo_siteid]."’ "; // 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
[glo_logo] = NULL;
}
elseif (empty({my_data})) // same, not tested but should prevent later crash if no value in table
{
[glo_logo] = NULL;
}
else
{
// this loads the variable with the html AND the blob image data, so it works in the header later
[glo_logo] = ‘<img src="data:image/jpeg;base64,’ . base64_encode( {my_data[0][0]} ) . ‘" />’;
}
Now that the onLoad event has loaded that variable, I go to the Layout - Header + Footer settings.
Changed the NM_LOGOTIPO (or whatever SC had called the built-in logo) to use Value, then put the global variable in teh next field [glo_logo]
That should put your logo from the DB blob field in where the hard coded default SC image was. This I have working with no problems so far.
The other fields can use variables to display other info, using html and global variable values set somewhere else as well. It actually let me get just the effect I wanted. The headers on all the apps, I believe, can be modified in this same way.
Note - if you put stuff like echo [glo_logo] into the onLoad event, you can put all sorts of other stuff BEFORE the SC header. I was looking at doing that before I fgigured out ther above scheme. One approach could be to use the onLoad event to make a new header, matching the layout and colors etc of the whole app, then just don’t use the built-in header. I would consider that if you have a very complicated thing up there, like with javascript and stuff. But so far, I haven’t had to do that except in tests.
BTW Merry Christmas (80F here in Tampa).
Jamie