Location: PHPKode > projects > lowbatCMS > lowbatcms/booktest.php
<?php
/*
 * Created on 29.04.2006
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

	require_once ('siteconfig.inc.php');

	// Create a new book object for this page
	$book = new Book();

	// Create a title object for this book and store this title object in the book
	$title = new TextField('Title', 'A book title here');
	$book->setField('Title', $title);
	// This way assumes that you remember which type/class this field has
	
	/* Another way to do this could be (where you don't necessary have to know the field-type for'):
	 $book->getField('Title')->setValue('Another book title here');
	BUT: Why the hell does this NOT work... (parse error)
	... while THIS works: 
	*/ 
	$title2 =& $book->getField('Title'); // get a field object
	$title2->setValue('Noch Another book title here'); // set its value
	$book->getField('Title')->setValue('NUN Another book title here');
	//$book->setField('Title', $title2); // store this field into the book
	
	/* BTW: 
	 $book->getField('Title')->setValue('Another book title here');
	 would only give a field object and set its value, but no actually save this value ito the book
	 so we should the do:
	 $book->setField('Title', $book->getField('Title')->setValue('Eins mehr: Another book title here'));
	*/

	// Same question with reading:
	$title = $book->getField('Title');
	echo '<BR /><BR /><BR />'.$title->getValue().'<br />';
 	// ... works, but not: (parse error)
	// echo $book->getField('Title')->getValue();

 	echo '<pre>';
	print_r($book);


	$book->setField('Title', 'fkjsdhfksdjf'); // store this field into the book



?>
Return current item: lowbatCMS