Generally, when you are developing a desktop application, then you should provide your users Help feature so your user can easily display the help for the current window. Similarly to the web applications, that would be better if you provide Help feature, too.
The following customization will help you to make it comes true. After implementing it, then you will see an Help icon next to Page Title. When user clicks on that icon, then system will open a new window that displaying the help for the current page. This customization includes the creating of two tables in order to store help and its category records. You can manage this help from the generated page based on those two help tables.
Please note that this customization below depends on the customization in my previous article: How to Clear User Session ID in Websites that Created with PHPMaker 9.0.1
Updated on July 22, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 5, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 29, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 10, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: This customization below has been handled by using MasinoFixedWidthSite extension. You donβt need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extension files.
[hidepost]
-
First of all, create two new tables to store the help records. Simply using the following scripts (in this case I am using MySQL):
CREATE TABLE `help` ( `Help_ID` int(11) NOT NULL, `Language` char(2) NOT NULL, `Topic` varchar(255) NOT NULL, `Description` longtext NOT NULL, `Category` int(11) NOT NULL, `Order` int(11) NOT NULL, `Display_in_Page` varchar(100) NOT NULL, `Updated_By` varchar(9) DEFAULT NULL, `Last_Updated` datetime DEFAULT NULL, PRIMARY KEY (`Help_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE `help_categories` ( `Category_ID` int(11) NOT NULL, `Language` char(2) NOT NULL, `Category_Description` varchar(100) NOT NULL, PRIMARY KEY (`Category_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
Open your \Script\ewcfg.php file, and find this code:
// General
before that line, please insert the following code:
// Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 define("MS_HELP_TABLE", "help", TRUE); // Help table name, adjust with yours! // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012
-
Open your C:\Program Files\PHPMaker 9\languages\english.xml file, and find this code:
</global>
before that line, please insert the following code:
<phrase id="Help" value="Help"/> <phrase id="HelpNotAvailable" value="Sorry, help not available for this page."/>
Do the same way with your another .xml language file. For example, I am also using Indonesian, then I will add the following code into my C:\Program Files\PHPMaker 9\languages\indonesian.xml file:
<phrase id="Help" value="Bantuan"/> <phrase id="HelpNotAvailable" value="Maaf, bantuan belum tersedia untuk halaman ini."/>
-
Open your \Script\template.php file, and find this code:
<script language="JavaScript"> <!-- function popupWindow(url) { var SecondaryWin; SecondaryWin = window.open(url,"secondary","toolbars=0,statusbars=0,menubars=0,scroll=1,fullscreen=0,resizable=1,width=450,height=580"); self.name="main"; } --> </script>
if you don't find it, then insert that code before the following line:
</head>
otherwise, just skip this step.
-
Open your \Script\list-script.php file, and find this code (there are three occurrences you will find this code):
<?php $<!--##=sPageObj##-->->ExportOptions->Render("body"); ?>
before that line, please insert the following code (IMPORTANT: There are three occurrences you will do this step in that list-script.php file, so make sure you have done it for three times, too!):
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a> <?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\add-script.php file, and find this code:
<?php echo $<!--##=gsTblVar##-->->TableCaption() ?></span>
then replace it with the following code:
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?><?php echo $<!--##=gsTblVar##-->->TableCaption() ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a></span><?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\delete-script.php file, and find this code:
<?php echo $<!--##=gsTblVar##-->->TableCaption() ?></span>
then replace it with the following code:
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?><?php echo $<!--##=gsTblVar##-->->TableCaption() ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a></span><?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\edit-script.php file, and find this code:
<?php echo $<!--##=gsTblVar##-->->TableCaption() ?></span>
then replace it with the following code:
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?><?php echo $<!--##=gsTblVar##-->->TableCaption() ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a></span><?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\update-script.php file, and find this code:
<?php echo $<!--##=gsTblVar##-->->TableCaption() ?></span>
then replace it with the following code:
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?><?php echo $<!--##=gsTblVar##-->->TableCaption() ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a></span><?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\view-script.php file, and find this code:
<?php $<!--##=sPageObj##-->->ExportOptions->Render("body"); ?>
before that line, please insert the following code:
<?php // Begin of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?> <a href="javascript:popupWindow('help.php?page=<?php echo ew_CurrentPage(); ?>')"><img src="phpimages/question.ico" title="<?php echo ew_HtmlEncode($Language->Phrase("help")) ?>" width="16" height="16" border="0"></a> <?php // End of modification Add Help Feature, by Masino Sinaga, June 6, 2012 ?>
-
Open your \Script\control.xml file, and find this code:
<control id="datenumber-min.js" type="copy" ofolderid="_js" ifiles="datenumber-min.js" />
after that line, please insert the following code:
<control id="help.php" type="copy" remark="Copy help.php" ifiles="help.php" />
-
Create a new file and save it as help.php and put it under your \Script\ sub-directory. Copy-paste the following code into it:
<?php if (session_id() == "") session_start(); // Initialize Session data ob_start(); // Turn on output buffering ?> <?php include_once "ewcfg9.php" ?> <?php if (EW_IS_MYSQL) { include_once "ewmysql9.php"; } else if (EW_IS_MSSQL) { include_once "adodb5/adodb.inc.php"; } ?> <?php include_once "phpfn9.php" ?> <?php include_once "".MS_USER_TABLE_NAME."info.php" ?> <?php include_once "userfn9.php" ?> <?php // // Page class // $Help = NULL; // Initialize page object first class cHelp { // Page ID var $PageID = 'Help'; var $sEmail = ''; // Added by Masino Sinaga, in order to prevent error undefined variable $sEmail, January 16, 2012 var $sSrchWhere = ''; // Added by Masino Sinaga, in order to prevent error undefined variable $sSrchWhere, January 16, 2012 var $sDisabled = ''; // Added by Masino Sinaga, in order to prevent error undefined variable $sDisabled, January 16, 2012 // Project ID var $ProjectID = ""; // <-- Don't forget to adjust with yours! // Page object name var $PageObjName = 'Help'; // Page name function PageName() { return ew_CurrentPage(); } // Page URL function PageUrl() { $PageUrl = ew_CurrentPage() . "?"; return $PageUrl; } // Message function getMessage() { return @$_SESSION[EW_SESSION_MESSAGE]; } function setMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v); } function getFailureMessage() { return @$_SESSION[EW_SESSION_FAILURE_MESSAGE]; } function setFailureMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v); } function getSuccessMessage() { return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE]; } function setSuccessMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v); } function getWarningMessage() { return @$_SESSION[EW_SESSION_WARNING_MESSAGE]; } function setWarningMessage($v) { ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v); } // Show message function ShowMessage() { $hidden = TRUE; $html = ""; // Message $sMessage = $this->getMessage(); $this->Message_Showing($sMessage, ""); if ($sMessage <> "") { // Message in Session, display $html .= "<p class=\"ewMessage\">" . $sMessage . "</p>"; $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session } // Warning message $sWarningMessage = $this->getWarningMessage(); $this->Message_Showing($sWarningMessage, "warning"); if ($sWarningMessage <> "") { // Message in Session, display $html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewWarningIcon\"></td><td class=\"ewWarningMessage\">" . $sWarningMessage . "</td></tr></table>"; $_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session } // Success message $sSuccessMessage = $this->getSuccessMessage(); $this->Message_Showing($sSuccessMessage, "success"); if ($sSuccessMessage <> "") { // Message in Session, display $html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewSuccessIcon\"></td><td class=\"ewSuccessMessage\">" . $sSuccessMessage . "</td></tr></table>"; $_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session } // Failure message $sErrorMessage = $this->getFailureMessage(); $this->Message_Showing($sErrorMessage, "failure"); if ($sErrorMessage <> "") { // Message in Session, display $html .= "<table class=\"ewMessageTable\"><tr><td class=\"ewErrorIcon\"></td><td class=\"ewErrorMessage\">" . $sErrorMessage . "</td></tr></table>"; $_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session } echo "<div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div>"; } // // Page class constructor // function __construct() { global $conn, $Language; $GLOBALS["Page"] = &$this; // Language object if (!isset($Language)) $Language = new cLanguage(); // Page ID if (!defined("EW_PAGE_ID")) define("EW_PAGE_ID", 'Help', TRUE); // Start timer if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer(); // Open connection if (!isset($conn)) $conn = ew_Connect(); } // // Page_Init // function Page_Init() { // Global Page Loading event (in userfn*.php) Page_Loading(); // Page Load event $this->Page_Load(); } // // Page_Terminate // function Page_Terminate($url = "") { global $conn; // Page Unload event $this->Page_Unload(); // Global Page Unloaded event (in userfn*.php) Page_Unloaded(); $this->Page_Redirecting($url); // Close connection $conn->Close(); // Go to URL if specified if ($url <> "") { if (!EW_DEBUG_ENABLED && ob_get_length()) ob_end_clean(); header("Location: " . $url); } exit(); } // // Page main // function Page_Main() { global $Security, $Language; //$this->setSuccessMessage("Welcome " . CurrentUserName()); // Put your custom codes here } // Page Load event function Page_Load() { //echo "Page Load"; } // Page Unload event function Page_Unload() { //echo "Page Unload"; } // Page Redirecting event function Page_Redirecting(&$url) { // Example: //$url = "your URL"; } // Message Showing event // $type = ''|'success'|'failure' function Message_Showing(&$msg, $type) { // Example: //if ($type == 'success') $msg = "your success message"; } } ?> <?php ew_Header(FALSE) ?> <?php // Create page object if (!isset($Help)) $Help = new cHelp(); // Page init $Help->Page_Init(); // Page main $Help->Page_Main(); ?> <?php // include_once "header.php" ?> <?php // $Help->ShowMessage(); ?> <!-- Put your custom html here --> <html> <head> <title><?php echo $Language->Phrase("help"); ?></title> <?php global $gsLanguage; ?> <link rel="stylesheet" type="text/css" href="<?php echo EW_PROJECT_STYLESHEET_FILENAME ?>" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="400" align="center"> <tr> <td> <table border="0" cellpadding="0" cellspacing="0" width="420" align="center"> <tr> <td align="left" valign="top" width="4" height="30"><img src="phpimages/sidebox-title-left.gif"></td> <td align="left" valign="middle" background="phpimages/sidebox-title-bg.gif" width="390" height="30"> <font class="phpmaker"> <strong><?php echo $Language->Phrase("help"); ?></strong></font></td> <td align="left" valign="top" width="4" height="30"><img src="phpimages/sidebox-title-right.gif"></td> </tr> </table> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" align="center" > <tr valign="top"> <td width="4" align="left" valign="top" background="phpimages/sidebox-bar-left.gif"><img src="phpimages/sidebox-bar-px.gif"></td> <td bgcolor="#FFFFFF" width="" align="left" valign="top"> <table bgcolor="#F0F1F5" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <table width="412" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td> <?php global $conn; $page = $_GET["page"]; if ($page!="" && isset($page)) { $sSql = "SELECT Topic, Description FROM ".MS_HELP_TABLE." WHERE Display_in_Page = '".$page."' AND Language = '".$gsLanguage."'"; $rs = $conn->Execute($sSql); if ($rs->RecordCount() < 1) { $helptext = $Language->Phrase("HelpNotAvailable"); } else { $helptext = str_replace("\n", "<br>", "<strong><font color='blue'>".$rs->fields("Topic")."</font></strong><br /><br />"); $helptext .= str_replace("\n", "<br>", $rs->fields("Description")); } } else { $helptext = "<br /><br /> <strong>".$Language->ProjectPhrase("BodyTitle")."</strong><br /><br /> Web Developer and Designer: Masino Sinaga"; } ?> <span class="phpmaker"><?php echo $helptext; ?></span></td> </tr> <tr> <td> </td> </tr> <?php if ($page!="" && isset($page)) { ?> <tr> <td align="center"><input type="submit" name="btnAction" id="btnAction" value=" OK " onclick="javascript:window.close();"></td> </tr> <tr> <td> </td> </tr> <?php } ?> </table> </td> </tr> </table> </td> <td width="4" align="left" valign="top" background="phpimages/sidebox-bar-right.gif"><img src="phpimages/sidebox-bar-px.gif"> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="420" align="center"> <tr> <td width="2" height="29" align="left" valign="top"><img src="phpimages/storybox-bottom-left.gif"></td> <td width="394" height="29" background="phpimages/storybox-bottom-bg.gif"> </td> <td width="8" height="29" align="left" valign="top"><img src="phpimages/storybox-bottom-right.gif"></td> </tr> </table> <br><br> </body> </html> <?php // include_once "footer.php" ?> <?php $Help->Page_Terminate(); ?>
[/hidepost]
Keith Howard says
this is a GREAT addition. It looks like steps 8 & 9 are identical, though.
Masino Sinaga says
Thanks for reminding. Please re-apply step 9, as I have just changed it for the update-script.php file.
Keith Howard says
I am getting the following errors:
Notice: Use of undefined constant MS_USER_TABLE_NAME – assumed ‘MS_USER_TABLE_NAME’ in C:\xampp\htdocs\weekendsupport.org\help.php on line 126
Notice: Use of undefined constant MS_USER_TABLE_NAME – assumed ‘MS_USER_TABLE_NAME’ in C:\xampp\htdocs\weekendsupport.org\help.php on line 126
Fatal error: Class ‘cpengguna’ not found in C:\xampp\htdocs\weekendsupport.org\help.php on line 126
Masino Sinaga says
1. Please implement the customization in this article first before doing the customization above, in order to add MS_USER_TABLE_NAME constant into your configuration (ewcfg9.php) file.
2. Please replace the following code in help.php file:
become:
Keith Howard says
Thanks much. I looked for a prerequisite script but didn’t see it. Sorry.
Also, it appears that the MS_USER_TABLE_NAME does not take into account any “Prefix/Infix/Suffix” characters in the output filename. All of my file names use the infix “_” character.
Would I use the following line?
Masino Sinaga says
Infix? Did you mean Suffix “_” instead of Infix “_”? If so, it seems your code is fine, since your user table name will include “_” in the end of its name.
Keith Howard says
No. the infix will create xxx_view.php, xxx_list.php, etc. the suffix will create xxxlist_.php. I’m using infix.
Andrew Pietrzyk says
Warning: include_once(adodb5/adodb.inc.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/snelling/help.php on line 6
Warning: include_once() [function.include]: Failed opening ‘adodb5/adodb.inc.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/snelling/help.php on line 6
Fatal error: Cannot redeclare class chelp in /var/www/snelling/helpinfo.php on line 794
Andrew Pietrzyk says
** Update – Have only this error remaining:
Fatal error: Cannot redeclare class chelp in /var/www/snelling/helpinfo.php on line 794
Using MySQL.
Andrew Pietrzyk says
Implemented the clear user session script article then re-ran through this one – still erroring on the helpinfo page:
Fatal error: Cannot redeclare class chelp in /var/www/snelling/helpinfo.php on line 794
Any ideas?
Andrew Pietrzyk says
And now:
Fatal error: Class ‘mysqlt_driver_ADOConnection’ not found in /var/www/snelling/phpfn9.php on line 3299
I give up.
Masino Sinaga says
What is the code in line around 794 of helpinfo.php file?
Andrew Pietrzyk says
Got past that error Masino… But I continue to get empty message boxes on the js popup. Just an ok button. I get the same thing with logout. I’m being careful to keep my language .xml files separate on each project but this is a recurring theme…
Andrew Pietrzyk says
And now that issue seems to have gone away.. LOL… sorry, buddy. Good to go, now!
Masino Sinaga says
Glad to hear good news from you. π
Masino Sinaga says
Make sure you have entered some records to the help and help_categories tables.
keithh0427 says
I have a strange issue with the Help feature.
I keep getting a “Loading…” message below the menu and above the table header along with the animated GIF.
I have records in the Help table and the Help_Categories table.
I have even echoed the $sSql and got this: SELECT Topic, Description FROM help WHERE Display_in_Page = ‘weekendsedit.php’ AND Language = ‘en’
It’s valid and returns a record associated with the page.
But the loading message is still there and never goes away.
I was using the infix character, but removed that and am still getting the icon and loading message.
Masino Sinaga says
Make sure there are no characters such as “, ‘, [Enter key] in the help content. If you want to add some blank lines between paragraphs, then replace it with <br /> tag.
keithh0427 says
So, no formatting with a DHTML editor at all?
Masino Sinaga says
You can actually replace such forbidden character before inserting or updating the help record.
Waheed Rahuman says
How to add icons to Delete , Edit , Print , View in the List View ?
Thank you
Masino Sinaga says
Simply enable the Graphical extension from Tools -> Extensions of PHPMaker.