faqts : Computers : Software : FreeTrade : Customization

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 2 people (100%) answered Yes

Entry

How can I alter the display in the admin_departments screen to only show the contents of the current department and its ancestors?

Sep 6th, 2000 06:23
Kathleen Ballard,


My client requested a version of the admin_departments gui screen that 
would only display the contents of the currently selected department 
and its ancestors.  The client also requested that closing a department 
would shift the *focus* to that department's parent.

Below are the commented sections of the admin_departments screen that I 
changed to accomplish the above requirements.

in the directoryTree function:

/*
** Truncated department tree note:
** These lines were commented out to allow the building of an
** array of all the ancestors of the current directory.
** If the current directory is closed, only its ancestors should
** be expanded.
*/
  //unset($expandDepartmentsArray[$deptID]); //temporarily
  //$unexpandImplode = onvalKeyImplode
("|",$expandDepartmentsArray) . " ";
  //$expandDepartmentsArray[$deptID] = TRUE;
			
/*
** Truncated department tree note:
** We need to create $expandAncestors array.  This is an array of 
** all the ancestors of the current department.  This array will 
** be used to create the variable expandDepartments that is passed
** with the "close"  image url for the current department.
*/
  $tempDept = $departmentParents[$deptID];
  while ($tempDept)
  {
    $expandAncestors[$tempDept] = TRUE;
    $tempDept = $departmentParents[$tempDept];
  }
  $expandAncestors[0] = TRUE;
  $unexpandImplode = onvalKeyImplode("|", $expandAncestors) . " ";

/*
** Truncated department tree note:
** If current directory is closed, we want the parent of the current
** directory to be the value passed as department in the "close"
** image url.
*/
print("&department=$departmentParents[$deptID]");

/*
** Truncated department tree note:
** Note the addition of the $departmentParents array added to the 
** argument list of directoryTree.  This is required to build the
** $expandAncestors array for each "close" image url
*/
directoryTree($ID, $name, $departmentStructure, 
	$expandDepartmentsArray,$departmentParents);

~~~~~~~~~~~~~~~~IN THE MAIN SCRIPT~~~~~~~~~~~~~~~~~~~~~
/*
** Truncated department tree note:
** I can't really figure an easy way to make this link work with the
** truncated list, so I am removing it.
*/
/*	
print("<LI><A HREF=\"" . ScreenURL("admin_departments") . 
	"&department=$departmentParent\">" . 
L_ADMINDEPARTMENTS_GOUPONE . 
	"</A>\n");
*/


/*
** Truncated department tree note:
** Since we want to limit the departments displayed, we need to get the
** ID's of the expanded departments.
*/
if ($expandDepartments)
{
	$visibleDepartments = ereg_replace("\|",",", 
$expandDepartments);
}
else
{
	$visibleDepartments = 0;
}

/*
** Grab the store structure from the database (i.e. all department's 
name,
** ID, and parent). 
*/
$query = "SELECT ID, Name, Parent FROM department ";

/* 
** Truncated directory tree note:
** Again, we are limiting the display to only the children of the 
** current department and the currently expanded departments.
*/
$query .= "WHERE Parent = $department or ID IN ($visibleDepartments) ";
$query .= "ORDER BY DisplayPrecedence, Name";

/*
** Truncated department tree note:
** Note the addition of the $departmentParents array added to the 
** argument list of directoryTree.  This is required to build the
** $expandAncestors array for each "close" image url
*/
directoryTree(0, "Root", $departmentStructure, 
$expandDepartmentsArray,$departmentParents);