<?php
defined('WM3_cEXEC') or die('Denied');
// List example
// This example create a simple list from $data array
$pageID = $w3->getVariable('pageID'); // Take pageID
variable from get or post
$data = array(
array('1','Good', 'Green', '100'),
array('2','Good', 'Red', '80' ),
array('3','Bad', 'Yellow','60' ),
array('4','Very good', 'Blue', '55' ),
array('5','Normal', 'Orange','90' ),
array('6','Good', 'Blue', '90' ),
array('7','Very bad', 'Violet','65' ),
array('8','Very very good','Violet','120'),
array('9','Very very bad', 'Red', '12'),
);
// Create a wm3GUIList object
// parameters are: list data (must be an array of objects
or an array of arrays), list title
$list = new wm3GUIList($w3,$data,"List title");
// Set labels for list caption
// parameter: an array of strings
$list->setCaptionLabels(array('#ID','Quality','Color','Price'));
// Set widths for list caption (and list columns)
// parameter: an array of integer used as percentage (the
sum must be 100)
$list->setCaptionWidths(array(5,45,30,20));
// Create a page navigator for the list (each page have 6
items max)
$list->setTotalItems(count($data)); // The total items
$list->setPagesNavigatorLink('index.php?section='.WM3_cSECTION_PAGES.'&pageID='.$pageID);
// Link to be render for list page navigator
$list->setUseAutoPage(true); // Enable the auto page mode
$list->setRenderPagesNavigator(true); // Enable list page
navigator
$list->setMaxPageItems(6); // Max 6 items per page
$list->setPage($w3->getVariable('pg')); // Variable
used for list pagination
// Highlight an item (the second item)
$list->setCurrentID(1);
// You can also set a content for list bottom
$list->setBottomContent("<hr>Bottom content");
// Render list
echo $list->render();
?>
|