Page 2 of 2

Re: Uber-Flexible Help System

Posted: Wed Jan 04, 2023 2:54 am
by philmills

forgot to say, actually the $Q var isn't needed at all

just use backslashes to escape the double quotes :

Code: Select all


Re: Uber-Flexible Help System

Posted: Sat Jan 28, 2023 10:21 pm
by andyrav

Does any one have working code for version 2023? I tried it, nothing showing on the screen and no error in the browser, was the simplified method i tried and didnt work.


Re: Uber-Flexible Help System

Posted: Wed Feb 15, 2023 7:56 pm
by philmills

I've upgraded now, and the simplified method is still working for me.
Please check all steps thoroughly

Re: Uber-Flexible Help System

Posted: Sun Feb 19, 2023 12:55 am
by andyrav

What is the best was to get a dropdown of the pages to make it easyer to create a help topic

Re: Uber-Flexible Help System

Posted: Fri Mar 17, 2023 5:38 pm
by philmills

I solved that a bit differently, so that no drop down of the table names is needed at all.
My tablename field is actually VARCHAR 255 text
The help window checks the helpinfo table to see if an entry exists for the page that I am on, if so it displays a pen icon to edit it, or if no entry exists, it shows a plus icon to add one.
This means that your help records are connected to the page you're on, rather than the table itself.
This means your help becomes context help rather than table help, which I think is far more useful.

To do that I added the following to Global Code:

Code: Select all

function helpBox(){
	$space=" ";
	$phppage = CurrentPageName(); //PHP Pagename.php
	$breadcrumb = CurrentPageHeading(); //MenuDisplayname of PHP page
	if ($breadcrumb == "") {$breadcrumb = "Help Function";} //on Homepage breadcrumb is empty, so other text is needed
	$Hid = ExecuteScalar("SELECT Helpinfoid FROM Helpinfo WHERE Tablename = '" . $phppage . "'", "DB");
	$helpURL = "HelpinfoEdit";
	$editicon = "fas fa-pen";
	$editTitle = Language()->phrase('Help_6');
	if (empty($Hid)){
		$helpURL = "HelpinfoAdd";
		$editicon = "fas fa-plus";
		$editTitle = Language()->phrase("Add");
	$HContainer = ExecuteScalar("SELECT Instruction FROM Helpinfo WHERE Tablename = '" . $phppage . "'", "DB");
	$HGeneral = ExecuteScalar("SELECT Instruction FROM Helpinfo WHERE Tablename = 'General'", "DB");
	$HTimestamp = ExecuteScalar("SELECT LastUpdated FROM Helpinfo WHERE Tablename = '" . $phppage . "'", "DB");
	$helpbox = "<div id='helpdiv' style='LEFT:70%; TOP:10%; display:none'>";

	//edit buitton for admins
	if (CurrentUserLevel() =='-1') {
	$helpbox .= "<i class='ms-2 mb-1 ".$editicon."' Title='".$editTitle." ".$phppage."' style='float: left; margin: 10px;' type='button' onclick=\"location.href='".AppRootURL().$helpURL."/".$Hid."';\"></i>";
	$helpbox .= "<button class='ms-2 mb-1 btn-close' aria-label='Close' style='float: right; margin: 10px;' type='button' onclick=\"document.getElementById('helpdiv').style.display='none'\"></button>";
	$helpbox .= "<div id='helpdivheader'><h2>".Language()->phrase('Help_1')."</h2><div id='noticetxt'>(".Language()->phrase('Help_2').")<br /></div></div>";
	$helpbox .= "<div id='helpdivbody'>";

	//accordion for gen help
	$helpbox .= "<button class='Haccordion'>".Language()->phrase('Help_5')."</button>";
	$helpbox .= "<div class='Hpanel'>".$HGeneral."</div>";
	if ($HContainer == "") { //no helptext for this page -->
		$helpbox .= "<button class='Haccordion text-danger'>".Language()->phrase('Help_3')." ".$breadcrumb."</button>";
		$helpbox .= "<div class='Hpanel'></div>";
	} else {
		$helpbox .= "<div style='float: right; font-size: x-small; background-color: white; padding: 4px; margin: 14px;' class='muted font-italic'>".Language()->phrase('General_Updated').": ".date("d/m/Y H:i", strtotime($HTimestamp))."</div>";
		$helpbox .= "<h3 class='text-primary' style='margin-top: 10px;'>".$breadcrumb."</h3><div class='helpbody'>";
		$helpbox .= $HContainer;
		$helpbox .= "</div>";
	// end accordion for gen help
	$helpbox .= "</div>"; //end helpdivbody
	$helpbox .= "<div id='helpdivfooter'>";
	$helpbox .= "<button class='btn btn-primary ew-btn' name='helpdivbtn' id='helpdivbtn' style='align-items:center; text-align:center;' type='button' onclick=\"document.getElementById('helpdiv').style.display='none'\">".Language()->phrase('Help_4')."</button></div></div>";
	$helpbox .= "</div>";
	return $helpbox;	

Then in Page_Foot i just added this where I wanted it to appear

Code: Select all

<?php echo helpBox(); ?>

I also have this in Page_Foot which is referred in the global function:

Code: Select all

/*  Accordion js,  source w3schools  */ 

var acc = document.getElementsByClassName("Haccordion");
var i;

for (i = 0; i < acc.length; i++) {
    acc[i].addEventListener("click", function() {
    /* Toggle between adding and removing the "active" class,
    to highlight the button that controls the panel */

    /* Toggle between hiding and showing the active panel */
    var Hpanel = this.nextElementSibling;
    if ( === "block") { = "none";
    } else { = "block";

Obviously you'll need to edit this code a lot for your needs, but hopefully it gives you the framework you need