Dynamic content sensitive Help Content or User Guide
I always used to design a user document or help content after I design a given system, but in all cases users have to first go back and open the user guide then try to locate which section has the help they need then come back. I then noticed some systems mostly desktop applications where for example when a user is in the list,add or edit mode of a customer entity, the help button shows him help about the customer module and once he switches to purchases it will be showing help content for purchases etc. So after try and error I found a quick way around it. where users can have content sensitive help as well as update it themselves when need arises.
LOGIC: this is mainly possible due to phpmaker 2017 modal dialog feature which helps me call the view page of the table containing the help content, while passing it the id that links to a given entity, the hlep content is saved in a TEXT field and I use the CKeditor thus allowing the user to use html and css to design the help content in a much nicer way.
------------------------------------------STEP ONE:saving and designing help content.------------------------------------------------------------------------
create a table as follows
CREATE TABLE IF NOT EXISTS help_document (
url_name varchar(100) PRIMARY KEY,
url_label varchar(100) ,
help_content TEXT
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
LOGIC:PHPmaker has unique identifiers for all pages of tables, views and custom pages, this is what i use to identify a given help content
Table explanation:
url_name -> this keeps the unique identifier of a phpmaker page object, eg for tables and views bank_add, customer_edit, purchase_list, eg for custom pages dashboard_main_php.
url_label -> this can be the title of the help content, eg Add new Bank, Edit Cusomer Details, Purchase List, Main Dashboard.
help_content -> this controll should use CKEditor or DHtmlEditor, this contains html designed help content which gives specific help pertaining the given action eg if url_name = bank_add and url_label = Add new Bank then help_content can maybe draw an html table with all column of the bank table and equivalent explanation of what each of them means as well as how it links to another entity in your system.
NOTE: you must enable Modal Dialog on the view page of help content table since we shall be calling the modal view page
------------------------------------------STEP ONE:saving and designing help content.------------------------------------------------------------------------
------------------------------------------STEP TWO:draw link to help content on every page.------------------------------------------------------------------------
LOGIC: I use Global StartUp Scripts to add code to draw a button next to the breadcrumb(you can put it anywhere you like), which when clicked it passes the page id as the url_name to the modal View page of Help content.
CAUTION: Since the help content is in a table we might need to check if a user has view permissions for help content before drawing the link(I have left this out on purpose to make this as short as possible).
//ADD the following php and javascript code in Global startup scripts:
// Write your global startup script here
// document.write("page loaded");
<?php
//get the unique identifier for current page Object
//THis should be what was defined as the Id for help content in url_name column
$url_name = CurrentPage()->PageObjName;
?>
<?php
//convert the variable to javascript to use when drawing help link
echo 'var the_id = "'.$url_name.'";';
?>
//check if help link already exists so as not to draw it twice (this occurs if you cal modal dialog add or edit while on list pages)
if ($('#id_help_link').length)
{
//it exists
}
else
{
//it doesn't exist
//Determine the id of the last breadcrumb list element so as to draw it after that
var breadcrumb_id = '#'+'ewBreadcrumb1';
//decide where to add it
if ($('#ewBreadcrumb4').length)
{
/* it exists */
breadcrumb_id = '#'+'ewBreadcrumb4';
}
else if ($('#ewBreadcrumb3').length)
{
/* it exists */
breadcrumb_id = '#'+'ewBreadcrumb3';
}
else if ($('#ewBreadcrumb2').length)
{
/* it exists */
breadcrumb_id = '#'+'ewBreadcrumb2';
}
else if ($('#ewBreadcrumb1').length)
{
/* it exists */
breadcrumb_id = '#'+'ewBreadcrumb1';
}
//ADD HELP LINK ON BREADCRUMB
var help_link = "<a id='id_help_link' title='View Help' class='btn btn-success ewAddEdit ewAdd btn-sm' href='javascript:void(0);' onclick='ew_ModalDialogShow({lnk:this,url:\"help_documentview.php?url_name="+the_id+"\"});'><span class='glyphicon glyphicon-question-sign ewIcon fa-spin' ></span></a></li>";
//$('<li><a href="<URL>">This</a></li>').insertAfter("#ewBreadcrumb1");
$('<li>'+help_link+'</li>').insertAfter(breadcrumb_id);
}
------------------------------------------STEP TWO:draw link to help content on every page.------------------------------------------------------------------------
--------------------CLOSING NOTES and useful tips-------------------------
-To obtain the url_namevalues faster, fist do step two, coz it will draw ll help links with expected url_name primary key values which you can see if you inspect the link and them copy and paste it to create the help content
-the modal view page wont show if there is no help content for specific page.
-If you already have your help content in a help document like Microsoft word, easy fix is. save the document as HTMl using save as option. This will convert all contents to html tags, then you can just copy and paste them in the DHtml editor and create help content faster.
-I used breadcrumbs sine I show breadcrumbs on all my pages, but if you hide breadcrumbs on some pages, you ca then draw it somewhere else.
-You can decide to also show the help content list page in the menu which advanced search enabled to help users be able to search for the help content manually if need be
-If you issue Edit permissions on help_content table to specific users users can also adjust the help content of given items if they feel its lacking
--------------------CLOSING NOTES and usefull tips-------------------------
Tell me what you guys think, questions and suggestions