Help article from database

Hi SC-fans,

i’m looking forward to the best-practice for a help system for every fields. The help content for a field (the “?” tag behind a field) should be saved at the database. Later somebody without scriptcase can write the article with a sc grid/form.

Current i realize it with a short sql-code in onApplicationInit and a [helpX] in the field-config:

$seite = “form_app_firma”; // How can i get the name of the application? Constants, specific variable?
sc_lookup(my_data, “SELECT
hilfe_id,
hilfe_seite,
hilfe_titel,
hilfe_text
FROM
app_hilfe
WHERE
(hilfe_seite = '”.$seite."’)
ORDER BY
hilfe_id");
if ({my_data} === false)
{
echo “Access error. Message=”. {my_data_erro} ;
}
elseif (empty({my_data}))
{
echo “Kein Hilfetext gefunden”;
}
else
{
{Hilfefeld} = {my_data[0][0]};
[Hilfetitel] = {my_data[0][2]};
[help1] = {my_data[0][3]};
[help2] = {my_data[1][3]};
[help3] = {my_data[2][3]};
[help4] = {my_data[3][3]};
[help5] = {my_data[4][3]};
}

I think, it’s ok but not really very comfortable for a form with 25 fields or more, 3 master-detail-forms… :wink: Do you have some better solutions / ideas? Perhaps a connection between the field and a function?

Thanks!

Lars

if you have a table with the field name you can create a global variable array to get the help description
for example considere the table

[table=“width: 500”]
[tr]
[td]TableName[/td]
[td]Field Name[/td]
[td]Description[/td]
[/tr]
[tr]
[td]Table1[/td]
[td]Field1[/td]
[td]help text for field 1[/td]
[/tr]
[tr]
[td]Table1[/td]
[td]Field2[/td]
[td]help text for field 2[/td]
[/tr]
[/table]

so in the onload event you create an sql statement like


$sql = "SELECT * FROM helptexttable WHERE table= <The table name you require>"
sc_lookup( helptext, $sql);
if ( isset({helptext[0][0]}) )
{
     foreach({helptext} as $help)
    {
        [g_HelpVariable][ $help[1] ] = $help[2];
    }
}

Then make sure in every field at design time you place in the “Help description” property something like

[g_HelpVariable][ ‘<field name>’ ]

Hope this helps.

Regards

hi kafecadm,

thank you for your help. I guess, this is a good solution for my requirements :slight_smile:



$seite = "form_app_firma";
$sql = "SELECT `hilfe_seite`, `hilfe_feld`, `hilfe_text` FROM `app_hilfe` WHERE `hilfe_seite` = '".$seite."'";
sc_lookup( helptext, $sql);
if ( isset({helptext[0][0]}) )
{
     foreach({helptext} as $help)
    {
        [g_HelpVariable][ $help[1] ] = $help[2];
    }
}   

echo [g_HelpVariable][ 'firmennummer' ]; //only in a blank application for tests


I tested the code with a form application and a blank application. But only the blank application works. The form shows a fault message:

Notice: Array to string conversion in /opt/NetMake/v8/wwwroot/scriptcase/app/dbhelp/form_app_firma/form_app_firma_help.php on line 49
Firmennummer
Array[ ‘firmennummer’ ]

The variable is global and the typ “out”.

Thanks.
Lars

Cold you please share a screen capture with me so i can take a look at your helpcase field configuration?.

regards

Hello kafecadm,

i have tried all versions of [g_HelpVariable][ ‘<field name>’ ] -> [g_HelpVariable][ ‘firmennummer’ ] -> [g_HelpVariable][ ‘<firmennummer>’ ] … and the help typ “popup”,“text”… and in the events onload, onApplicationinit…

Thank your for the help.

Lars

CropperCapture[5].png

CropperCapture[4].png

CropperCapture[3].png

CropperCapture[2].png

CropperCapture[1].png

Hello my friend, I checked your code and i found the problem ( It was me =P ) whenever you use something inside helpcase it makes a code similar to this:

<?php echo “<b>Code</b><br>” . nl2br(" text " . $_SESSION[‘Code’] . " text "); ?>

so when you use an expression like [g_Help][Somethingelse] it tries to do something like this

<?php echo “<b>Code</b><br>” . nl2br("" . $_SESSION[‘Code’] . " $_SESSION[‘Somethingelse’]"); ?>

Reason why you get the output Array [‘firmennummer’] so we have to get rid of SC’s session variables for a bit.

try this ok?


$seite = "form_app_firma";
$sql = "SELECT `hilfe_seite`, `hilfe_feld`, `hilfe_text` FROM `app_hilfe` WHERE `hilfe_seite` = '".$seite."'";
sc_lookup( helptext, $sql);
if ( isset({helptext[0][0]}) )
{
     foreach({helptext} as $help)
    {
        $_SESSION[ $help[1] ] = $help[2];
    }
}   


This will create session variables with the name of the field. kind of what would happen if you use [FieldName].

then in your HelpCase type

[firmennummer]

Try it out and lemme know how it goes.

Regards

Yes, it works perfect. I think this is an easy and fast way for a database saved help field - perhaps an entry for the hot tip category?

Thank you and i hope in the future i’ll get same knowledge for help to fix questions like “control form / entire sice” :wink:

lol tnx… css is my weakspot =P

c u around.