7.0

Table Of Contents
//Retrieve the publication types and templates for the logged on user
$storeFront = New Storefront();
$treeData = $storeFront->getTree();
Once the publication type and document information is collected in a PHP array we need to iterate through the
array values. For this we use a PHP foreach loop. Within this function a custom PHP function
(renderPublicationType) is called to generate the actual HTML.
This function generates the <li> elements required by the Treeview plugin. When a publication type contains
one or multiple documents a sub list is created, again using <ul> and <li> elements. For each document a
link to the preview_init_form is inserted supplying the internal ID of the document. The functions of the
preview_init_form file determine the workflow of that document (e.g. show the User Input fields page or
Database Upload page).
foreach ($treeDataArray as $publicationTypes)
{
renderPublicationType($publicationTypes);
}
function renderPublicationType($publicationType)
{
echo "<li><span class='folder'>" . $publicationType['name'] . "</span><ul>";
if (isset($publicationType['publicationTypes'])) {
foreach ($publicationType['publicationTypes'] as $subPublicationType) {
renderPublicationType($subPublicationType);
}
}
if (isset($publicationType['documents'])) {
foreach ($publicationType['documents'] as $document) {
echo "<li><span class='file'>";
echo "<a href='site.php?formid=preview_init_form&id=" . $document['id'] . "'>";
echo $document['name'];
echo "</a>";
echo "</span></li>";
}
} else {
if (!isset($publicationType['publicationTypes'])) {
echo "<li><a href='#'>-</a></li>";
}
}
echo "</ul></li>";
}
Virtual Subfolders
In the current version of PSM Web a publication type can not contain subfolders. You can however simulate
nested publication types. The getTree() function can create virtual sub publication types or sub folders based
on a delimiter character that appears in a document name.
When you call the function as follows getTree('', '_');, it will split the template names using the underscore
character (if it exists in the name). The parts are used for the virtual folder name, the last part is used as the
document name.
Customizing the store front - Creating a hierarchical tree
Objectif Lune Inc. © 2010 55