addProject(array( * id, // A unique identifier for this project. * parent, // This project's parent project, if any. * title, // The long title for this project. * image, // The image for this project. * link, // An outbound link for this project. * copy // Long text copy for this prject. * )); * * OUTPUT * Big methods are buildNav(), and display(). The first builds a * semantically correct ul li based navigation. Style this as you like. * display() just displays a related piece of information, related to the * current value of the $_GET variable. */ class Book{ // Initilize master arrays and default values. function Book( $homePage='index.php', $seperator='q', $imgDir='images/' ) { $this->book = array( 'id' => array(), 'parent' => array(), 'title' => array(), 'image' => array(), 'link' => array(), 'copy' => array() ); $this->setHomePage($homePage); $this->setSeperator($seperator); $this->setImgDir($imgDir); } // Set default / home page. function setHomePage( $homePage ) { $this->homePage = $homePage; } // Get default / home page. function getHomePage() { return $this->homePage; } // Set page seperator. function setSeperator( $seperator ) { $this->seperator = $seperator; } // Get page seperator. function getSeperator() { return $this->seperator; } // Set image directory. function setImgDir( $imgDir ) { $this->imgDir = $imgDir; } // Get image directory. function getImgDir() { return $this->imgDir; } // Add an item to the portfolio. function addProject( $addItem ) { // Make sure it's an array. if (is_array($addItem)) { // Make sure all parts were passed. if (count($addItem) == count($this->book)) { array_push($this->book[id], $addItem[0]); array_push($this->book[parent], $addItem[1]); array_push($this->book[title], $addItem[2]); array_push($this->book[image], $addItem[3]); array_push($this->book[link], $addItem[4]); array_push($this->book[copy], $addItem[5]); } else die('You didn\'t pass enough arguments!'); } else die('You didn\'t pass an array!'); } // Return an array to build navigation with. function buildNavArray() { // Combine ids with their parents. $preNav = array_combine($this->book[id], $this->book[parent]); // Build the top level nav. foreach($preNav as $key => $val) if (!$val) // If it has no parent, it is a parent! $navigation[$key] = array(); // Make it an array to hold its children. // Loop through again and add the children. foreach($preNav as $key => $val) if ($val) // If it has a parent, it is a child! array_push($navigation[$val], $key); // Add the child to its parent array. return $navigation; } // Build semantically correct navigation with ul. function buildNav( $navArray, $id='nav' ) { // Start our nav menu. $nav = '