In this demonstration the PanelBar control is used in a sample page and configured with PHP to create the menu shown.
Step 1 - Create an instance of PanelBar on your page.
Import the PanelBar library and create a new PanelBar object.
<?php
include 'Coalesys.PanelBar.php';
$objPB = new Coalesys\PanelBar\PanelBar();
Step 2 - Set the UserAgent property for automatic browser detection.
Setting the UserAgent property to the User-Agent string allows PanelBar to auto-detect the browser and to generate the code that is specific to it.
$objPB->setUserAgent($_SERVER["HTTP_USER_AGENT"]);
Step 3 - Add Group and Item objects to the menu.
The Groups and Items collections are used to manage the Group and Item objects. Here we add 2 Group with and their items.
$objGroup = $objPB->getGroups()->Add();
$objGroup->setCaption("Home");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("News");
$objItem->setURL("news.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("About Us");
$objItem->setURL("about.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Contact");
$objItem->setURL("contact.php");
$objGroup = $objPB->getGroups()->Add();
$objGroup->setCaption("Products");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Super Widget");
$objItem->setURL("SuperWidget.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Super Widget Pro");
$objItem->setURL("superwidgetpro.php");
Step 5 - Generate the PanelBar output on the Page.
The main PanelBar object has methods to generate blocks of client code to the page in sections. Event handlers are also added to the BODY tag.
<html>
<head>
<title>Quick Start</title>
<style type="text/css">
<?php echo $objPB->GenerateStyleSheet() ?>
</style>
<script type="text/javascript">
<?php echo $objPB->GenerateJavaScript(0) ?>
</script>
</head>
<body
onload="<?php echo $objPB->GenerateOnLoadEvent() ?>"
onresize="<?php echo $objPB->GenerateOnResizeEvent() ?>">
<?php echo $objPB->GeneratePanelBar(0) ?>
</body>
</html>
Step 6 - The Completed Page.
Below is the complete PHP page.
<?php
include 'Coalesys.PanelBar.php';
$objPB = new Coalesys\PanelBar\PanelBar();
$objPB->setUserAgent($_SERVER["HTTP_USER_AGENT"]);
$objGroup = $objPB->getGroups()->Add();
$objGroup->setCaption("Home");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("News");
$objItem->setURL("news.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("About Us");
$objItem->setURL("about.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Contact");
$objItem->setURL("contact.php");
$objGroup = $objPB->getGroups()->Add();
$objGroup->setCaption("Products");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Super Widget");
$objItem->setURL("SuperWidget.php");
$objItem = $objGroup->getItems()->Add();
$objItem->setCaption("Super Widget Pro");
$objItem->setURL("superwidgetpro.php");
?>
<html>
<head>
<title>Quick Start</title>
<style type="text/css">
<?php echo $objPB->GenerateStyleSheet() ?>
</style>
<script type="text/javascript">
<?php echo $objPB->GenerateJavaScript(0) ?>
</script>
</head>
<body
onload="<?php echo $objPB->GenerateOnLoadEvent() ?>"
onresize="<?php echo $objPB->GenerateOnResizeEvent() ?>">
<?php echo $objPB->GeneratePanelBar(0) ?>
</body>
</html>