|
Previous: Public Pages
Next: Making Hyperlinks
Modifying A Default PageIf a database has an ITEMS table, a CUSTOMERS table and an ORDERS table we can say in Andromeda lingo that there is an "items page" and "customers page" and an "orders page." These are all private pages, you must be logged in to see them. There is no actual code file associated with them, Andromeda generates them on the fly. If you want to modify one of these default pages, there are many things you can do, from simply adding links to replacing sections outright. Begin With a Class FileBegin by making a class file. This is a PHP file in the application directory. The filename is the same as the table (plus the .php extension of course) , and the class name is the same as the table. The class always extends "x_table2". Here is a very basic example: <?php
# This is file example.php
class example extends x_table2 {
#
# method code
# will go in here
#
}
?>
Overriding the Data DictionaryYou can override things like descriptions and display sizes of columns by coding up a method 'custom_construct'. Normally we do not modify much more than a description or a display size, the following example shows both: <?php
# This is file example.php
class items extends x_table2 {
function custom_construct() {
// Individual column data dictionary information
// is in the array $this->table['flat']
$this->table['flat']['sku']['description']="SKU (Internal)";
// We can shrink the input by changing this value
$this->table['flat']['sku']['dispsize']=13;
}
}
?>
Adding Links At TopWhen a user is editing a particular row, sometimes there are additional links you want to offer to them. In the Node Manager, for example, when you are looking at a particular application you can see a link "Build This Application." These links are created by creating a method called aLinks_extra(), which accepts one parameter and must always return an array. The array contains links, which will be displayed. The parameter tells the program what mode we are in, we almost always are only interested in "upd" mode, which is the mode where the user is looking at a particular row in the table. When we make the link we can make use of the object's $row array, which contains the current row the user is looking at. Here is an example from the node manager, somewhat simplified for clarity: <?php
class applications extends x_table2 {
function aLinks_Extra($mode) {
// We usually only put links in update mode
if($mode<>'upd') return array();
$app = trim($this->row['application']);
$href="&gp_page=a_builder&application=$app";
$a = hLink('','Build This Application',$href);
return array($a);
}
}
?>
Completely Replacing Main ContentIf you create a "main" method in a Page class, you will completely override all normal behavior. Whatever is in your main class will rule the day.
Previous: Public Pages
Next: Making Hyperlinks
|
