How to asssemble a hyperlink or form
|We assume you know the HTML basics or use a WYSIWYG editor.
The easy part is the script to target: index.php. Within the same application you can use local urls. You may reference other phpPeanuts applications through ../applicationfolder/index.php. The application folder can be obtained from the getDir method on each request handler (page, part of a page, widget, or action). (This method will already includes a trailing slash).
The hard part is the request parameters. What the user interface framework does depends on the values of the request parameters. The following parameters are used:
||specifies type of request handler to use
||most request handlers, but may be omitted in some cases|
||domain/business model class of the primary object(s) the requesthandler works with
||all generic request handlers except IndexPage|
||identifier of the domain/business object the requesthandler works with. If an id is required, values 0, empty String or no id parameter means a new object. If not required an index page may show all objects of the specified type.
||ObjectEditDetailsPage, ObjectPropertyPage, ObjectReportPage|
||multi value property whose values will be shown. Special value 'pntList' leads to ObjectIndexPage.
||pntType, id and pntProperty to return to after deleting a domain/business object or when the Context button is pressed.
||ObjectDeleteAction, Pages that show the Context Button.|
||informative text supplied by the sender of the request
||Most page classes|
For more information on how these parameters are used to decide which page or action class is instantiated to handle the request, read the design documentation on request dispatch.
A special case is the use of funky urls. Funky urls are used to make websites more search engine friendly. This website itself is powered by phpPeanuts and uses funky urls. To use funky urls the url rewriting feature of your webserver must be enabled (if it has one) and you need to instruct it to rewrite urls if an alias of your choice occurs in the url, so that the same index.php script is called. Then from index.php you call with the alias as the argument to get the request parameters.
Funky urls are always absolute. All their components are separated by slashes. They start with the base url, that can be retrieved from each request handler from the getBaseUrl method. Then the application folder, the alias, the value of the pntType parameter, and the value of the id parameter. Then of each of the other parameters the name and the value, also separated by a slash. Finally the url ends with the page title extended with .html.
Funky urls can be mixed with normal urls because getFunkyRequestData also gets the normal parameters. You can even combine normal parameters with funky ones in the same url.