In this page you can find some useful code snippets to help you thru some common operations with P4A.
One of our beloved users wrote some p4a tips in spanish, check them out!
If you are just getting started with P4A, here are some suggestions to help you get up and running faster:
through the docs.
errors).
If you receive this error probably you’re using aliases in your apache configuration, P4A can work with aliases but cannot autodetect paths, thus if you are simply testing P4A please install it under your document_root without aliases.
If you want to do advanced tests, please open the “index.php” of your application and define the following constants at the beginning of the file
define('P4A_ROOT_PATH', '/fabrizio/p4a'); //the path to the framework root define('P4A_THEME_DIR', '/home/fabrizio/public_html/themes/default'); //the absolute dir of the selected theme define('P4A_ICONS_DIR', '/home/fabrizio/public_html/icons/default'); //the absolute dir of the selected icons themes
On startup, all of the application’s files in objects/masks are read. If you make a copy of a file as a backup, or copy to make a new class and do not change the name of the class, you will get a class redeclare error.
$values = array(); $values[] = array("id" => "id1", "desc" => "desc 1"); $values[] = array("id" => "id2", "desc" => "desc 2"); $values[] = array("id" => "id3", "desc" => "desc 3"); $array_source =& $this->build("p4a_array_source", "array_source"); $array_source->load($values); $array_source->setPk("id"); $field->setType("radio"); // or "select" $field->setSource($array_source); $field->setSourceDescriptionField("id"); // optional, should be detected automatically $field->setSourceValueField("desc"); // optional, should be detected automatically
P4A has “libraries” concept, you have 3 levels of “libraries” in P4A:
p4a_installation_dir/p4a/librariesp4a_installation_dir/librariesproject_dir/libraries
You should not touch system libraries, extract your package and copy files in the chosen libraries directory. After that you could simply do a require ‘filename.php’;, all libraries dir will automatically loaded in your include path.
$p4a =& p4a::singleton(); $p4a->masks->the_mask_you_want->the_object_you_want
the_mask_you_want needs to be already instanced before you access it, otherwise you’ll get a PHP error.
php_value magic_quotes_gpc 0 php_value mbstring.func_overload 1 php_value mbstring.internal_encoding UTF-8 php_value session.use_trans_sid 0