PHPMaker 12
PHPMaker 12
PHPMaker 12 Help
Table of Contents
1. PHPMaker 12 ............................................................................................................................ 3
1.1 What's New in PHPMaker 12 .............................................................................................. 3
1.2 System Requirements ....................................................................................................... 14
1.3 Installation and Uninstallation .......................................................................................... 15
1.4 License and Ordering Information .................................................................................... 16
1.5 Technical Support ............................................................................................................. 16
1.6 Disclaimer of Warranty ..................................................................................................... 17
1.7 Third-party Tools ............................................................................................................... 17
1.8 Introduction to PHP and MySQL ....................................................................................... 19
1.9 Quick Start......................................................................................................................... 28
1.10 Project Setup................................................................................................................... 31
1.10.1 Database Setup ........................................................................................................ 31
1.10.2 PHP Settings ............................................................................................................. 38
1.10.3 HTML Settings .......................................................................................................... 48
1.10.4 Security Settings....................................................................................................... 52
1.10.5 Generate Settings .................................................................................................... 63
1.10.6 Table Setup .............................................................................................................. 66
1.10.7 Field Setup ............................................................................................................... 80
1.10.8 Lookup Table .......................................................................................................... 111
1.10.9 Server Events and Client Scripts ............................................................................ 120
1.10.10 Custom Templates ............................................................................................... 163
1.10.11 Using Custom View .............................................................................................. 171
1.10.12 Using Report ........................................................................................................ 176
1.10.13 Custom Files ......................................................................................................... 181
1.10.14 Custom Fields ....................................................................................................... 186
1.10.15 Linked Tables ....................................................................................................... 188
1.10.16 Multi-Language Project ........................................................................................ 193
1.11 Application Root ........................................................................................................... 198
1.12 Project File .................................................................................................................... 201
1.13 Tools .............................................................................................................................. 202
1.14 Customizing Template .................................................................................................. 223
1.14.1 Control File ............................................................................................................. 227
PHPMaker 12 Help
1.14.2 System Functions ................................................................................................... 231
1.14.3 Template Object Properties ................................................................................... 246
1.14.4 Using User Code ..................................................................................................... 268
1.14.5 Template Tags ........................................................................................................ 271
1.15 Tutorials ........................................................................................................................ 273
1.15.1 Connecting Remote MySQL using PHPMaker Connection Script .......................... 274
1.15.2 Master/Detail ......................................................................................................... 276
1.15.3 File Upload to Database ......................................................................................... 286
1.15.4 File Upload to Folder.............................................................................................. 291
1.15.5 Dynamic Selection List ........................................................................................... 296
1.15.6 Field Aggregation ................................................................................................... 299
1.15.7 User Registration System ....................................................................................... 301
1.15.8 Inline Add, Inline Copy, Inline Edit, Grid-Add and Grid-Edit .................................. 307
1.15.9 Advanced Security - User ID Security ..................................................................... 311
1.15.10 Advanced Security - Static User Level Security .................................................... 316
1.15.11 Advanced Security - Dynamic User Level Security ............................................... 323
1.15.12 Custom View ........................................................................................................ 331
1.15.13 Report .................................................................................................................. 337
1.15.14 Integrating with PHP Report Maker Project ........................................................ 343
PHPMaker 12 Help
1. PHPMaker 12
PHPMaker is a powerful automation tool that can generate a full set of PHP quickly from
MySQL, PostgreSQL, Microsoft Access, Microsoft SQL Server and Oracle databases.
Using PHPMaker, you can instantly create web sites that allow users to view, edit, search,
add and delete records on the web. PHPMaker is designed for high flexibility, numerous
options enable you to generate PHP applications that best suits your needs. The generated
codes are clean, straightforward and easy-to-customize. The PHP scripts can be run on
Windows servers (MySQL/PostgreSQL/Access/MSSQL/Oracle) or Linux/Unix servers
(MySQL/PostgreSQL/Oracle). PHPMaker can save you tons of time and is suitable for both
beginners and experienced develpers alike.
Also See:
What's New in PHPMaker 12(See 1.1)
License and ordering(See 1.4)
PHPMaker 12 Help
Custom Fields
Add custom fields to a table or view with SQL expression.
PHPMaker 12 Help
Tabular form
PHPMaker 12 Help
Horizontal form
PHPMaker 12 Help
PHPMaker 12 Help
Improved AutoSuggest
Support Option Template, min-width and max-height settings.
PHPMaker 12 Help
PHPMaker 12 Help
Improved Multi-Page
Options: (To be set up by Client Script)
10
PHPMaker 12 Help
Set multiple properties of multiple fields at one time.
11
PHPMaker 12 Help
12
PHPMaker 12 Help
Language_Load - For customizing the language phrases, fired after the language
file is loaded.
AuditTrail_Inserting - For customizing the data to be logged, fired before inserting
the audit trail log.
Format project file - Add indentation to XML nodes in the project file
Allow login by session variables - For use with User_CustomValidate server event
Session timeout period (minutes) - Specifies the session time-out period if the user
does not refresh or request a page
Session keep alive interval (seconds) - Specifies the interval to send Ajax request to
the server for keeping the session alive
Session time out countdown period (seconds) - Specifies the countdown period
before session ends
Use ADOdb driver for MySQL - Use the full ADOdb driver for MySQL instead of the
lite version (ewmysql.php)
Encrypt file path - Encrypt the file path of uploaded files in URL
13
PHPMaker 12 Help
Reduce image size only (image resize) - Specifies if enlarging image is preferred
(Migrated from previous Image Resize extension)
Always keep aspect ratio (image resize) - Specifies if aspect ratio should be kept
(Migrated from previous Image Resize extension)
Check password strength - Specifies if the strength of inputted password for
password fields should be checked
Minimum password strength - Specifies the minimum acceptable password strength
Generate password - Specifies if a random password generation button should be
added to password field
Password length - The length of the password to be generated
Add plain text version in HTML email - Specifies if text version of email content is
required
Use tabular form for desktop - Use Boostrap table instead of Bootstrap horizontal
form for Add/Edit/Search/Update/Register pages (Desktop mode only)
More
Windows Vista/2008/2012/7/8
PHPMaker requires the following system files. If you do not have latest version of these files,
you may experience ActiveX errors. To update your system, go the Microsoft download
pages listed below.
Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack (vbrun60sp6.exe)
14
PHPMaker 12 Help
If you use Microsoft Access, SQL Server or Oracle, PHPMaker requires the following database
drivers to connect to the database:
Microsoft Data Access Components (MDAC) 2.8 (for Microsoft Access, SQL Server
and Oracle)
Microsoft Jet 4.0 Service Pack 8 (SP8) (for Microsoft Access <= 2003)
2007 Office System Driver: Data Connectivity Components (for Microsoft Access
2007)
Microsoft Access Database Engine 2010 Redistributable (for Microsoft Access 2010)
Microsoft SQL Server 2012 Native Client (X86 Package) (for Microsoft SQL Server
2005/2008/2012)
Oracle Client (for Oracle)
Server
Browser
PHPMaker 12 can co-exist with previous version of PHPMaker. You do NOT need to uninstall
previous version of PHPMaker if you don't want to.
Double-click on the downloaded installer to start the installation process. Follow the prompts
and change the settings whenever necessary.
To uninstall PHPMaker, go to [Control Panel]. Click [Add/Remove Programs] and select
[PHPMaker 12].
15
PHPMaker 12 Help
1. Login as administrator. Open a command prompt (under All Programs ->
Accessories) in administrator mode by right-clicking and choosing Run as
administrator,
2. Type the command: net user administrator /active:yes. You should see:
"The command completed successfully."
3. Log out. You'll now see the Administrator account show up on the login screen.
Log in as the built-in administrator and install again. After successful installation, if you want
to disable the built-in administrator account. Logout and re-login as your regular user
account, and then open an administrator mode command prompt as above. Type the
command: net user administrator /active:no. The administrator account will now
be disabled, and should not show up on the login screen anymore.
16
PHPMaker 12 Help
1. Is the problem reproducible? If so, provide the steps to reproduce it?
2. What version of Windows is your PC running?
3. What version of PHPMaker are you running? (Click [Help] and then [About...] to
check)
4. What database and what version are you using?
5. What OS is the server running? Windows or Linux? What version of PHP is running?
(Note that PHP 4 is not supported.)
6. If any error message was displayed, please include the full text of error message. If
not, describe the problem in detail.
7. Your project file (.pmp file) and your database (.sql file) with enough data for
reproducing the problem.
8. Your license information. Emails without license information will be ignored.
While we are happy to support your usage of our software, please note that technical
support does NOT entail customization of templates, extensions or generated code, writing
server events or client scripts (JavaScripts) or custom template, integrating third-party
code, setting up web server, or any other issues not directly related to the workings of the
software. Request for debugging or modifying code not generated from the original template
will be ignored.
Note
17
PHPMaker 12 Help
This extension is EXPERIMENTAL only. There are some known issues of DOMPDF,
please read the developer website for more information. Known issues includes (but now
limited to):
Warning
jQuery
Website: http://jquery.com/
jQuery is released under MIT License.
JsRender
Website: https://github.com/BorisMoore/jsrender
JsRender is released under MIT License.
Bootstrap
Website: http://getbootstrap.com/
Bootstrap is licensed under Apache License v2.0.
Barcode and QRCode
Website: http://www.phpclasses.org/package/2441-PHP-Generate-barcode-graphs-usingdifferent-standards.html
The class is distributed for free without warranty.
PHP Thumb
Website: https://github.com/masterexploder/PHPThumb
PHP Thumb is distributed under the MIT License.
Supports GIF, JPEG and PNG images only. Requires PHP GD2 extension.
pGenerator and pStrength
Website: https://github.com/M1Sh0u/pGenerator and
https://github.com/M1Sh0u/pStrength/blob/master/pStrength.jquery.js
Both are released under the MIT License.
Horizontal Menu
Replaces the graphical extension for previous versions. Uses Bootstrap Navbar as horizontal
menu.
FCKeditor File Manager (for CKEditor)
FCKeditor is the previous version of CKEditor and has been discontinued after version
2. FCKeditor extension had been dropped by PHPMaker. This extension only applies
the free File Manager from FCKeditor to CKEditor (so the commerical product CKFinder is not
required), based on http://www.mixedwaves.com/2010/02/integrating-fckeditorfilemanager-in-ckeditor/.
FCKeditor Website: http://sourceforge.net/projects/fckeditor/
FCKeditor is distributed under the LGPL Open Source license.
18
PHPMaker 12 Help
TinyMCE
Website: http://tinymce.moxiecode.com
TinyMCE is distributed under the LGPL Open Source license. If IE, requires IE >= 9.
Time Picker
Website: http://jonthornton.github.io/jquery-timepicker/
Timepicker Plugin for jQuery is made available under the open source MIT License.
PHPExcel
Website: http://phpexcel.codeplex.com
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above. Requires PHP version 5.2.0 or higher, PHP extension php_zip enabled (for
Excel2007 format), PHP extension php_xml enabled and PHP extension php_gd2 enabled (if
not compiled in).
PHPWord
Website: http://phpword.codeplex.com
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above. Requires PHP version 5.2.0 or higher, PHP extension php_zip enabled, PHP
extension php_xml enabled and PHP extension php_gd2 enabled (if not compiled in).
Detail Preview
Allow previewing detail records in an expanded row of the main table in List page, and/or in
a popup overlay by Bootstrap Popover.
Scrollable Table
Scrolling table example. Enable X/Y scrolling of the main table in the List page. If IE,
requires IE >= 9.
CAPTCHA
Generates CAPTCHA image. Requires PHP GD extension with GD2.
Also support reCAPTCHA (https://developers.google.com/recaptcha/). reCAPTCHA is
OPTIONAL. If you choose to use reCAPTCHA, note that reCAPTCHA is a Web service,
meaning that the CAPTCHA images are served directly from reCAPTCHA's servers to the end
users, the end users need to be online. To use the service, you must register at the
reCAPTCHA Web site and obtain public and private keys.
What is MySQL?
19
PHPMaker 12 Help
MySQL is a relational database management system, or RDBMS. It has become the world's
most popular open source database because of its consistent fast performance, high
reliability and ease of use. PHP has MySQL extension which makes it really easy to access
data in MySQL.
MySQL Home Page
Manual
Download
upload_tmp_dir - If you want to use file upload, make sure this setting points to an existing
folder on your machine, e.g. upload_tmp_dir="C:\Windows\Temp"
20
PHPMaker 12 Help
If you're using NTFS on Windows, make sure that the user running the web server has
write permissions to this folder (e.g. make it readable and writable by Everyone). See the
section Configuring Permissions below.
Note
php_com_dotnet.dll - If you use MS Access or MS SQL Server (on Windows server), the COM
extension is required. As of PHP 5.3.15 / 5.4.5, the COM extension
requires php_com_dotnet.dll to be enabled inside of php.ini, i.e.
extension=php_com_dotnet.dll
Also make sure you have installed the php_com_dotnet.dll in the extension folder
(extension_dir) specified in php.ini.
Note
The left hand side pane is Connections, the middle pane is Workspace and the right hand
side pane is Actions.
The Connections pane lists application pools and websites. The workspace pane consists of
two tabs at the bottom namely Features View and Content View. The Features View
allows you to work with the settings of the selected item from Connections pane whereas
the Content View displays all the child nodes (content) of the selected item.
21
PHPMaker 12 Help
Application pool is a group of IIS applications that are isolated from other application
pools. Each application pool runs in its own worker process. Any problem with that process
affects the applications residing in it and not the rest of the applications. You can configure
application pools individually.
In order to create a new application pool, select "Application Pools" under Connections pane.
Then click on "Add application pool" from Actions pane. This will open a dialog as shown
below:
Specify a name for the new pool to be created. Select .NET framework version that all the
applications from the pool will use. Also select pipeline mode. There are two pipeline modes
viz. integrated and classic. The integrated mode uses the integrated request processing
model whereas the classic mode uses the older request processing model. Click OK to create
the application pool.
Your new application pool will now be displayed in the Workspace pane. To configure the
application pool click on the "Advanced Settings" option under Actions pane. The following
figure shows many of the configurable properties of an application pool.
22
PHPMaker 12 Help
If you use 64-bit Windows, set Enable 32-Bit Applications to True. (See Running on 64bit Windows Operating System below.)
To create a new web site, select Web Sites node under Connections pane and then click on
"Add Web Site" under Actions pane. This opens a dialog as shown below:
23
PHPMaker 12 Help
Here, you can specify properties of the new web site including its application pool and
physical location.
Creating an IIS application or a Virtual Directory is quick and simple. Just right click on
the web site and choose either "Add Application" or "Add Virtual Directory" to open
respective dialogs (see below).
24
PHPMaker 12 Help
An existing Virtual directory can be marked as an IIS application by right clicking on it and
selecting "Convert to Application".
If you use IE, you may encounter the following error messages when you run PHP pages
with IIS 7:
An error occurred on the server when processing the URL. Please contact the system
administrator.
Go to Internet Options -> Advanced, disable Show friendly HTTP error messages.
25
PHPMaker 12 Help
Configuring Permissions
An important aspect of working with file upload to a folder on the Web server is to correctly
configure permissions.
When a Web application uses a file, the application must have Read permission to the file so
the application can access the data. Additionally, the application must have Write permission
to the folder that contains the file. Write permission is required because the file may be
created at run time.
If you use Linux/Unix, CHMOD your upload folder to "777" by using your FTP software.
To use an Access database in an PHP Web application, you must configure the folder that
contains the Access database to have both Read and Write permissions for the IIS user
account.
The default anonymous IIS user depends on IIS version. In IIS 5, it is
IUSR_<MachineName>. In IIS 6 and IIS 7 it can be NETWORKSERVICE or IUSR. In IIS 7.5
it depends on Application Pool, read Application Pool Identities for detail.
To set permissions in the folder (if you're using NTFS on Windows),
26
PHPMaker 12 Help
1. In Windows Explorer, move to the root folder for the Web site. e.g.
C:\Inetpub\wwwroot\ExampleSite.
2. If the folder does not already exist, create one.
3. Right-click the folder, click Properties, and then click the Security tab.
27
PHPMaker 12 Help
To generate your first PHP project, you can skip the options and use default settings first. In
other words, you skip the intermediate steps and go directly to the [Generate] tab after
connecting to your data source, that is:
[Database] > [Generate]
You can generate the web site quickly by the following steps:
1. Start up PHPMaker. There are two connection methods to connect to your MySQL server DIRECT or URL. As explained in Introduction to PHP and MySQL(See 1.8), it is recommended
that you have a local MySQL server during development. You usually connect to MySQL by
the DIRECT method, the URL method is only used when you want to conenct to a remote
MySQL server which does not allow direct connection. (See Tutorial - Connecting Remote
MySQL using PHPMaker Connection Script(See 1.15.1).)
2. In this example, we use direct connection. Enter connection details for the MySQL Server
.
28
PHPMaker 12 Help
3. Click the [Connect] button to load the database information. Tables and fields
information will be loaded and displayed on the left hand side.
29
PHPMaker 12 Help
To run PHP you need to setup a website or virtual directory (See Introduction to PHP and
MySQL (See 1.8)). If you are not familiar with web server, you can install IIS Express which
can be downloaded from Microsoft website. Then select [IIS Express] and [Browse after
generation] in PHPMaker.
5. Click the [Generate] button, the generation process will begin. After the web site is
generated successfully, a completion message will be displayed. The web site should then be
ready to run. If [Browse after generation] is enabled, PHPMaker will open your browser,
and - voila! - you'll see PHP displaying the data in your first PHP website.
30
PHPMaker 12 Help
After understanding how it works, you can then take advantages of various other options
provided by PHPMaker and setup your project more precisely. See Project Setup(See 1.10)
for full details.
Database(See 1.10.1)
PHP(See 1.10.2)
HTML(See 1.10.3)
Security(See 1.10.4)
Generate(See 1.10.5)
To further control the functionality of the generated scripts, you can setup different options
for each table/field:
You can also setup additional database objects for your project in PHPMaker:
31
PHPMaker 12 Help
(Also see Tutorial - Connecting Remote MySQL using PHPMaker Connection Script(See
1.15.1))
While the direct connection method is quick and easy, some remote MySQL server may not
allow direct connection. PHPMaker provides an alternative simple way to connect remote
servers:
1. Upload the PHP connection script provided by PHPMaker to your site. Note that:
a.
b.
The script is named "phpmaker.php" and can be found under your installed
folder, usually C:\PHPMaker,
Always use the script shipped with your version of PHPMaker.
PHPMaker may not work with script shipped with previous versions.
2. If it is the first time that you use this script, you may want to test the script with
your browser:
32
PHPMaker 12 Help
a.
b.
c.
Click "Get Database List" and then "View Schema", you should be able to
view the schema of your database in XML properly. Now go back to
PHPMaker.
3. Enter the SAME connection information, select URL for connection method, enter the
URL of the script (e.g. http://servername/path/phpmaker.php), you can test the URL
by clicking the [Test] button,
4. Click the [Connect] button to load the database information. PHPMaker will connect
to the database server through the PHP script over HTTP.
33
PHPMaker 12 Help
2. PostgreSQL
Select PostgreSQL as database type.
34
PHPMaker 12 Help
Click the
Notes
1. Database path is relative to application root. Use slashes "/" as path delimiter, no
leading slash. e.g. If the application root of your website is
C:\Inetpub\wwwroot\demo and you enter "data/" in this textbox, the folder for the
database will be C:\Inetpub\wwwroot\demo\data. If you are not sure which folder is
application root, please read Creating Virtual Directories in IIS(See 1.8).
2. PHP COM extension is required on the web server. As of PHP 5.3.15 / 5.4.5, the COM
extension requires php_com_dotnet.dll to be enabled inside of php.ini in order to use
these functions. Previous versions of PHP enabled this extension by default. Read
http://php.net/manual/en/book.com.php.
1. If you use SQL Server 2000/2005/2008/2012 and have installed SQL Server 2012
Native Client on your computer, then Microsoft SQL Server and Microsoft SQL
Server 2005/2008/2012 database type will be available for selection. You can use
this database type for connection to SQL Server 2000, 2005, 2008 or 2012. You can
download SQL Server 2012 Native Client from the Microsoft website. See System
Requirements(See 1.2). The native client must also be installed on the web server.
(ODBC connection is not supported.)
2. PHPMaker connects to the SQL Server by TCP/IP (NOT Windows authentication),
make sure TCP/IP protocols is enabled for your SQL server, you can use SQL Server
Configuration Manager to check and configure.
3. If the SQL Server is a remote server (not on the same machine as PHPMaker), make
sure your SQL Server allows remote connection, you can use SQL Server
Management Studio to check and configure.
35
PHPMaker 12 Help
4. If you have firewall enabled on the server, make sure it allows inbound
traffic on port 1433 for TCP/IP. If the SQL Server uses another port number, make
sure you have set up the firewall rules accordingly.
Select Microsoft SQL Server (or Microsoft SQL Server 2005/2008/2012 if you
use SQL Server 2005/2008/2012 or later) as database type,
Enter the name or IP of the SQL server,
Enter the User ID and Password,
Select the database you want or just enter the name of your database,
Click the
Notes
1. If Microsoft SQL Server 2005/2008/2012, make sure the server name includes
the instance name, e.g. localhost/SQLEXPRESS.
2. The server name or IP should be valid on your production Web server also.
Otherwise you'll need to modify the generated connection string in ewcfg*.php
before you upload it to your production server. For example, if you have a testing
SQL Server installed on the same computer, you can use "(local)" as server name
when you connect to it with PHPMaker. The generated scripts will then try to connect
to a SQL Server on the same computer as the production Web server, if this is not
the case on the server, the connection will fail. It is common that SQL Server is
installed on a different server in production environment.
3. PHP COM extension is required on the web server. As of PHP 5.3.15 / 5.4.5, the COM
extension requires php_com_dotnet.dll to be enabled inside of php.ini in order to use
these functions. Previous versions of PHP enabled this extension by default. Read
http://php.net/manual/en/book.com.php.
5. Oracle
36
PHPMaker 12 Help
If you have installed Oracle client on your computer, this database type will be available
for selection. You can download Oracle client from the Oracle website. Make sure the path of
your Oracle client (e.g. oci.dll) is among the Path variable under Windows Environment
Variables -> System variable.
Note
The service name should be valid on your production Web server also. Otherwise you'll
need to modify the generated connection info in ewcfg*.php before you upload it to your
production server. The service name must be set to the appropriate Net8 name which is
known to the naming method in use. For example, for Local Naming, it is the alias in the
tnsnames.ora file; for Oracle Names, it is the Net8 Service Name.
Note
37
PHPMaker 12 Help
The database pane is dockable. If you prefer to display the database pane on the right hand
side, simply drag it to the right side.
Dynamic Table Loading
By default all tables in the database are loaded. It is convenient but loading and
sychronization could be slow if your database contains a large number of tables or fields. If
this option is enabled, a table will only be loaded when you select it in the database pane. If
you just use a few tables out of a large database, this feature enables you to work much
faster than before. To enable this feature, simply check [Load tables dynamically]
BEFORE pressing the [Connect] button.
38
PHPMaker 12 Help
(For Unix-based server only) If you put the PHP parser binary
somewhere outside of the web tree of files, for example, in
/usr/local/bin, you will have to put a line similar to: #!/usr/local/bin/php
as the first line of any file containing PHP tags. (You will also need to
make the file executable.)
Set locale
39
PHPMaker 12 Help
Default Date
Format
The default date format for the scripts. Possible values are:
yyyy/mm/dd, mm/dd/yyyy, dd/mm/yyyy,
yyyy-mm-dd, mm-dd-yyyy, dd-mm-yyyy,
yyyy.mm.dd, mm.dd.yyyy, dd.mm.yyyy
with or without time (hh:mm:ss). The selected date format also
determines the date separator ("/" or "-" or ".").
No Cache
Multi-Language
40
PHPMaker 12 Help
Template(See 1.14) and Tools(See 1.13)).
Default Language Default language of the project. It must be compatible with Charset
(see HTML Settings(See 1.10.3)). Default is English.
There is always one default language for a project. Only the English
language file (english.xml) is shipped with PHPMaker. If your project is
single language but you use another language, create a language file for
your language (see Customizing Template(See 1.14)), put it in the
"languages" subfolder under the installation folder and then select your
default language using this combobox.
If you enable Multi-Language, you must select one of the selected
languages as the default language.
File Upload
Upload folder - The global folder where the uploaded files resides. If
you do not enter a specific folder for a file upload field in the Edit Tag
panel of the Field Setup(See 1.10.7) page, all the uploaded files will be
put in this folder.
Always specify an upload folder if you allow file upload.
This folder is used as the root folder of temporary folders for file upload
fields during Add/Edit. It is also used as the root folder of the user files
folder of CKEditor.
Important
Notes
41
PHPMaker 12 Help
checking on file size.
File upload also depends on your PHP, web server and database
configuration:
Notes
Audit Trail
42
PHPMaker 12 Help
depend on database type)
DateTime (DateTime)
Script (VarChar)
User (VarChar)
Action (VarChar)
Table (VarChar)
Field (VarChar)
KeyValue (Long VarChar)
OldValue (Long VarChar)
NewValue (Long VarChar)
You can create the database yourselves and select the table in the
combobox, then click the [...] button to select the fields in your table.
Alternatively, if you have not created the table yet, you can click
[Create Table] and let PHPMaker creates the table and setup the
settings for you.
Track login/logout activities - If security feature is enabled,
login/logout activities will also be logged.
Validation
43
PHPMaker 12 Help
"NumericPages" or "NextPrev"
Sort type
44
PHPMaker 12 Help
Multiple column
Multiple delete
Inline delete
Export
45
PHPMaker 12 Help
of the field in Field Setup(See 1.10.7) page.
Export type - Determines which records to
export. The follows are supported:
Notes
46
PHPMaker 12 Help
above) because write permission for the
folder should be already setup properly. If
you do not use file upload to folder, but
you use export to PDF with images, then
make sure you still specify an upload
folder and set up the write permission.
Email Settings
PHPMaker supports many features that can send emails. If you use these features, you'll
need to specify a SMTP server.
From v9, PHPMailer (see Third-party Tools(See 1.7)) is always used as the email
component. Make sure you generate and upload the subfolder named "phpmailer<version>"
to your website.
Note
SMTP server
Recipient (Email address)Email address of the recipient(s) for notification emails when a
record is added/edited/deleted (if enabled, see Table Setup(See
1.10.6)). If there are multiple recipients, separate them by
comma.
47
PHPMaker 12 Help
Protocol used by the SMTP server. Possible values are: SSL or
TLS.
Security
Leave this setting empty if your SMTP server does not use
such protocols.
Note
Title
Charset
Charset setting used in the META tag of the site and for exporting data.
If you use Multi-Language (see PHP Settings(See 1.10.2)), this setting
must be utf-8.
Note
Font
Size
Default font size (pixel). Unit must be in pixel for working with Bootstrap (see
below). Default is 14.
Site icon
Icon of the site. For browsers to show your URL with an icon. Must be an .ico
file.
48
PHPMaker 12 Help
1. If you use Multi-Language (see PHP Settings(See 1.10.2)), use MultiLanguage Property Editor, see Tools(See 1.13) for details.
2. This setting is enabled in registered version only.
Theme
Provides over a dozen of themes for you to setup the look and feel of your project quickly.
You can change the various properties of the selected theme to suit your style. The property
name are self-explanatory.
Themes are intergrated with Bootstrap, you can customize Bootstrap properties directly in
the Theme tab, scroll down to find the Bootstrap variables which start with "@".
To export custom theme settings, click the [Export theme] button to export the theme to an
external xml file. To import custom theme settings from earlier saved xml files, click the
[Import theme] button.
49
PHPMaker 12 Help
There are some settings related to Bootstrap but they are not Bootstrap "@xxx" variables:
Mobile Menu - Inverted
Notes
1. Changing a setting in the user interface does not change the corresponding setting
in the theme definitions, it only changes the setting for the project. The theme
definition files (in XML format) are installed in the subfolder "themes" under the
installation folder. You can easily add your own themes by duplicating one of the
theme definition file (except the theme.xml which is for defining the settings and
data type in a theme), rename it and modify the settings in the file, just make sure
you give your theme an unique theme name.
2. Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and
easier web development, to get started, checkout http://getbootstrap.com.
3. After changing theme properties, make sure you re-generate *.css files.
50
PHPMaker 12 Help
Styles
Edit styles
A separate CSS stylesheet will be generated for each project. Click the
[Edit styles] button to open CSS editor.
Notes
When you edit the CSS styles in the editor, note the follows:
BEGIN_USER_STYLES
END_USER_STYLES
You MUST write your styles between these two comment
lines, styles outside this user styles section will be
discarded.
3. If you want to override the system styles, you can copy the styles
to the User Styles Section, or you can use a separate user
stylesheet.
User StylesheetSpecify an external user stylesheet (will be copied across during
generation)
You can see the effect of new settings immediately in the preview window at the bottom of
the HTML tab.
51
PHPMaker 12 Help
Other than choosing color from the palettes, the color picker can also pick color directly from
screen using the "eyedropper".
Field Description:
Administrator Login (HardCoded)
Login Name
Password
52
PHPMaker 12 Help
Table
Password Field
Login Options
Advanced Security
Advanced Security feature allows you to setup User ID, assign User Levels to users and
create a complete user registration system. To setup, click the [Advanced] button.
PHPMaker supports two types of security - User ID and User Level. User ID Security
secures data at record level. User Level Security secures data at table level. They
complements each other and they can work independently or together. Users get their User
ID and User Level after login. Before login, an user's identity is unknown and the user is an
Anonymous User.
53
PHPMaker 12 Help
User ID
User ID Security secures data at record level. Protected tables must have an User ID field
for identifying which user a record belongs to. The User ID field names can be different in
tables though. When User ID security is enabled, users can only access their own data.
User Level
User Level Security secures data at table level. Each user level is granted with specific
permissions to tables in the database.
There are 2 types of User Level security:
1. Static User Levels - the User Levels and the permissions are defined in this form and
the User Levels are not to be changed after script generation.
54
PHPMaker 12 Help
icon to delete an
2. Dynamic User Levels - the User Levels and the permissions are defined in 2 tables in
the database, the User Levels can still be changed with the generated scripts.
55
PHPMaker 12 Help
2. Select an integer field in your user table as the [User Level field],(note: if this
field is not set, the feature is disabled)
3. Switch to the [Dynamic User Levels] tab, check [Enable Dynamic User Levels],
4. Select your User Level Table and User Level Permission Table and the required
fields.
The User Level Table and User Level Permission Table must have the following fields,
note the data types, User Level ID and the Permission fields must be of integer type, the
field names can be different though:
If you want PHPMaker to create these 2 tables in your database, click the [Create tables]
button, the following form will display for you to change the table/field names if necessary.
You can change the table/field names and then click OK to continue.
If you have projects created by previous versions of PHPMaker you may want to use
dynamic User Levels and migrate the previously defined static User Levels in the project to
the database. After selecting or creating the User Level and User Level Permission
tables/fields, just click the [Migrate] button to let PHPMaker do that for you.
56
PHPMaker 12 Help
After setting the user levels, PHPMaker will populate the user levels to the User Level field's
Edit Tag (also see Field Setup(See 1.10.7)) so administrators can assign user levels using
the generated pages.
Important Notes on Anonymous Users
1. From v12, the permissions for anonymous users are integrated in the User Level
security settings. See built-in user levels for anonymous users below.
There are three built-in user levels:
Anonymous - Anonymous user level is a built-in user level for the anonymous user (i.e.
users that have not logged in). The User Level ID of the anonymous user is -2.
Administrator - Administrator user level is a built-in user level that has all permissions plus
the privileges to modify User IDs and User Levels. Its permissions are same as that of the
hard-coded Administrator. The User Level ID of Administrator is -1.
Default - Default user level is built-in user level with user level = 0. Since User Level field is
an integer field, if you set a default value of 0 for this field, this user level will become the
default user level for the user after registration and before the Administrator assigning
another higher user level.
Important Notes on User Levels
1. Even you enable all permissions for an user defined User Level, the User Level will
NOT become same as this Administrator User Level. User defined User Levels will
not have the permissions to manage users.
2. From v9, the permissions for List/Search/View are separate in newly created
projects. However, for backward compatibility, the permissions for List/View/Search
in converted projects (created by previous versions) are the same unless you have
enabled Separate permssions for List/View/Search in Advanced Settings(See
1.13).
3. You may need to use the hard-coded Administrator Login to log on and assign
dynamic user levels to users initially.
4. It is possible to use single login and common Dynamic User Levels for multiple
projects provided that ALL projects use the same project name and same Advanced
Security tables (i.e. User Table, User Level Table and User Level Permission Table).
If all projects uses the same database and same Advanced Security tables, then the
latter condition is automatically fulfilled. However, if the projects use different
databases, you need to use Database_Connecting(See 1.10.9) server event to
change the connection info so the user can get the Dynamic User Levels from the
common Advanced Security tables correctly during login. For the projects not using
the database with the common Advanced Security tables, you still need to create
dummy Advanced Security tables (with same table/field names as the common
Advanced Security tables) in the project database so you can setup Advanced
Security.
57
PHPMaker 12 Help
Login
Track failed attempts
58
PHPMaker 12 Help
Disallow concurrent login
Maximum concurrent user session countFor use with Disallow concurrent login. By
default only one session is allowed fror each
user. But you may want to give more than one
chance to user so they will not be rejected after
unexpected incidents such as a system crash.
Please be reminded that this option
somewhat compromise the Disallow
concurrent login feature. Use this option
discreetly and always use the smallest possible
value.
Note
Password
MD5 password
59
PHPMaker 12 Help
character hexadecimal number) of the
clear text password. If you also use
case-insensitive password, convert the
clear text passwords to lower case first
before calculating MD5 hash.
Otherwise, existing users will not be
able to login. MD5 hash is irreversible,
password will be reset during password
recovery. Note that the reset password
is also in the format of 16-character
hexadecimal number, it is NOT the MD5
hash of the old password.
2. PHPMaker will try to detect salted
password created by other application.
(PHPMaker itself does NOT create salted
password.) If salted, the password
must be stored in
'<hashedstring>:<salt>' format, and
the hashed string must be the md5
hash of the concatenated string of the
clear text password and the salt. Other
salt algorithm is not supported, you can
however customize the function
ew_EncryptPassword() in the template
to suit your applcation.
Case-sensitive password
Fields
Requires activation
Auto login after registration/activation Optionally auto-login the user after registration
or activation.
60
PHPMaker 12 Help
Requires activation is enabled, the user
is not activated yet after registration, auto login
will be applied when the user clicks the
activation link in the email.
Note
Send email
Activated field
61
PHPMaker 12 Help
click an activation link in the email sent
after registration to activate the user
account.
2. If enabled, make sure the activated
field for existing users in your user
table is updated with your activation
values (e.g. True/False, 1/0, Y/N) or
the existing users cannot login because
they are not recognized as activated.
You can enable Multi-Update feature for
the user table so administrators can
activate or deactivate existing users
easily.
Profile field
Email Template
The email sending function and the email contents can be customized in the template. The
following special tags are used in the email templates:
62
PHPMaker 12 Help
You can also dynamically change the email by code using Email_Sending event before the
email is sent. (See Server Events and Client Scripts)(See 1.10.9)
1. To set up email templates for Multi-Language projects, read the topic Tutorial Multi-Language Project Setup(See 1.10.16)
Also See:
Tutorial
Tutorial
Tutorial
Tutorial
Tutorial
Template file
Application root folder
63
PHPMaker 12 Help
1.11) for more info on application root)
Destination folder
Output filename
Prefix/Infix/Suffix
Lowercase
Extension
Default page
Start page
Specify the first page that the default page (usually "index.php")
should redirect users to.
If this setting is left blank, user will be redirected to the List page
of the default table (see Table Setup(See 1.10.6)) or the first
table that the user have permission to access.
If this setting is not blank, the default page will simply redirect
user to the page you specify, e.g. a page not generated by the
current project or a custom file. If you start the site by the typical
index.php, leave this setting blank, do NOT enter index.php or
there will be a indefinite loop.
Specify the web server that you want to use to test the generated
site. For use with Browse after generation (see below). You
can choose IIS Express or Other. Requires IIS Express installed
on the same machine as PHPMaker.
IIS Express is a simpler and self-contained version of IIS that is
optimized for developers. IIS Express is free, does not require
administrative privileges to run. It can be downloaded from
microsoft.com.
If you choose Other web server (e.g. you use IIS or Apache),
you need to specify Testing root URL (see below) also.
Browse after generationSpecify whether to open a browser to test the generated site
after script generation.
Testing root URL
Specify the URL of your testing site that maps to the Application
root folder (see above). For use with Browse after
generation. If you use IIS Express, this setting is NOT
64
PHPMaker 12 Help
required.
For example, if you have set up a website like:
Application root folder:
C:\Users\Administrator\Documents\mycompany.com
Destination folder:
C:\Users\Administrator\Documents\mycompany.com\project1
and you have setup your testing website's document root at the
application root folder, so that you browse the main site by:
http://localhost/
and browse the PHPMaker generated site by:
http://localhost/project1/
Then the Testing root URL should be:
http://localhost/
(NOT http://localhost/project1/, which points to the Destination
folder).
PHPMaker will calculate the relative path and add "project1/" to
the Testing root URL when opening the browser.
After setting above, click the [Generate] button to generate scripts. PHPMaker allows you
select scripts to generate, just select the files you want to generate in the [Output] column.
If you want include PHPMaker scripts into your custom PHP scripts, you may not want to
generate header and footer in those pages. Then you can enable [No header/footer] for
those pages. Note that header/footer means the header row containing the site header
logo and the footer row containing the site footer text.
After selection, click the [Generate] button to generate scripts.
If it is your first generation for the project or you have changed some project level
settings, you must select [Other files] to generate the non table-specific pages.
Note
If you modify settings for a table and want to re-generate script for that table only, you can
click [Unselect All], then select the files you want to re-generate and click the [Generate]
button to generate again. If you are not sure which files to re-generate, click [Select All]
and re-generate all files.
You can also right-click the column header of [Output] or [No header/footer] to quickly
select all or unselect all items in the column.
65
PHPMaker 12 Help
If you need to abort script generation in the middle of the process, just click the [Cancel]
button under the progress bar that displayed during generation.
Also See:
Customizing Template(See 1.14)
Project File (See 1.12)
After loading the database, the tables will be shown in the database pane on the left pane.
To access ALL setting for a table (including Multi-page, Table-specific Options and
Master/Detail), click the table node of any table in the database pane and then
click the [Table] tab to go to the Table Setup page. This is the setup page for a single
table.
66
PHPMaker 12 Help
You can also click on the [Tables] or [Views] or [Custom Views] or [Reports] or
[Linked Tables] node in the database pane to go to the Tables Setup page which is a grid
showing the most frequently used settings for all tables. If you need to set these settings for
multiple tables, this page allow you to view and set them quickly. Note that this page does
not include Multi-page, Table-specific Options and Master/Detail.
Notes
1. For all checkbox or combobox columns, if you want to apply the setting to ALL tables
or views, you can choose your setting at the [Tables] or [Views] or [Custom
Views] or [Reports] or [Linked Tables] row.
67
PHPMaker 12 Help
2. View/Edit/Search functionality works at field level and can be setup for each field in
the Field Level Setup page. Please refer to the Field Setup(See 1.10.7) for details. If
all fields are not selected for View/Edit/Search, the function will not be generated.
If you prefer to view the tables in alphabetical order, click [Tools]->[Sort Tables
Alphabetically] (see Tools(See 1.13)).
You can still change the display order of the menu item by drag-and-drop. Select a table by
clicking the first column - [Table/View Name] column, then drag and drop to where you
want. Note that a table cannot be moved out of its parent node.
Note that changing the display order of table in this Table Setup page does not change the
display order of the tables in the menu. To change the display order of the menu item, click
[Tools]->[Menu Editor] (see Tools(See 1.13)).
Important
1. It is assumed that all tables have primary key. (Composite key is supported) If there
is no primary key specified, View/Add/Copy/Delete/Edit/Update settings have no
effect and will be reset to disabled when the [Generate] button is pressed. Only the
List page can be generated. If you add back a primary key later, you'll need to come
back to this page and re-enable them. Since reports are read-only,
View/Add/Copy/Delete/Edit/Update settings are not applicable to reports.
2. Views or Custom Views involving more than one table are usually NOT updatable.
Although you can force PHPMaker to enable the Add/Copy/Delete/Edit/Update pages
by specifying a primary key, the generated pages will not work if these views or
Custom Views cannot be updated like regular tables.
Caption
Filter
Specify a filter (WHERE clause) for the table. Click the [...] button in
[Filter] column, the Filter Editor will popup. Enter your filter, you can
drag the field names from the left pane to the editor, the SQL identifier
quote characters will also be added for you automatically.
68
PHPMaker 12 Help
Sort
Specify the sort fields (ORDER BY clause) for the table. Click the [...]
button in [Sort] column, the following dialog box will popup. You can
choose up to 6 fields, in either ascending or descending order.
69
PHPMaker 12 Help
Output folder
For use with Custom File only. The output folder is relative to
application root(See 1.11).
Include custom
files
For use with Custom File and for PHP file only. Include common files
such as header and footer so the custom file will have the same layout .
Default
Set a Table as the Default Table. The Default table is the first table the
user see when visiting your site. Select the table you want in the
[Default] column.
List
Inline Add
Enable/disable Inline Add function for the table. Inline Add allows
users to add a record within the List page. Default is disabled.
Inline Copy
Inline Edit
Enable/disable Inline Edit function for the table. Inline Edit allows
users to edit a record within the List page. Default is disabled.
Grid Add
Grid Edit
Detail Add
70
PHPMaker 12 Help
table). Allows users to add multiple records to the detail table in
the Add page of the master table. Default is disabled.
Detail Edit
Detail View
Requires Search CriteriaSpecifies if the List page requires search criteria. Default is
disabled.
Notes
View
ViewIf enabled, a View page for the table will be generated (for displaying a record).
Default is enabled.
71
PHPMaker 12 Help
The table must have primary key or this setting will be unchecked during
generation.
Note
Add
Add
If enabled, an Add page for the table will be generated (for adding/copying a
record). Default is enabled.
The table must have primary key or this setting will be unchecked during
generation.
Note
Copy
If enabled, Add page will be generated and "Copy" links will be generated for
record(s) in List/View page (for copying). Default is enabled. (If this setting is
enabled, the "Add" setting is also enabled by default as copying requires the Add
page.)
The table must have primary key or this setting will be unchecked during
generation.
Note
CAPTCHAEnable/disable CAPTCHA function for the Add page. Default is disabled. (CAPTCHA
requires that the user type the letters or digits of a distorted image before
submitting a form to prevent automated software from posting spam to your web
application.)
Notes
1. Requires CAPTCHA extension, click Tools -> Extensions from the main
menu to enable. Also see Third-party Tools(See 1.7).
2. Not applicable to Inline/Grid-Add/Copy.
Confirm Enable/disable confirmation function for the Add page. Default is disabled. If
enabled, there will be a confirmation step in the Add page, users will be able
check their input before actually inserting the record.
Note
Edit
Edit
If enabled, an Edit page for the table will be generated (for updating a
record). Default is enabled.
The table must have primary key or this setting will be unchecked
during generation.
Note
CAPTCHA
72
PHPMaker 12 Help
Confirm
Check ConflictsCheck if the record is changed by other user before updating the record.
Notes
Delete
DeleteIf enabled, a Delete page for the table will be generated (for deleting record or
multiple records). Default is enabled.
The table must have primary key or this setting will be unchecked during
generation.
Note
Multi-Update
Multi-UpdateIf enabled, a Multi-Update page for the table will be generated (for updating
multiple records). Default is disabled. With this feature you can select multiple
records in the List page and update all records at the same time. You can
select fields (see Field Setup(See 1.10.7) page) to be included in the MultiUpdate page.
The table must have primary key or this setting will be unchecked during
generation.
Note
Confirm
Search
Quick
73
PHPMaker 12 Help
Default value
Default search typeDefault search type for Quick Search. Possible values are:
Any words
All words
Exact match
Extended
For use with Extended Quick Search. Specifies the number of fields per
row in the Quick Search panel. Default is 0 (unspecifed), which means
one field per row.
Advanced
Highlight
If this setting is checked, the search criteria in the search result (List
page) will be highlighted. Default is disabled.
Audit Trail
To use this feature, you must also specify the [Audit Trail folder] or database table and
field under [PHP]->[General Options] tab. See PHP Settings(See 1.10.2) for details.
Audit TrailIf audit trail for a table is enabled, when an user add(copy)/edit/delete a record
or login/logout, the related information will be logged in a log file or into the
specified database table.
By default all add(copy)/edit/delete info will be logged, if you want to select
what to log, or want to log search/view activities also, use the Audit Trail
Extension, also see [Tools]->[Extensions(See 1.13)].
Note
Email Notification
To use this feature, you must also specify the [Email Settings] under [PHP]->[Email
Settings] tab. See PHP Setup(See 1.10.2) for details.
On Add
If enabled, when an user add a record, an email will be send to pre-set recipient
email address(es). Default is disabled.
On Edit
If enabled, when an user edit a record, an email will be send to pre-set recipient
email address(es). Default is disabled.
On DeleteIf enabled, when an user delete a record, an email will be send to pre-set
recipient email address(es). Default is disabled.
Other than above Tables Setup page, you can also click on a particular table node (under
[Tables] or [Views] or [Custom Views] or [Reports] or [Linked Tables] node) in the
74
PHPMaker 12 Help
database pane to go to the Table Setup page for that table. The Table Setup page includes
the following tabs: Table, Fields(See 1.10.7), and Server Events/Client Scripts(See 1.10.9).
Click on the Table tab you'll see settings for the selected table only. The right side includes
two panel - the [Table-specific Options] panel and the [Master/Detail] panel (see
below), the left side contains settings same as above (but for the selected table only) plus
the following additional settings:
Multi-page
Normally each field is displayed as a table row in the View/Add/Edit page, this Multi-Page
features allow you to display divide the fields into pages and display only one page at a
time. To enable, at least one field with page number larger than 1 must be set up in Field
Setup(See 1.10.7) page. This feature is presented as tabs.
Multi-Page type
Page Labels
Specifies the page captions of each page in the Multi-Page. Click the [...]
button and enter the page captions and click [OK] to save.
75
PHPMaker 12 Help
If page captions are not specified, "Page n" will be used by default. To
add a page, go to Field Setup(See 1.10.7) page, specify the page
number for the fields in the page first.
If you use Multi-Language (see PHP Settings(See 1.10.2)), use
Multi-Language Property Editor, see Tools(See 1.13) for details.
Note
Add page
Edit page
View page
Search page
Return Pages
After Add
Example 1
If you want to redirect user to a custom page, enter: (with quotes)
"MyPage.php"
Example 2
If you want to pass field values, enter: (with quotes)
"MyPage.php?xxx=" . urlencode($this-><Field>->CurrentValue)
e.g.
"MyPage.php?ID=" . urlencode($this->ID->CurrentValue)
76
PHPMaker 12 Help
Example 3
If you have just added a master record and want to go to Grid-Add page of the
detail table, enter: (with quotes)
"<DetailTable>list.php?a=gridadd&showmaster=<Table>&fk_<Key
Field>=" . urlencode($this-><Field>->CurrentValue)
e.g.
"OrderDetailslist.php?a=gridadd&showmaster=Orders&fk_OrderI
D=" . urlencode($this->OrderID->CurrentValue)
Example 4
If you have just added a master record and want to go to Add page of the
detail table, enter: (with quotes)
"<DetailTable>add.php?showmaster=<Table>&fk_<KeyField>=" .
urlencode($this-><Field>->CurrentValue)
e.g.
"OrderDetailsadd.php?showmaster=Orders&fk_OrderID=" .
urlencode($this->OrderID->CurrentValue)
After Edit
After
Register
Specifies the return URL after an user is registered. This setting is only
available for the user table specified in Security Settings(See 1.10.4).
The URL must be a valid PHP expression. If it is a string, it should be
double quoted.
Note
Table-specific Options
These options are same as the list page options as described in PHP Settings(See 1.10.2)
except that the options are table-specific, meaning that you can have different list page
options for different tables. To use table-specific options, select a table in the grid, uncheck
[Use global settings] in the [Table-specific Options] panel, the panel will be enabled for
you to setup.
77
PHPMaker 12 Help
Master/Detail
When you set up a master/detail relationship, you link two tables so that all the records of
one table (the detail table) always correspond to the single current record in the other table
(the master table). Each table can have multiple master tables and details tables.
You can establish master/detail (one-to-many) relationship between two tables as follows
1. Select a table in the table grid,
2. Then in [Master/Detail] panel at the bottom right corner of the page, click
[Modify...] to bring up the visual master/detail relationship editor.
3. Click [Add table] to add the master and detail table to the diagram.
4. Create a relationship between them by dragging from the master field (key field
in master table) to the detail field (foreign key field in the detail table). If
there are more linked field, repeat the step until all the relationships are setup.
78
PHPMaker 12 Help
If you want to remove a relationship, select the link in the diagram and click [Delete]. After
setup, click [OK] to confirm.
The diagram only shows master/detail relationships of the selected table. Although you
can setup relationships for other tables in the diagram and view them in the
[Master/Detail] panel immediately after clicking [OK], the relationships for other tables
will not be loaded again if you go to other table and then come back to this table. Instead,
the relationships will only be displayed when you change to the related tables.
Note
In most cases, master and detail tables are joined by one field, you have one link between
the master/detail table and you have one row in the Master/Detail panel only.
Referential IntegritySpecifies that user may not add/update a record in the detail table
unless the foreign key points to a valid record in the master table.
Cascade Delete
79
PHPMaker 12 Help
Cascade Update
Specifies that if the primary key for a record in the master table
changes, all corresponding records in the detail table will be updated.
If you have used ON UPDATE CASCADE for the table in the
database, no need to enable this setting.
Note
Also See:
Tutorial - Master/Detail(See 1.15.2)
PHPMaker support most commonly used data types. If PHPMaker finds any unsupported
fields in a table, an [Unsupported Fields] tab will appear. You can click on the tab to view
the list of fields that are not supported.
The Field Setup pages consists of two section. The upper section is a grid showing available
options of all fields. The lower section contain two panels, the [Edit tag] panel and the
[View tag] panel for the selected field.
80
PHPMaker 12 Help
General
List Page
View Page
Edit Page
Add Page
Multi-Update Page
Advanced Search Page
General
Properties
Field Name
Data Type
Size
Expression
The expression for custom field (Custom Fields only). See also Custom
Fields(See 1.10.14)
Caption
Primary Key
Page number of the field. For use with Multi-Page. By default all the
fields are in page 1 and Multi-Page is disabled.
Multi-Page is supported for Add/Edit/View/Search pages, you can
optionally enable it for each page. Page labels are also supported. See
Table Setup(See 1.10.6).
If Multi-Page is enabled and the page number is 0, the field will
appear in all pages.
Note
81
PHPMaker 12 Help
Name column and then right click to set the page number for the
selected fields simultaneously.
Auto-Update ValueA dynamic value to update the field function automatically in Add/Edit
pages.
The dropdown list for this setting is preloaded with a few functions for
your selection. For example, you may want to record the last modified
date of a record, then you can select "ew_CurrentDate". Do not select a
function that return values of unmatching data type, for example, you
should not select a function that return a non-numeric string for a
numeric field.
Notes
MyAutoValueFunction1,MyAutoValueFunction2
Then put your functions under server side Global Code section,
see Server Events and Client Scripts(See 1.10.9).
Change Field Display Order by Drag-and-Drop
You can change the field order defined in the database by simple drag-and-drop. Simply ctrlclick or shift-click the Field Name column to select multiple fields, then drag it to where you
want. PHPMaker will generate scripts and display records according to this order.
82
PHPMaker 12 Help
List Page
Properties
List
Export
Aggregate
83
PHPMaker 12 Help
- AVERAGE (average field value in current page)
Width
Specify CSS width property for field column width . e.g. If you enter: (no
quotes)
200px
the output will be:
style="width: 200px"
If your table is too wide, browsers will try to best fit the content into
screen and the specified width may be overridden.
Note
Wrap
Quick SearchInclude this field when performing Quick(Basic) Search in the List page.
Only text fields and numeric fields are supported in Quick Search. By
default only text fields are enabled.
Note
Ext. Search
View Page
Properties
View
View Tag
84
PHPMaker 12 Help
You can either click the [View Tag] column and select a View Tag from the drop down box
or click the icon on the View Tag panel toolbar to select. After selecting the View Tag, you
can further setup its properties in the View tag panel.
View Tag
There are two types of View Tag, Formatted Text and Image.
Formatted Text - View Tag to display the field value as formatted text using <div> tag
with optional hyperlink. Properties:
Custom Attributes Other custom attributes for the <div> or <span> tag. For example, you
can enter as string, e.g. (string with single/double quotes)
"onmouseover='my_js_function();'
onmouseout='my_js_function2();'"
or preferably as an array (array for PHP < 5.4), e.g.
85
PHPMaker 12 Help
or (array for PHP >= 5.4), e.g.
No formatting
Currency
Date/Time
Number
Percent
String
Format the field value with specified PHP string function or custom
function
Truncate the field value at specified max. length and append "..." to the
end.
This setting only applied to memo fields in list page and must be
larger than 0 to take effect.
Note
Hyperlink
HREF field
Display the field as hyperlink with the href attribute set to the value of
this field. It can be the field itself.
Original field
value
Use original field value of the Href field in the hyperlink instead of
display field value.
86
PHPMaker 12 Help
If the HREF field has lookup table or user values, by default the display
value will be used. If this option is enabled, the original field value will
be used instead.
Target
Prefix
Prefix added before the HREF field value. You can select one of the
follows:
-
You can also enter your own partial URL (preceding the HREF field
value)
This setting is a string to be quoted by double quotes, if you want
to use PHP variable, wrap it in "{" and "}". Since "{" can not be
escaped, this syntax will only be recognized when the "$" immediately
follows the "{". Read PHP Strings for more information on parsing
variable in string.
Note
mypage.php?id=
The value of the HREF field will be appended to the end of the your
prefix in the outputted HTML.
If you want pass a field value, you can enter: (no quotes)
mypage.php?myfield={$this->UrlEncode($this->MyField>CurrentValue)}&id=
If you need to pass parameters which should not be URL-encoded, for
example, if you use ew_Encrypt() to encrypt your parameter, you can
enter: (no quotes)
mypage.php?myfield={$this->Raw(ew_Encrypt($this>MyField->CurrentValue))}&id=
Suffix
Suffix added after the HREF field value. You can use this setting to
append additional URL parameters.
For example, you can enter: (no quotes)
&field2={$this->UrlEncode($this->Field2>CurrentValue)}
If the suffix is URL parameter(s), you should use "&" at the
beginning of the string.
Note
87
PHPMaker 12 Help
quotes)
"rel='xxx'"
or preferably as array, e.g. (array for PHP < 5.4)
Tooltip width
There are some ready-to-use Custom View Tag for you to choose:
Google Maps
Barcode and QR code
YouTube videos
If your data stores information for above, just click the down arrow
button to open the setup form, enable one of them, read the notes at
the bottom panel carefully, then click the Settings tab to setup, and
click OK to save your settings.
Notes
88
PHPMaker 12 Help
All records will use the same Custom View Tag. For instance,
you can NOT use Barcode for a record and use Google Maps
for next record.
2. The above Custom View Tags are provided as examples only.
The third party tools used are not developed by the author of
PHPMaker and are not part of PHPMaker, NO TECHNICAL
SUPPORT WILL BE PROVIDED.
You can also create your Custom View Tag, they are implemented in
exactly the same way as template extensions (see Customizing
Template(See 1.14)). Custom View Tags must be placed under the
subfolder "customviewtags" of the installation folder. Each Custom View
Tag must have a XML description file so it can be loaded for selection.
You can open an XML file in the "customviewtags" subfolder to see the
content, which is self-explanatory. Unzip the zip file to see how it is
implemented.
If you want absolute freedom, click the [...] button to enter your own
code to display the your data in your own PHP, HTML and JavaScript.
If you choose to enter your own code, you are completely on
your own to display the field value. Intermediate knowledge in PHP,
HTML and JavaScript is required.
Important
Custom View Tag is HTML, if you want to embed PHP code, use <?php
and ?>, if you want to use JavaScript, use <script
context, you can use CurrentPage() to get the current page object.
To reuse the original code, you can generate scripts without Custom
View Tag first, then customize the field in View page as needed. When
done, copy and paste your customized code to PHPMaker user interface
as your Custom View Tag.
The original code will also be generated in a hidden DIV with
id="orig_<table>_<field>", you can also reuse it by JavaScript.
Example 1
Output the field value conditionally:
<?php
if (CurrentPage()->MyField->CurrentValue == "xxx") {
// Assume string field
echo "something";
} else {
echo "something else";
}
?>
Example 2
Output a custom link:
89
PHPMaker 12 Help
Example 3
Reuse the original code by JavaScript. Replace some code in the original
code by regular expression:
<div id="my_unique_id"></div>
<script type="text/javascript">
$("#my_unique_id").html($("#orig_MyTable_MyField").htm
l().replace("xxx", "yyy").concat("zzz")); // Replace
part of the old code by new code, and append something
at the end
</script>
Notes
Image - View Tag to display as Image using <img> tag. The field should be a BLOB field or
a field storing the path of an image.
Only image files can use the Image View Tag. Other files such as PDF cannot be
displayed as image. If the field contains mixed file types, do not use Image View Tag.
Note
90
PHPMaker 12 Help
Height
Alt
Custom attributesOther custom attributes for the <div> or <span> tag. For example, you
can enter: (string with single/double quotes)
"onmouseover='my_js_function();'
onmouseout='my_js_function2();'"
or (array for PHP < 5.4)
Resize the image to above width and/or height on displaying the image.
This feature requires PHP GD extension and supports GIF, JPEG and
PNG images only.
Note
Edit Page
Properties
91
PHPMaker 12 Help
Edit
Title to be placed in title attribute of Edit Tag. (see section below) The title will
also appear as popup tooltip of the Edit Tag.
Title
If you use Multi-Language (see PHP Settings(See 1.10.2)), use MultiLanguage Property Editor, see Tools(See 1.13) for details.
Note
Form element for the field. Use in Add/Copy/Edit/Search pages. (See below for
details)
You can either click the [Edit Tag] column and select a Edit Tag from the drop down box or
click the icon on the [Edit Tag] panel toolbar to select. After selecting the Edit Tag, you can
further setup its properties in the Edit Tag panel:
Edit Tags
Edit Tags are HTML forms elements for the field in Add/Copy/Edit/Search pages. All HTML
form elements are supported:
Text
92
PHPMaker 12 Help
Size
Maxlength
"onmouseover='my_js_function();'"
or (array for PHP < 5.4)
array("onmouseover" =>
"my_js_function();")
or (array for PHP >= 5.4)
Custom attributes
93
PHPMaker 12 Help
format.
Client side events
Validation
Force selection
Option Template
94
PHPMaker 12 Help
details.
Passw <input type="password"> tag
ord
Display the field as a masked textbox.
Size
MaxLength
Custom attributes
Validation
95
PHPMaker 12 Help
Repeat columns
Use dropdown
96
PHPMaker 12 Help
Option Template
97
PHPMaker 12 Help
labels and values are "Y" and "N" (or "1" and "0") will be considered as boolean
fields. PHPMaker will display a boolean field by a checkbox automatically.
Custom attributes Same as above (see Text Edit Tag)
Client side events See section below
Validation
Repeat columns
Use dropdown
98
PHPMaker 12 Help
Option Template
The submitted values of the multi-selected checkboxes is a commaseparated string. Therefore you must use a string field for checkbox list.
Note
99
PHPMaker 12 Help
Size
Multiple
Custom attributes
Validation
Repeat columns
Use dropdown
100
PHPMaker 12 Help
Option Template
101
PHPMaker 12 Help
File
Cols
Rows
Custom
attributes
Client side
events
Validation
Use DHTML
Editor
Replace the textarea with a DHTML editor for editing the data as
HTML. See Third-party Tools(See 1.7) for more info on DHTML
Editors.
102
PHPMaker 12 Help
Size
Custom attributes
Validation
If the field is of BLOB (binary) data type, file is uploaded to the database.
You can also store the information of the uploaded file in the following fields: (for
BLOB field only)
File type field - Recommended. Useful when you want to response to user browser
the exact content type of the data.
File name field - Optional. Useful if you want to use the original filename.
Do not specify file name field if you want IE to open the file automatically. (IE
may fail to open non-image files retrieved from database properly.) Use file name
field if you want IE to popup a File Download dialog for user to save the file with
the filename specified in the file name field.
Note
103
PHPMaker 12 Help
uploaded image.
Image height field - Optional. For use with images only. Stores the height of the
uploaded image.
If the field of string type, file is uploaded to a subfolder relative to the
application root.
Multiple - Allow multiple upload. Field value will be comma separated file names.
NOT application to BLOB field.
Upload folder - Folder where the uploaded file will reside. If you do not enter a
specific folder, all the uploaded files will be put in the global upload folder specified in
the PHP tab (see PHP Settings(See 1.10.2)).
Notes
1. Unlike the global upload folder setting (which is a constant and must be a
string without double quotes, see PHP Settings(See 1.10.2)), this field
setting must be a valid PHP expression. If it is a string, it must be single
or double quoted.
2. Make sure that the Web server user have read/write access to the folder.
3. The path is relative to application root. Use slashes "/" as path
delimiter, no leading slash. e.g. If the application root of your website is
C:\Inetpub\wwwroot\demo and you enter "uploads/folder1/" (with double
quotes) in this textbox, the folder for the uploaded files will be
C:\Inetpub\wwwroot\demo\uploads\folder1. If you are not sure which folder
is application root, please read Creating Virtual Directories in IIS(See 1.8).
4. The path can be dynamic. For example, if the upload path varies with some
field value, you can refer to other fields by $this->MyField->DbValue.
However, you must be very careful when using dynamic folder, make sure
the setting is valid as a folder name, i.e. it does not contain some characters
which can not be used in a file path on your server. The setting will be
evaluated to obtain the upload folder before the file is displayed and before
the uploaded file is saved, so your setting should be consistent, do not use
random number or current date/time to name the folder. Alternatively, you
can also use Row_Rendered, Row_Inserting and Row_Updating server
events(See 1.10.9) to set the field object's UploadPath property.
5. If Multiple is enabled, all upload files use the same upload folder.
Resize image - Optionally resize the image to resize width and/or height.
Resize width - Width of the resized image
Resize height - Height of the resized image
Resizing requires PHP GD extension and supports GIF, JPEG and PNG images
only.
Note
Allowed file types - Comma separated file extensions (e.g. jpg,png,gif) without
spaces and quotes. If not specified, the global setting (see PHP Settings(See 1.10.2)
-> General Options -> File Upload) will be used.
Max file size (bytes) - The maximum allowed file size in bytes. (Requires browsers
supporting the File API.) If not specified, the global setting (see PHP Settings(See
1.10.2) -> General Options -> File Upload) will be used.
Max number of files - The maximum number of files that are allowed to be
uploaded if Multiple (see above) is enabled. It must be larger than 1. (If you just
allow one file, disable Multiple.) If not specified, unlimited file uploads are allowed.
104
PHPMaker 12 Help
Since file names are stored as comma separated value in the field, the max number
of files is also limited by the field size defined in the database.
Hidde <input type="hidden"> tag
n
Hide the field with a hidden form element.
This is different from de-selecting the field in the [Edit] column. If a field is deselected, no code will be generated for the field in the Edit page and the field will not
be updated. With a hidden form element the field is not seen but it may still get
updated.
Note
Custom value - by default the 'value' attribute contains the field value, custom
value is used to update the field with another value when a record is updated using
the Edit page.
Notes
1. Custom value is used in Edit page only. It cannot be used with Read-only
fields, User ID fields and Detail fields(Foreign key fields)
2. In Add page, if a default value is specified (see section below), hidden form
element will also be used but the 'value' attribute will contain the default
value. If default value is not specified, the field will be displayed as a normal
textbox.
3. Other preferable ways of updating a hidden field is to use Auto-Update
Value (see above) or to use Row_Inserting and/or Row_Updating server
events(See 1.10.9).
Custom attributes - same as above (see Text Edit Tag)
105
PHPMaker 12 Help
For boolean fields, if you use Radio Edit Tag with User Values, the first value/label
should be for True and the second for False.
Note
106
PHPMaker 12 Help
You can manipulate fields on the client side quickly with PHPMaker's "fields" jQuery plugin
(see Server Events and Client Scripts(See 1.10.9)).
Example 1
Set field values based on current field value
value to
true to
true as
true as
value to
Example 2
Client side calculation based on user input
Integer
Float
Range
Date(yyyy/mm/dd) - also allows yy/mm/dd and date
with time
Date(mm/dd/yyyy) - also allows mm/dd/yy and date
with time
Date(dd/mm/yyyy) - also allows dd/mm/yy and date
with time
Time(hh:mm:ss)
Email
107
PHPMaker 12 Help
Credit card
GUID
US phone number
US zip code
US social security number
Regular Expression
Notes
/foobar/i
See Creating a Regular Expression for more information about
the pattern and flags.
Arguments (Server-side)Arguments for the PHP functions for validation. For Regular
Expression and custom validation functions only.
108
PHPMaker 12 Help
This is PHP arguments, it should be comma separated (if
more than one) PHP expressions. e.g. If it is a string, it must be
single or double quoted.
Note
'/foobar/i'
See PHP function preg_match for more information about the
pattern.
Use date/time picker
Check duplicate
Add Page
109
PHPMaker 12 Help
Properties
Add
Default ValueDefault value for field (for adding new record only) .
The value must be a valid PHP expression. (If it is a string, must be single or
double quoted.)
Multi-Update Page
Properties
Multi-UpdateShow field in Multi-Update page
If a field is selected, it will be included in the (See 1.10.7)Multi-Update page.
In the generated (See 1.10.7)Multi-Update page, there is a checkbox for each
field, the field will only be updated if the checkbox is checked so users can
update only the checked fields without affecting values of the other unchecked
fields.
Properties
Search
Show field in Advanced Search page (Note: NOT related to Quick Search)
110
PHPMaker 12 Help
Search Opr 1
Default Value
Search Opr 2
Also See:
Custom Fields(See 1.10.14)
Lookup Table
Lookup Table is used for lookup field with Text (Auto-Suggest), Radio, Checkbox and
Select Edit Tags. To enable, check User lookup table under Edit Tag panel after selecting
one of the Edit Tags.
111
PHPMaker 12 Help
From v12, Lookup Table always use Ajax and the "Use Ajax" option in previous versions
has been removed.
Note
Table name
Link field
Required. The field to be used as the value of an option. Note that this is
the actual value to be submitted by the form This field is usually the key
field of the lookup table.
Display field #1
Display field #2
Display field #3
Display field #4
Order By
Optional. Specify a field in the lookup table for sorting the options.
Asc/Desc
Distinct
Filter
Optional. Specify the WHERE clause of the SELECT statement for the
lookup table. The input should be a valid PHP expression. If it is a string,
it should be quoted.
If your lookup table has a special field (e.g. named "ALookupTableField")
for filtering the records by a field (e.g. named "AField") in the current
112
PHPMaker 12 Help
record (of the current table), you can enter:
"`ALookupTableField` = 'SomeValue'"
b. if the value needs to be escaped,
(strval(CurrentPage()->AField->CurrentValue) <>
"") ? "`ALookupTableField` = " .
ew_QuotedValue(CurrentPage()->AField>CurrentValue, EW_DATATYPE_STRING) : ""
3. This setting is used in all pages. If you want to used in some
pages only, you should add your conditions, e.g. if you just want
to use your filter in the Edit page,
(CurrentPageID() == "edit") ?
"`ALookupTableField` = 'SomeValue'" : ""
4. This setting is an one-liner. If your logic is complex and cannot
be implemented in one line, you can write a function and enter a
function call, e.g.
MyLookupFilterFunction()
You can also pass some variables to your function as arguments,
e.g.
MyLookupFilterFunction(CurrentPage()->AField>CurrentValue)
Your function should return a valid WHERE clause, e.g.
function MyLookupFilterFunction($value) {
if (strval($value) <> "") {
return "`ALookupTableField` = " . $value;
// assume ALookupTableField is integer field
} else {
return "";
}
}
113
PHPMaker 12 Help
You can place your function in Global Code section under
Server Events/Client Scripts. (See Server Events and Client
Scripts(See 1.10.9).)
Parent field #1
Optional. For use with dynamic selection lists. Specify the parent field
(in the current table) for the current selection list.
When the parent selection list is changed, the available options in
current selection list will be changed accordingly. Each field can have up
to 4 parent fields.
Parent field is solely used with Filter field for dynamic selection
lists only. Each Parent field MUST have a corresponding Filter field.
The Parent field alone does NOT do any filtering.
Note
Filter field #1
Optional. For use with dynamic selection lists. Specify the filter field (in
the lookup table) for filtering.
When the parent selection list changes, only options (records from the
lookup table) with Filter field value matching the selected value(s) of
its corresponding Parent field will be shown.
Filter field is solely used with Parent field for dynamic selection
lists only. Each Filter field MUST have a corresponding Parent field.
The Filter field alone does NOT do any filtering.
Note
Parent/Filter #2 Optional. For use with dynamic selection lists. The 2nd pair of parent
field and filter field.
If setup, the filtering of lookup table records will be based on 2 fields.
For example, if you have set up Parent/Filter field #1 and
Parent/Filter field #2, and both Parent field #1 and Parent field
#2 have selected value, the records will be filtered by:
Parent/Filter #3 Optional. For use with dynamic selection lists. The 3rd pair of parent
field and filter field. If setup, the filtering of lookup table records will be
based on 3 fields.
Parent/Filter #4 Optional. For use with dynamic selection lists. The 4th pair of parent
field and filter field. If setup, the filtering of lookup table records will be
based on 4 fields.
Allow add
1. Review your lookup table design before using this option. The
option works best if you there is only one display field and the
link field (primary key) is an autoincrement field. In that case
the user only need to fill in a textbox and the option is added.
But if the link field (primary key) is not an auto-increment field,
114
PHPMaker 12 Help
the user will need to enter the link field value which the user
may not know.
2. The user will be asked to enter the link field and the display
field(s) only. If the lookup table has other NOT NULL fields other
than the link field and display field(s), the new option cannot be
added. However, you can define default values for these fields in
the database (not in PHPMaker).
3. This feature is implemented using Ajax.
4. Adding fields other than the link field, display fields and filter
field is allowed. Click the [...] button and select additional fields
in the lookup table. However, please note that this feature is
designed for adding a lookup value on-the-fly only, it is NOT
supposed to replace the full-featured Add page of the lookup
table. Although file upload and JavaScript features such as
popup calendar and DHTML editor are also allowed (v9+), there
may be chances that they do not work properly in the popup
form. You should choose as few fields as possible. Also, note
that the add option form for each lookup table is shared among
all fields (possibly in different tables) using the same lookup
table. If you change the fields to be added to the lookup table,
the shared add option form will affect other fields as well.
Auto fill
Optional. If enabled, the script fills the target fields for you
automatically.
For example, when you select a product number (which is a lookup field
using the product table as its lookup table), it will fill product price
textbox for you.
Before using Auto-Fill, review your database design, you should
consider database normalization, in many cases you do NOT need to and
you should NOT copy the field values from one table to another. You can
view the other field values by creating a query/view joining the current
table with the lookup table using the parent field as linked field.
Note
115
PHPMaker 12 Help
In this example, when you select a product from combobox, the script
know the product ID from the option value, so it can use the ID to
locate the product from the same lookup table (your product table) and
retrieve other field values such as the product unit price and fill the
target fields.
Do NOT setup fields to autofill each other. For example, if you set
up field A to autofill field B (A -> B) and B -> A, it will be an infinite
loop. Similarly, if you setup A -> B and B -> C and C -> A, it will not
work either.
Note
Allow sort/search Enable sorting and searching of the looked-up values. For use with
Select (select-one) or Radio or Text Edit Tag only.
Since display values are field values in the lookup table (not in the main
table), they are retrieved dynamically by code during execution of the
script and normally the field cannot be sorted or searched by the display
values. PHPMaker makes it possible by adding a subquery to the SQL to
create a virtual field in the main table.
Limitations
Enable text input for the field in the search forms. For use with Select
(select-one) or Radio or Text Edit Tag with Allow sort/search
enabled.
If Edit Tag is not Text (i.e. Select or Radio) and you have enabled
Allow sort/search, you may want to search with a textbox instead of
combobox or radio buttons. If so, enable this setting. Note that if Edit
Tag is Text and you have enabled Allow sort/search, the input is
116
PHPMaker 12 Help
textbox, this setting is enabled automatically even you have not checked
this setting to enable it explicitly.
NOT compatible with Dynamic Selection Lists. When this option is
enabled, the form element value (and the submitted value) is always
the text input (not the Link field value) for searching to work.
Therefore, if the field is a parent field in Dynamic Selection Lists (see
below), the child fields may not work in the search forms.
Note
Option Template
By default, the options are displayed as comma separated values of the display field values.
If you just want to change the display value separator from comma to other string, you can
use server events such as Page_Load (see Server Events and Client Scripts(See 1.10.9)) to
set the field object's DisplayValueSeparator property, e.g. if the field name is "MyField",
117
PHPMaker 12 Help
Option Template supports the following tags:
{{:lf}}
{{:df1}}
{{:df2}}
{{:df3}}
{{:df4}}
Option template is in the format of JsRender template, refer to JsRender API for more
details.
Note
If the options needs to show some additional data from the lookup table, you can get the
additional data as Display fields so you can use them in Option Template. If you use Text
Edit tag (see Field Setup(See 1.10.7)), sometimes you may not need the additional data in
the input textbox, then again you can set the DisplayValueSeparator property by server
event. If the separator for a display field is not specified, the display field value will not be
placed in the input textbox You must always put the additional data in the last (n) display
field(s). There are 3 possible settings:
118
PHPMaker 12 Help
Write a Startup Script for Add Page to attach onchange event: (JavaScript)
$("#x_ProductID").change(function() {
var result = ew_Ajax(ewVar.MyCustomSql, $(this).val()); // Send
the encrypted SQL and client side input value to server side by Ajax
for execution and get the result
$("#x_UnitPrice").val(result); // Set the result (manipulate it
first if necessary) to the target field
});
Note
The function ew_Ajax() reuses the generated script for lookup tables (ewlookup*.php)
so there is no need to write server side handler. For synchronous requests, if the result is a
recordset, it is in the format of array of object. If the result is a row, it is in the format of
object. If the result is a single value, it is in the format of string, remember to convert it to
the proper data type before manipulation. The function also supports asynchronous request,
just pass a callback function as the third argument, but the result from the server side is not
processed and therefore is always in the format of array of object. See the source code of
ew_Ajax() in the generated ewp*.js for details.
$("#x_ProductID").change(function() {
$.post(ew_CurrentPage(), { "myajax": 1, "token": EW_TOKEN,
"value": $(this).val() }, function(result) { // Post back your custom
data (with the synchronizer token)
$("#x_UnitPrice").val(result); // Set the result (manipulate
it first if necessary) to the target field
});
});
Write a server side handler, check your custom data "myajax" in Page_Load server event
for Add Page and return the required value. In this example, only a single value is required
so ew_ExecuteScalar() (see Server Events and Client Scripts(See 1.10.9)) is used, e.g.
(PHP)
119
PHPMaker 12 Help
Note: For simplicity, we use "table" in the following description to refer to any of database
object in the project. A database object can be either a table, a view, a custom view or a
report.
The treeview shows the available server events and client scripts that you can add to your
project:
Server Events Server-side PHP procedures
Global
Table-SpecificThe set of events are table-specific, the events are applicable to the selected
table only
Other
The events are applicable to some common pages in the project only
120
PHPMaker 12 Help
Client Scripts Client-side JavaScript
Global
The JavaScript are included in all pages with header and footer
Table-SpecificThe JavaScript are table-specific, they are included to pages for the selected
table only
Other
The JavaScript are included in some common pages in the project only
To add your custom scripts to the server events or client scripts, select an item in the
treeview, then enter your code in the editor.
The editor supports Find and Replace. Press Ctrl-F to open the Find dialog and press Ctrl-H
to open the Replace dialog.
You can click the [Clear] button to discard the existing code and reset template code for the
server event or client script.
Code Repository
PHPMaker provides a Code Repository for easy reuse of your code across projects and
sharing with other users. Click the [Code Repository] button to open it, categorized
reusable code will be displayed:
You can add the code to the editor by clicking the [Add to Editor] button. The reusable
code is stored in XML files which reside in s subfolder name "code" under the installation
folder. The format of the XML files is simple, there are 3 parts:
1. description - description of the reusable code
2. code - code to be inserted to editor
3. globalcode - common code to be inserted to Global Code (see below), this code will
only be inserted once into the project. For example , if your code is used several
121
PHPMaker 12 Help
times in your project and your code calls a helper function, it is unnecessary to
include the helper function several times. In this case you put your helper function in
the globalcode section, then the function will only be included one time.
There are a few example files in the "code" folder, you can copy and modify for your own
code and then save them under the "code" folder for reuse.
Server Events
In general, server events are fired in the following order:
Notes
1. From v9, the page class inherit from the table class, so you can use $this in the
page class methods to access table class members. For backward compatibility, the
table object is kept and it is an alias of the page object, so you can also use $this
in the table class methods to access page class members.
2. The Page_Unload and Page_Unloaded are server side events to be fired every
time the page is accessed and before the HTML is outputted to the browser on the
client side. They are NOT events to be fired before you leave the page and reload
the page or go to another page. For example, if you submit a form in the page,
usually it submits to the page itself, you are actually reloading the page, all server
events will be fired again. For another example, if you click a hyperlink which links to
another page, the page on the server side is not even accessed again and no server
events for the page will be fired.
3. If a server event is a global function, there is NO $this in the function context. If
you want to refer to the current page object, you can use the global function
CurrentPage().
4. In the following table, the <fieldname> in code, e.g. in $this-><fieldname>><property> or x_<fieldname>, represents the field variable name. In general, if
the field name is alphanumeric, field variable name is same as the field name.
Otherwise, spaces are replaced by underscores, and other non alphanumeric
characters are replaced by their hexadecimal string representation of their unicode
value. If the variable is a reserved word or starts with a digit, it will be prepended
with an underscore. However, note that if the field name is quoted, e.g. as a key in
$rs['<fieldname>'], <fieldname> is the actual field name as in the database,
not the field variable name.
5. Server events are functions or class methods, if you need to use global variables in
the events, note the PHP variable scope, you must use the global keyword or
$GLOBALS.
Available server events are:
Global -> All Pages
Page_Head
The code you entered in this event will be placed in the header.php
before closing the <head> section. You can use this event to can add
122
PHPMaker 12 Help
your code in head section. Note: This is a global function.
Example
PHPMaker does NOT use jQuery UI, but you can include it yourself
(using CDN):
ew_AddStylesheet("http://code.jquery.com/ui/1.10.3/the
mes/smoothness/jquery-ui.css"); // Add CSS stylesheet
ew_AddClientScript("http://code.jquery.com/ui/1.10.3/j
query-ui.js"); // Add JavaScript
Then you can use the widgets using Startup Script (see below).
Database_Connecti This event will be called by all PHP pages before connecting to the
ng
database. Note: This is a global function.
If MySQL/PostgreSQL, the argument is an array with the following
keys: host, port, user, pass, db. If Access/MSSQL, the argument is
the connection string for ADO. You can use this event to change the
connection string (e.g. changing connection info with server, or even
connect to other databases).
Example 1
// MySQL/PostgreSQL
function Database_Connecting(&$info) {
//var_dump($info);
// assume the scripts are generated with
connection info for local PC
if (ew_CurrentUserIP() <> "127.0.0.1") { // not
connecting to local PC
// connect to the production database
$info["host"] = "localhost";
$info["user"] = "xxx";
$info["pass"] = "yyy";
$info["db"] = "production_db";
}
}
Example 2
It is possible to use single login and common Dynamic User Levels for
multiple projects provided that ALL projects use the same project
name and same Advanced Security tables (i.e. User Table, User Level
Table and User Level Permission Table). If all projects uses the same
database and same Advanced Security tables, then the latter condition
is auto fulfilled. However, if the projects use different databases, you
can use this event to change the connection info so the user can get
the Dynamic User Levels from the common Advanced Security tables
correctly during login, e.g.
// MySQL/PostgreSQL
function Database_Connecting(&$info) {
//var_dump($info);
if (preg_match('/login|userpriv/',
CurrentPageID()) { // login.php or userpriv.php
123
PHPMaker 12 Help
// connect to the common database with the
common Advanced Security tables
$info["host"] = "localhost";
$info["user"] = "xxx";
$info["pass"] = "yyy";
$info["db"] = "common_db";
}
}
Database_Connect This event will be fired by all PHP pages after connecting to the
ed
database. Note: This is a global function.
The argument is the connection object, you can use it to execute your
own statements.
Example
Call a stored procedure after connection.
function Database_Connected(&$conn) {
$conn->Execute("CALL MyStoredProcedure");
}
Language_Load
This event will be fired when the language file is loaded. You can use it
to change the language phrases if necessary. Note: This event is a
language class member.
Example
function Language_Load() {
$this->setPhrase("MyID", "MyValue"); // Refer to
language file for the actual phrase id
$this->setPhraseClass("MyID", "glyphicon
glyphicon-xxx ewIcon"); // Refer to
http://getbootstrap.com/components/#glyphicons for
icon name
}
Page_Loading
This event will be called by all PHP pages at the beginning of the page.
If the pages involves database connection, it will be called after
connecting to the database and before the Page_Load event. Note:
This is a global function, NOT page class member.
Page_Rendering
This event will be called by all PHP pages before outputting HTML for
the page. Note: This is a global function, NOT page class
member.
Page_Unloaded
This event will be called by all PHP pages at the end of the page. If the
pages involves database connection, it will be called before closing
database connection and after the Page_Unload event. Note: This is
a global function, NOT page class member.
Global Code
Code to be included in all PHP pages. This may contain your constants,
variables and functions.
User_CustomValidaFor use with security. (See Security Settings(See 1.10.4)) This event
is fired before default user validation. You can use this event to
124
PHPMaker 12 Help
te
validate the user yourself. The arguments are the user name and
password the user entered. Return TRUE if the username and
password pass your custom validation. Note: This event is a
security class member.
From v9, default validation will continue after this event is fired. If
you return TRUE, the user will always pass the default validation and
get the User ID and User Level, if any. If you return FALSE, the default
validation proceeds as normal. If you use Advanced Security, you still
need the user table to store user information such as User ID and User
Level, although the password field value can be empty or any value if
you return TRUE.
Note
Example 1
Login user by Windows user name.
For use with security. (See Security Settings(See 1.10.4)) This event
is fired after successful user login. The user info is passed to the event
as an array (see note), you can get more info of the user and use it as
you need. Note: This event is a security class member.
Notes
125
PHPMaker 12 Help
Add current user's country to session variable
function User_Validated(&$rs) {
$_SESSION["UserCountry"] = $rs['Country'];
}
Example 2
Check if an user password has expired by custom code with Enable
password expiry (see Security Settings(See 1.10.4)) enabled
function User_Validated(&$rs) {
if ($rs["PasswordExpired"] == "Y") { // Assume the
user table has a field named "PasswordExpired" storing
if the password has expired
$this->SetPasswordExpired($rs["Username"]); //
// Assume the user name field is named "Username"
return FALSE; // Return FALSE to invalidate
the user
}
}
UserLevel_Loaded For use with User Level security. (See Security Settings(See 1.10.4))
This event is fired after successful user login and after the User Level
settings are loaded. It is possible to do actions such as changing or
adding User Level permissions. Note: This event is a security class
member.
Example
Change the permissions of an User Level for a table
function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return False if menu item not allowed
126
PHPMaker 12 Help
if ($Item->Text == "Download")
return Security()->IsLoggedIn();
return TRUE;
}
Menu_Rendering
This event is fired before the menu is rendered. You can manipulate
the menu items in this event. The argument is the menu object. (See
Menu Object below.) Note: This is a global function.
Example 1
Add an additional menu item to the menu for logged in users only.
function Menu_Rendering(&$Menu) {
if ($Menu->IsRoot) { // Root menu
$Menu->AddMenuItem(10000, "MyName",
"MyMenuText", "MyPage.php", -1, "", IsLoggedIn());
$Menu->MoveItem("Logout", $Menu->Count() - 1);
// Move to last
}
}
Example 2
Remove all the default menu items and use your own menu items.
function Menu_Rendering(&$Menu) {
if ($Menu->IsRoot) { // Root menu
$Menu->Clear(); // Clear all menu items
$Menu->AddMenuItem(1, "MyName1",
"MyMenuText1", "MyPage1.php");
$Menu->AddMenuItem(2, "MyName2",
"MyMenuText2", "MyPage2.php");
}
}
TablePermission_L For use with User Level security. (See Security Settings(See 1.10.4))
This event is fired before the user permission for the table of the
oading
current page is loaded. It is possible to do actions such as changing or
adding more User Level permissions to the current user. Note: This
event is a security class member.
This is an event fired for the current table only. If you
change the permissions of the other tables in this event, there will be
no effect. Use the UserLevel_Loaded event if you need to change
permissions of other tables.
Note
Example
Grant another User Level to the user and let the user have permissions
of more than one User Level for the current table.
127
PHPMaker 12 Help
$this->AddUserLevel("Manager");
}
TablePermission_L For use with User Level security. (See Security Settings(See 1.10.4))
This event is fired after the user permission for the table of the current
oaded
page is loaded. It is possible to to change the permission by using the
setCanXXX methods of the Security class. Note: This event is a
security class member.
This is an event fired for the current table only. If you
change the permissions of the other tables in this event, there will be
no effect. Use the UserLevel_Loaded event if you need to change
permissions of other tables.
Note
Example
Grant more permissions to the user and let the user have more
permissions than his/her User Level allows for the current table.
For use with User ID security. (See Security Settings(See 1.10.4)) This
event is fired after successful user login and before loading the User ID
and its child User IDs of the current user. These User IDs determine
which records the current user can access. It is possible to do actions
such as changing the User ID of the current user so the user can
access records that he/she can access by its original User ID. Note:
This event is a security class member.
Example
Change the user's User ID to his parent user's user ID and let the user
access more records (accessible by the parent user).
For use with User ID security. (See Security Settings(See 1.10.4)) This
event is fired after loading the User ID and its child User IDs of the
current user. These User IDs determine which records the current user
can access. It is possible to do actions such as adding or deleting the
loaded User IDs for the current user so the user can access more or
less records that he/she can access by its originally loaded User IDs.
Note: This event is a security class member.
Example
128
PHPMaker 12 Help
Add more User IDs to the user and let the user access more records
function Recordset_Selecting(&$filter) {
ew_AddFilter($filter, "Field1 = 1234"); // Add
your own filter expression
}
Recordset_Selecte This event will be called after selecting records. Note: The argument is
d
the recordset object (not array).
Recordset_SearchV This event will be called after the Form_CustomValidate event and
the search criteria is assigned to the table/field objects. You can
alidated
modify the search criteria in this event.
This event is a member of the table class. There is no arguments for
this event. To change the Quick Search criteria, change the
BasicSearchKeyword and BasicSearchType property of the table
object. To change the Advanced Search criteria, change the
AdvancedSearch property (which is an object of the
cAdvancedSearch class) of the field object.
Example
function Recordset_SearchValidated() {
$this->MyField1->AdvancedSearch->SearchValue =
"your search criteria"; // Search value
}
129
PHPMaker 12 Help
Recordset_Searchi This event will be called before the search criteria is saved for the
session. The argument of the event is the part of WHERE clause built
ng
from the Quick/Extended/Advanced search criteria. You can modify the
WHERE clause in this event.
Example
Search a MySQL DATE field for a selected date or within 3 days after
the selected date.
function Recordset_Searching(&$filter) {
//die($filter); // Uncomment to view the filter
first
$filter = preg_replace('/`MyDateField` = (\'\d{4}\d{2}-\d{2}\')/', '`MyDateField` >= $1 AND
`MyDateField` < DATE_ADD($1, INTERVAL 3 DAY)',
$filter); // Replace part of the filter with your
modified filter
}
Row_Deleting
This event will be called before deleting a record. The argument of the
event is the record to be deleted as an array.
Row_Deleted
This event will be called after deleting a record. The argument of the
event is the record deleted as an array.
Example
Delete detail records from the detail table after the master record is
deleted.
function Row_Deleted(&$rs) {
// Assume ForeignKeyField is of integer type
ew_Execute("DELETE FROM DetailTable WHERE
ForeignKeyField=" . $rs["PrimaryKeyField"]);
}
Row_Inserting
This event will be called after inserting a record. The arguments of the
event are the arrays of the old (if copying record) and new record just
inserted.
Example
Get the ID (autoincrement field) of the just inserted record
130
PHPMaker 12 Help
$this->setSuccessMessage("Record Inserted. The ID
of the new record is " . $rsnew["ID"]);
}
Row_Rendering
This event will be called before rendering (applying the View/Edit Tag
settings) a record.
Row_Rendered
var_dump($this->RowAttrs);
var_dump($this->Trademark);
var_dump($this->Trademark->CellAttrs);
var_dump($this->Trademark->EditAttrs);
var_dump($this->Trademark->ViewAttrs);
Example
Click "Cars" node on the database panel, select [Server
Events/Client Scripts], and click [Table Specific] - > [Common] > [Row_Rendered] server event. The default Row_Rendered event
code is shown. Change as follow:
function Row_Rendered() {
// Change the row color in List page by Bootstrap
classes
if ($this->Trademark->ViewValue == "BMW") // List
page only
$this->RowAttrs["class"] = "info";
// Change the table cell color
if ($this->PageID == "list" || $this->PageID ==
"view") { // List/View page only
if ($this->Cyl->CurrentValue == 4) {
$this->Cyl->CellAttrs["style"] =
"background-color: #ffcccc";
} elseif ($this->Cyl->CurrentValue == 6) {
$this->Cyl->CellAttrs["style"] =
"background-color: #ffcc99";
} elseif ($this->Cyl->CurrentValue == 8) {
$this->Cyl->CellAttrs["style"] =
"background-color: #ffccff";
}
}
131
PHPMaker 12 Help
// Change text style by Bootstrap classes
if ($this->Category->CurrentValue == "SPORTS")
$this->Category->ViewAttrs["class"] = "bgwarning text-warning";
}
Row_Selecting
This event will be called before selecting a record. The argument of the
event is the filter (part of the WHERE clause of the SQL) for selecting
the record, you can customize the filter to change the record to be
selected.
Row_Selected
This event will be called after selecting a record. The argument is the
record selected as an array.
Row_UpdateConflicThis event will be called if conflicts is found before updating a record (if
Check Conflicts is enabled, see Table Setup(See 1.10.6)). The
t
arguments of the event are the old record (as array) and new record
(as array) to be updated.
You can use this event to resolve the conflicts according to your own
criteria. If you want to ignore conflicts or you have resolved the
conflicts in the event (by setting new values to the argument rsnew)
and want to continue update, return FALSE. Otherwise, return TRUE.
By default the event returns TRUE.
Row_Updating
This event will be called after updating a record. The arguments of the
event are the arrays of the old and new record updated.
Example
After updating a field in detail table, update a field in the master table.
132
PHPMaker 12 Help
}
Grid_Inserting
For use with Grid-Add for a table and Master/Detail-Add for a detail
table, this event will be called before inserting records. This event has
no arguments.
You can use this event to check all records to be inserted. If you want
to cancel insert, return FALSE. Otherwise, return TRUE. By default the
event returns TRUE.
If you only need to check individual record, there is no need to
use this event, simply use Row_Inserting (see above) which will be
called for each row in the grid.
Note
Example
Check all records before inserting. Note that this event is called before
Row_Inserting, the field values are not loaded yet, but you can load
them yourself.
function Grid_Inserting() {
$rsnew = $this->GetGridFormValues(); // Get the
form values of the new records as an array of array
//var_dump($rsnew); die(); // Print the records
and end the script
$sum = 0;
foreach ($rsnew as $row) // Loop through the new
records
$sum += intval($row["Percentage"]);
if ($sum < 100) {
// To cancel, set return value to False
$this->setFailureMessage("The total of
percentages must be 100.");
return FALSE;
}
return TRUE;
}
Data returned from GetGridFormValues() is read only, do NOT
try to change the values. To change the values, use Row_Inserting
(see above) which will be called for each row in the grid.
Note
Grid_Inserted
For use with Grid-Add for a table and Master/Detail-Add for a detail
table, this event will be called after inserting all records. The argument
of the event ($rsnew) is array of records inserted (retrieved from
database).
For example, you can use this event to update a field in the master
table (similar to the example for Row_Updated above) after
Master/Detail-Add.
Grid_Updating
For use with Grid-Edit for a table and Master/Detail-Edit for a detail
table, this event will be called before updating records. The argument
of the event ($rsold) is array of records to be updated (retrieved from
database).
You can use this event to check all records to be updated. If you want
to cancel update, return FALSE. Otherwise, return TRUE. By default the
event returns TRUE.
133
PHPMaker 12 Help
If you only need to check individual record, there is no need to
use this event, simply use Row_Updating (see above) which will be
called for each row in the grid.
Note
Example
Check all records before updating. Note that this event is called before
Row_Updating, the field values are not loaded yet, but you can load
them yourself.
function Grid_Updating($rsold) {
$rsnew = $this->GetGridFormValues(); // Get the
form values of the new records as an array of array
//var_dump($rsnew); die(); // Print the records
and end the script
$oldtotal = 0;
foreach ($rsold as $row) // Loop through the old
records
$oldtotal += intval($row["Subtotal"]);
$newtotal = 0;
foreach ($rsnew as $row) // Loop through the new
records
$newtotal += intval($row["Subtotal"]);
if ($newtotal < $oldtotal) {
// To cancel, set return value to False
$this->setFailureMessage("The new total must
be larger than the old total.");
return FALSE;
}
return TRUE;
}
Note
For use with Grid-Edit for a table and Master/Detail-Edit for a detail
table, this event will be called after updating all records. The argument
of the event ($rsold and $rsnew) are array of records before and
after update (retrieved from database).
For example, you can use this event to update a field in the master
table (similar to the example for Row_Updated above) after
Master/Detail-Edit.
Email_Sending
This event is fired before the email notification is sent. You can
customize the email content using this event. Email_Sending event has
the following parameters:
Email - the email object instance which contain all the information
about the email to be sent. It is an instance of the cEmail class (see
below).
Args - an array which contains additional information.
If Add, the new record in the format of array can be access by
$Args["rsnew"]. If Copy, the old record in the format of array can be
access by $Args["rsold"]. If Edit/Update, the old data of the records in
the format of array can be access by $Args["rsold"], the new data of
134
PHPMaker 12 Help
the records in the format of array can be access by $Args["rsnew"]. If
Register, the new record in the format of array can be access by
$Args["rs"]. You can get a field value by, e.g.
$rsnew = $Args["rsnew"];
$MyValue = $rsnew["MyField"];
or
$MyValue = $Args["rsnew"]["MyField"];
Return FALSE in the event if you want to cancel the email sending.
If Grid-Add/Edit or Update page, there are more than one records, the
arguments are array of array.
Example
Assume there is an email field in the record, and you want to change
the recipient to the value of that field.
This event is fired before building the SQL for selecting records from
the lookup table. You can use this event to change the filters.
In the event, the SQL and filter for the lookup can be viewed by:
var_dump($this->LookupFilters);
The property LookupFilters is an array, the key values are:
Datebase ID
t<n>
The data type of the filter field. Do not change unless you
change the filter field in f<n>.
135
PHPMaker 12 Help
concatenate the filters by "AND".
Example 1
Add additional filter to the lookup table filter
For use with User ID security. (See Security Settings(See 1.10.4)) This
event is fired before adding the User ID filter to the WHERE clause of
the table. It is possible to modify, replace or add filter so the user can
access more or less records that he/she can access by its originally
loaded User IDs.
Example
Assume you have 2 User ID fields in the current table and in the user
table, and you want to filter by both User ID fields.
function UserID_Filtering(&$filter) {
ew_AddFilter($filter, "MyUserIDField2 = " .
CurrentUserInfo("MyUserIDField2InUserTable")); //
Assume the field is of integer type
}
Table-Specific -> Add/Copy page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
136
PHPMaker 12 Help
argument is the URL to be redirected to.
By default after inserting a record user is redirected back to the List
page. You can change that by using Return Page (see Table Setup(See
1.10.6)). However, If you want to change by code, you can also use
this event.
Message_Showing This event is fired before the message stored in the session variable is
shown.
The first argument $msg is the message to be shown, the second
argument $type is the type of the message, possible values of type
are: "" (empty string), "success", "failure", and "warning".
Example
Replace an error message by custom message
$rs = $this->GetFieldValues("FormValue");
An argument $CustomError is passed to the event, you can add your
error message and return FALSE if the form values do not pass your
validation.
Example
Make sure an integer field value meet a certain requirement
function Form_CustomValidate(&$CustomError) {
$rs = $this->GetFieldValues("FormValue"); // Get
the form values as array
if (intval($rs["Qty"]) % 10 <> 0) {
// Return error message in $CustomError
$CustomError = "Order quantity must be
multiples of 10.";
return FALSE;
}
return TRUE;
}
137
PHPMaker 12 Help
If you use this server event, make sure you have enabled serverside validation, see Validation in PHP Settings(See 1.10.2).
Note
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Page_Redirecting
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Page_Redirecting
138
PHPMaker 12 Help
Page_Load
print
html
excel
word
xml
csv
pdf
email
function Page_Load() {
$item = @$this->ExportOptions->Items["pdf"];
if ($item)
$item->Visible = FALSE;
}
Example 2
Add a custom link at the end of the export links
function Page_Load() {
$item = &$this->ExportOptions->Add("MyName");
$item->Body = "<a href='MyURL'>My Link</a>";
}
Example 3
Add a custom action to submit selected records by HTTP POST
function Page_Load() {
$this->CustomActions["star"] = "Add Star"; //
Where "star" is the id and "Add Star" is the caption
of the custom action
}
Adding a custom action by its name and caption is a actually a short
form of
139
PHPMaker 12 Help
"glyphicon glyphicon-star ewIcon")
$SubmitType is either EW_ACTION_POSTBACK (submit by HTTP
POST) or EW_ACTION_AJAX (submit by Ajax).
$SelectType is either EW_ACTION_MULTIPLE (submit the selected
records) or EW_ACTION_SINGLE (submit the current record only).
To process the action, you also need to write a handler with
Row_CustomAction server event (see below).
Note
Example 4
Add a custom action to submit selected records by Ajax
function Page_Load() {
$this->CustomActions["star"] = new
cListAction("star", "Add Star", IsLoggedIn(),
EW_ACTION_AJAX, EW_ACTION_MULTIPLE, "Add Star to
selected records?");
}
To process the action, you also need to write a handler with
Row_CustomAction server event (see below).
Note
Example 5
When Custom Templates (see Custom Templates(See 1.10.10)) is
used, they will be used for export to Word/Excel/PDF/Email (not
including PHPExcel and PHPWord) by default. You can however disable
it. The corresponding (boolean) page properties are:
ExportExcelCustom, ExportWordCustom, ExportPdfCustom and
ExportEmailCustom.
function Page_Load() {
$this->ExportExcelCustom = FALSE; // Disable using
Custom Templates for export to Excel
}
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content before the main table.
Example
Hide a field from the main table
function Page_DataRendering() {
$this->MyField->Visible = FALSE; // Hide a field
named "MyField"
}
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content after the main table.
140
PHPMaker 12 Help
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. See description of
ate
Form_CustomValidate for Add/Copy page above.
ListOptions_Load
This event will be called before the main table is rendered. Use this
event to modify the non data columns of the main table (i.e. the links
and the checkbox for each record). You can modify these columns or
add your own columns using this event. You can get a column by
name using $this->ListOptions->Item["name"].
The following predefined names are reserved, do not use them for
your own columns. These names are case-sensitive and are in
lowercase except for the detail table names.
Note
checkbox
view
copy
delete
edit
detail_<DetailTable> - Detail table column
details - the Multiple Master/Detail column
preview - column for preview row of the Detail Preview
extension (for registered users) only
sequence - column for sequence number
button - column for button group or button dropdown
Example 1
Add a new column.
function ListOptions_Load() {
$item = &$this->ListOptions->Add("new");
$item->Header = "MyCaption"; // Set the column
header (for List page)
$item->OnLeft = TRUE; // Link on left
$item->MoveTo(0); // Move the column to the
specified index
}
If you have enabled Use buttons as links and/or Use button
dropdown for links (see PHP Settings(See 1.10.2)), note that the
feature will hide the list options and try to move hyperlinks to the
button group or button dropdown. If your Body property (see below)
is not hyperlink(s), it cannot be shown in the button group or button
dropdown, you should remove your list option from the button group
or button dropdown by adding, e.g.
Note
$item->ShowInButtonGroup = FALSE;
and/or
141
PHPMaker 12 Help
$item->ShowInDropDown = FALSE;
Example 2
Hide the "view" column.
function ListOptions_Load() {
$this->ListOptions->Items["view"]->Visible =
FALSE;
}
Example 3
Hide a detail table named "MyDetailTable" in Preview Row or Overlay
(requires Detail Preview extension(See 1.7) which is for registered
users only)
function ListOptions_Load() {
$this->DetailPages->Items["MyDetailTable"]>Visible = FALSE;
}
ListOptions_Rende This event will be called before a record is rendered. Use this event to
modify content of the non data columns for the record. To access field
red
object of the current row, you can use $this-><Field>-
Example 1
Set the content of the new column dynamically based on a field value.
function ListOptions_Rendered() {
if ($this->MyField->CurrentValue == "xxx") {
$this->ListOptions->Items["new"]->Body =
"yyy";
} else {
$this->ListOptions->Items["new"]->Clear(); //
Set Body = ""
}
}
Example 2
Add a link to perform a custom action for the row by Ajax.
function ListOptions_Rendered() {
$this->ListOptions->Items["new"]->Body = "<a
href=\"#\" onclick=\"return ew_SubmitAction(event,
{action: 'star', method: 'ajax', msg: 'Add star?',
key: " . $this->KeyToJson() . "});\">Add Star</a>";
}
To process the action, you also need to write a handler with
Row_CustomAction server event (see below).
Note
142
PHPMaker 12 Help
Row_CustomAction If you have used Page_Load server event (see above) to add your
custom action to the List page, the page will show the checkbox
column for users to select records (similar to Multi-Update and MulitDelete). When user clicks the custom action link or button, the page
will post back to itself and this event will be fired (after Page_Load
and before Page_Render) for each selected row to process the
custom action.
Return TRUE to proceed to next record or return FALSE to abort
custom action.
Example
Update the status of the selected records, assuming the table has a
field named "Starred" for storing the status.
Page_Exporting
This event will be called before the page is exported. You can use this
event to add your additional code to the beginning of file to be
exported. Return FALSE to skip default export and use Row_Export
event (see below). Return TRUE to use default export and skip
Row_Export event. Check $this->Export for the export type (e.g.
"excel", "word"). The content of the export document is $this-
>ExportDoc->Text.
If Custom Templates is used (see Custom Templates(See
1.10.10)), this event may be overridden. You can disable using
Custom Templates for report, see example for Page_Load above.
Note
Example
143
PHPMaker 12 Help
Add a title to the export document and use custom export if export to
Excel
function Page_Exporting() {
if ($this->Export == "excel") {
$this->ExportDoc->Text = "<p>My Title</p>"; //
Add a title
return FALSE; // Return FALSE to skip default
export and use Row_Export event
}
return TRUE; // Return TRUE to use default export
and skip Row_Export event
}
Row_Export
function Row_Export($rs) {
if ($this->Export == "excel")
$this->ExportDoc->Text .= "<div>" . $this>MyField->ViewValue . "</div>"; // Build HTML with
field value: $rs["MyField"] or $this->MyField>ViewValue
}
Page_Exported
This event will be called after the page is exported. You can use this
event to add your additional code to the end of the file to be exported.
If Custom Templates is used (see Custom Templates(See
1.10.10)), this event may be overridden. You can disable using
Custom Templates for report, see example for Page_Load above.
Note
Example
Add a footer to the export document if export to Excel
function Page_Exported() {
if ($this->Export == "excel")
$this->ExportDoc->Text .= "my footer"; // Add
a footer
//die($this->ExportDoc->Text); // View the whole
export document for debugging
}
144
PHPMaker 12 Help
Table-Specific -> Multi-Update Page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. See description of
ate
Form_CustomValidate for Add/Copy page above.
Table-Specific -> Report Page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Table-Specific -> Search Page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
145
PHPMaker 12 Help
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. See description of
ate
Form_CustomValidate for Add/Copy page above.
Table-Specific -> View Page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Page_Exporting
This event will be called before the page is exported. You can use this
event to add your additional code to the beginning of file to be
exported. Return FALSE to skip default export and use Row_Export
event (see below). Return TRUE to use default export and skip
Row_Export event. Check $this->Export for the export type (e.g.
"excel", "word"). The content of the export document is $this-
>ExportDoc->Text.
If Custom Templates is used (see Custom Templates(See
1.10.10)), this event may be overridden. You can disable using
Custom Templates for report, see example for Page_Load above.
Note
146
PHPMaker 12 Help
Row_Export
Page_Exported
This event will be called after the page is exported. You can use this
event to add your additional code to the end of the file to be exported.
If Custom Templates is used (see Custom Templates(See
1.10.10)), this event may be overridden. You can disable using
Custom Templates for report, see example for Page_Load above.
Note
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called before the page content is outputted. You can
ng
use this event to add content at the top of page content.
Page_DataRendere This event will be called after the page content is outputted. You can
d
use this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Other -> Default Page
Page_Load
Page_Unload
Page_Redirecting
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
147
PHPMaker 12 Help
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
User_LoggingIn
This event will be called before validating the username and password.
User_LoggedIn
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. Inspect the HTML source of
ate
the page in your browser to view the form element names.
An argument $CustomError is passed to the event, you can add your
error message and return FALSE if the form values do not pass your
validation.
User_LoginError
Page_Unload
Page_Redirecting
User_LoggingOut
User_LoggedOut
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
148
PHPMaker 12 Help
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Email_Sending
This event is fired before the email notification is sent. You can
customize the email content using this event. Email_Sending event has
the following parameters:
Email - the email object instance which contain all the information
about the email to be sent. It is an instance of the cEmail class (see
below).
Args - an array which contains additional information. For registration
page, the new record in the data type of a recordset can be accessed
by $Args["rs"].
Return FALSE in the event if you want to cancel the email sending.
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. See description of
ate
Form_CustomValidate for Add/Copy page above.
User_Registered
User_Activated
This event is fired after activating a new user (if user activation is
required, see Security Settings(See 1.10.4)). Argument is a recordset
of the new record in the user table.
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
149
PHPMaker 12 Help
argument is the URL to be redirected to.
By default user is redirected to the default page (e.g. index.php) after
successful login. You can change that by using this event.
Email_Sending
This event is fired before the email notification is sent. You can
customize the email content using this event. Email_Sending event has
the following parameters:
Email - the email object instance which contain all the information
about the email to be sent. It is an instance of the cEmail class (see
below).
Args - an array containing additional information. For Change
Password page, the old data of the records in the data type of
recordset can be accessed by $Args["rsold"], the new data of the
records in the data type of recordset can be accessed by
$Args["rsnew"].
Return FALSE in the event if you want to cancel the email sending.
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. Inspect the HTML source of
ate
the page in your browser to view the form element names.
An argument $CustomError is passed to the event, you can add your
error message and return FALSE if the form values do not pass your
validation.
Other -> Password Recovery Page
Page_Load
Page_Render
This event will be called before outputting HTML for the page. You can
use this event to make some last minute changes to the page before it
is outputted.
Page_Unload
Page_DataRenderi This event will be called after the header.php is included. You can use
ng
this event to add content at the top of page content.
Page_DataRendere This event will be called before the footer.php is included. You can use
d
this event to add content at the bottom of page content.
Page_Redirecting
Email_Sending
This event is fired before the email notification is sent. You can
customize the email content using this event. Email_Sending event has
the following parameters:
150
PHPMaker 12 Help
Email - the email object instance which contain all the information
about the email to be sent. It is an instance of the cEmail class (see
below).
Args - an array containing additional information. For Password
Recovery Page, the old data of the records in the data type of
recordset can be accessed by $Args["rs"].
Return FALSE in the event if you want to cancel the email sending.
Message_Showing This event is fired before the message stored in the session variable is
shown. You can use this event to change the message which is passed
to the event as argument.
Form_CustomValid This event is fired after the normal form validation. You can use this
event to do your own custom validation. Inspect the HTML source of
ate
the page in your browser to view the form element names.
An argument $CustomError is passed to the event, you can add your
error message and return FALSE if the form values do not pass your
validation.
User_RecoverPass This event is fired after the password is recovered. Argument is a
word
recordset of the user's record in the user table.
Client Scripts
In general, each page has two blocks of JavaScript:
Client Script - the first block of JavaScript to be included at the beginning of the page, you
can put your JavaScript variables and functions there. The View Tag (for display) and Edit
Tag (for input) of the fields supports Custom Attributes (See Field Setup(See 1.10.7)) so you
can add your own attributes to work with your own JavaScript included here.
Startup Script - the second block of JavaScript to be included at the end of the page, you
can put code here to "start up" your JavaScript.
In the following table, the <fieldname> in code represents the field variable name. In
general, if the field name is alphanumeric, field variable name is same as the field name.
Otherwise, spaces are replaced by underscores, and other non alphanumeric characters are
replaced by their hexadecimal string representation of their unicode value. If the variable is
a reserved word or starts with a digit, it will be prepended with an underscore. If in doubt,
always inspect HTML source in your browser to check the actual id, name, and
other attributes of the elements.
Note
The script will be placed in the header and therefore included in all
pages with header.
This event is NOT related to the No header/footer setting in
the Generate form (see Generate Settings(See 1.10.5)). Even if No
header/footer is enabled, this event will also be fired.
Note
Startup Script
The script will be placed in the footer and therefore included in all
pages with footer. This is a very useful event which is fired for all
151
PHPMaker 12 Help
pages with footer, you can almost do everything by changing the
document DOM of those pages.
This event is NOT related to the No header/footer setting in
the Generate form (see Generate Settings(See 1.10.5)). Even if No
header/footer is enabled, this event will also be fired.
Note
Example
Use jQuery to replace the logo
$("#ewHeaderRow").html('<img src="path/mylogo.png"
alt="xxx">');
Global Code
The script will be placed after the header. This may contain your
JavaScript variables and functions for the page. You can also use
this event to subscribe JavaScript events.
Example 1
Set Multi-Page (see Table Setup)(See 1.10.6) properties
CurrentForm.MultiPage.Set({
//LastPageSubmit: true, // Enable submit button
for the last page only
//HideDisabledButton: true, // Hide disabled
submit button
//HideInactivePages: true, // Hide inactive
pages
//HideTabs: true, // Hide all tabs
//ShowPagerBottom: true, // Show pager at
bottom
//PagerTemplate: '<nav><ul class="pager"><li
class="previous ewPrev"><a href="#"><span
class="icon-prev"></span> {Prev}</a></li><li
class="next ewNext"><a href="#">{Next} <span
class="icon-next"></span></a></li></ul></nav>' //
Pager template
LockTabs: true,// Set inactive tabs as disabled
ShowPagerTop: true // Show pager at top
});
Note: The argument of the Set() method is a JavaScript object, if
you modify above example, make sure that the syntax is correct
and that the last property value does not have a trailing comma.
Example 2
Subscribe the jQuery ajaxSend event before an Ajax request is sent
(e.g. "updateoption", "autosuggest", "autofill")
$(document).ajaxSend(function(event, jqxhr,
settings) {
var data = settings.data;
//console.log(data); // Uncomment to view data
in browser console
152
PHPMaker 12 Help
if (ew_Get("ajax", data) == "updateoption" &&
ew_Get("name", data) == "x_MyField") // Ajax
selection list
settings.data = data.replace("xxx", "yyy");
// Replace data with custom data
});
Example 3
Subscribe the "updatedone" event for Dynamic Selection Lists(See
1.15.5). The event fires after options of a child field is updated.
The script will be placed before the footer. This is a very useful
event which you can almost do everything by changing the
document DOM.
PHPMaker provides a jQuery plugin .fields() for you to easily
get/set the form values in client side events such as Startup Script
and Form_CustomValidate (see below)
153
PHPMaker 12 Help
$field = $(this).fields("<fieldname>"); // return
jQuery object of the input element(s) of a field
The jQuery object of the field is the jQuery object of the input
element of the field. (Note that if Edit Tag of the field is CHECKBOX
or RADIO, the jQuery object may contain more than one elements.)
For example, if the page is an Edit page and the field is named
"Field1" and it is a textbox, $(this).fields("Field1") is
equivalent to $("#x_Field1"). The advantages of using
.visible([value])
.row()
1. If Add/Edit page, the row is the <tr> or
the <div> of the field.
2. If Grid page, the row is the <tr> of the
record.
.toNumber()
154
PHPMaker 12 Help
default the input value is string).
.toDate()
.toJsDate()
Example 1
Add onchange event to the field named "Field1" in Add/Edit page
to change other fields by jQuery plugin .fields()
$("input[name='x_Field1']").change(function() { //
Assume Field1 is a text input
if (this.value == "xxx") {
$(this).fields("FieldA").value("yyy"); //
Set value to FieldA
} else {
$(this).fields("FieldB").value("zzz"); //
Set value to FieldB
}
});
Example 2
Add onclick event to the field named "Field2" which uses
CHECKBOX as Edit Tag.
$("input[name='x_Field2[]']").click(function() { //
Field2 has multiple inputs (checkboxes) so they
should be selected by name
if (this.checked) { // If checked
// Do something
} else { // Not checked
// Do something else
}
});
Example 3
Add onchange event to the field named "Field1" in Grid-Add/Edit
page to change other fields by jQuery plugin .fields()
$("input[data-field='x_Field3']").change(function()
{ // Field1 has multiple inputs in Grid-Add/Edit so
they should be selected by data-field attribute
if (this.value == "xxx") {
$(this).fields("FieldA").value("yyy"); //
Set value to FieldA in the same row
} else {
$(this).fields("FieldB").value("zzz"); //
Set value to FieldB in the same row
}
});
Example 4
155
PHPMaker 12 Help
Toggle visibility of a page in Multi-Page (see Table Setup)(See
1.10.6)
$(function() {
CurrentForm.MultiPage.TogglePage(2, false); //
Hide the 2nd page
});
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. Note: This function is a
member of the JavaScript page class.
Return false if the form values do not pass your validation.
If you use this client side event, make sure you have enabled
client-side validation, see Validation in PHP Settings(See 1.10.2).
Note
The HTML form object can be accessed by the parameter fobj. You
can also use the jQuery plugin .fields() in this event.
Example 1
Make sure an integer field value meet a certain requirement
156
PHPMaker 12 Help
must be at least 7 days after the Start Date."); //
Return false if invalid
return true; // Return true if valid
}
Table-Specific -> Delete Page
Client Script
Startup Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Table-Specific -> List Page
Client Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. Return false if the form
values do not pass your validation.
The form object can be accessed by the parameter fobj.
Note that the form element names are different in InlineAdd/Copy/Edit or Grid-Add/Edit mode of List page. They are named
as "x0_<fieldname>" in Inline-Add/Copy, as "x1_<fieldname>" in
Inline-Edit mode, and as "x1_<fieldname>", "x2_<fieldname>",
etc. in Grid-Add/Edit since there are multiple rows. Inspect the
elements in your browser to check the actual form element names.
Form_CustomValidate is fired for EVERY row in the grid. You
can also use the jQuery plugin .fields() (see above) to
manipulate the fields, but remember that the plugin return field(s)
of the CURRENT row only. If you need to access fields in other rows,
either use fobj.elements or jQuery with CSS selectors.
Note
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Table-Specific -> Report Page
157
PHPMaker 12 Help
Client Script
Startup Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Table-Specific -> View Page
Client Script
Startup Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Other -> Registration Page
Client Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Other -> Change Password Page
Client Script
Startup Script
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
Other -> Password Recovery Page
Client Script
Startup Script
158
PHPMaker 12 Help
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return false if the form values do
not pass your validation.
It is recommended that you develop your server event and client scripts in the
generated script so you can edit and test it immediately. When you finish your custom
script, copy it to PHPMaker custom script editor and save it.
Note
159
PHPMaker 12 Help
the List page. Please refer to the class "cListOptions" in the generated file "phpfn*.php" for
the complete list of methods and properties.
ExportOpions Object
The ExportOptions object contains all information of the export links in the List page. It is
also an instance of the class "cListOptions". Please refer to the class "cListOptions" in the
generated file "phpfn*.php" for the complete list of methods and properties.
Language Object
The language Object lets you retrieve a phrase of the active language during runtime. The
phrase can be retrieved in the generated scripts using methods such as Phrase, TablePhrase
and FieldPhrase. Please refer to the class "cLanguage" in the generated file "ewshared*.php"
for the complete list of methods and properties.
Breadcrumb Object
The Breadcrumb object contains all information of the breadcrumb at the top of page. Please
refer to the class "cBreadcrumb" in the generated file "phpfn*.php" for the complete list of
methods and properties.
There are other objects in the generated code, please refer to the source code of the file
"phpfn*.php" and "ewshared*.php" in template or generated scripts.
Description
Example
Conn([$dbname])
If $dbname is
not specified, it
returns the
$rs = Conn("MyDbName")connection object >Execute("SELECT ...");
for the database // execute a SELECT
of the project. If statement and get
$dbname is
recordset object
specified, it
160
PHPMaker 12 Help
returns the
connection object
for the specified
database of a
Linked Table.
Security()
Language()
if (Security()>CanEdit()) { // check
if current user has Edit
permission for the
current table (for use
with User Level Security
...your code...
}
CurrentUserID()
$userid =
For used with
User ID Security CurrentUserID();
(see Security
Settings(See
1.10.4)). Get
current User ID.
CurrentUserLevel()
$levelid =
For used with
CurrentUserLevel();
User Level
Security (see
Security
Settings(See
1.10.4)). Get
current user's
User Level ID
(integer). (Note:
NOT current
user's permission
as integer.)
CurrentUserInfo($fieldname)
$email =
For used with
Advanced
CurrentUserInfo("email")
Security (see
;
Security
Settings(See
1.10.4)). Get
current user's
info from the
user table. The
argument is the
field name in the
161
PHPMaker 12 Help
user table.
CurrentPageID()
CurrentPage()
CurrentLanguageID()
Get current
language ID.
Page([$tablename])
$langid =
CurrentLanguageID();
CurrentPage()
.
IsLoggedIn()
if (IsLoggedIn()) {
For used with
Advanced
...your code...
Security (see
}
Security
Settings(See
1.10.4)). Get the
login status of
the current user.
IsAdmin()
if (IsAdmin()) {
For used with
Advanced
...your code...
Security (see
}
Security
Settings(See
1.10.4)). Check
if the current
user is an
administrator.
ew_Execute($sql [,$dbname])
ew_ExecuteRow($sql [,$dbname])
Set $row =
Executes the
ew_ExecuteRow("SELECT *
query, and
returns the first
162
PHPMaker 12 Help
FROM MyTable WHERE...");
row as a
dictionaru object.
ew_ExecuteScalar($sql
[,$dbname])
Executes the
query, and
returns the first
column of the
first row.
DbHelper([$dbname])
$db = DbHelper();
Get database
helper object of a
databse (also see
Custom Files(See
1.10.13)).
$value =
ew_ExecuteScalar("SELECT
MyField FROM MyTable
WHERE...");
There are many other useful functions in the generated code, please refer to the source code
of the file "phpfn*.php" and "ewshared*.php" in template or generated scripts.
Custom Templates
By default fields are presented in tabular form, e.g. one field per row in
Add/Edit/Search/View page, or one record per row in List/Delete page. Custom Templates
enable you to re-arrange the fields in your own way.
Do not confuse Custom Template (which is a table level setting within a project) with
customizing the whole template zip file. If you want to customize the general layout of the
generated site or customize something for all tables and all projects, you should customize
the template zip file, see Customizing Template(See 1.14).
Note
How it Works
If a Custom Template is provided, PHPMaker splits the original code in many small client side
templates. A client side template is HTML code enclosed by <script type="text/html"> and
</script>. Since browsers do not know how to execute "text/html" scripts, they simply
ignore it. So it is possible to re-assemble HTML from the small client side templates by
JavaScript based on your provided Custom Template. In other words, it is simply rearrangement of existing HTML parts in browser.
During script generation, PHPMaker converts your Custom Template to a client side template
and outputs JavaScript to render the template. The client side template is rendered by
JsRender (see Third-Party Tools(See 1.7)) which is a third-party JavaScript template engine
optimized for high-performance pure string-based rendering. The generated scripts only use
its "template composition" feature to render HTML from other external templates, your
Custom Template can however make use of its other features if you need to. (Note that
JsRender is still in beta, if you use its features directly, be aware that there may be some
breaking changes in the future.)
163
PHPMaker 12 Help
What it Can Do (and Cannot Do)
Custom Templates let you customize the layout of the fields originally placed in the main
HTML table of the page, they cannot customize HTML outside those regions. The
customizable regions are highlighted as follows:
164
PHPMaker 12 Help
{{{field}}}
List/Delete page
CustomTemplateHeader - field caption
(supports sorting)
CustomTemplateBody - field value only
CustomTemplateFooter - field aggregate value
165
PHPMaker 12 Help
{{{caption field}}}
Field caption
{{{header field}}}
{{{value field}}}}
{{{value2 field}}}}
{{{operator field}}}}
{{{operator2 field}}}}
{{{condition field}}}}
{{{cell_attrs field}}}}
{{{list_options}}} or
{{{list_options n}}}
{{{list_options_2}}}
{{{list_option xxx}}}
copy
delete
edit
checkbox
preview - for use with Preview extension (for
registered users) only, or
detail_<DetailTable> - NOT for use with
Preview extension (for registered users)
166
PHPMaker 12 Help
single page.
{{{row_attrs}}}
{{{row_cnt}}}
{{{confirm_password}}}
How to Use
To enter your Custom Template for a table, follow the following steps:
1. Select the table in the database pane,
2. Select the Code tab (which contains Server Events, Client Scripts and Custom
Templates),
3. Scroll down the treeview or collapse the Server Events and Client Scripts node,
select a template node under Custom Templates,
4. Enter your Custom Template in the editor.
You can enter the first character of a field name and then press Ctrl + Space to
open the completion list of the editor and select a {{{field}}} tag.
Note
Then just generate and run your scripts in your browser as usual.
167
PHPMaker 12 Help
Examples
Example 1 - Custom Template in Add/Edit/Search/View page or Extended Search in List
page
{{{Trademark}}} {{{Model}}}<br>
{{{HP}}} {{{Liter}}}
If you want to have more control on the layout, use DIV and SPAN with CSS styles, e.g.
<table class="ewTable">
<tbody>
<tr><td>{{{Trademark}}}</td><td>{{{Model}}}</td></tr>
<tr><td>{{{HP}}}</td><td>{{{Liter}}}</td></tr>
</tbody>
</table>
Example 2 - Custom Template in Add/Edit/Search/View page (Multi-Page)
{{{page_1}}}
<div class="ewRow"><span class="ewCell">{{{Trademark}}}</span><span
class="ewCell">{{{Model}}}</span></div>
<div class="ewRow"><span class="ewCell">{{{HP}}}</span><span
class="ewCell">{{{Liter}}}</span></div>
{{{/page_1}}}
{{{page_2}}}
<div class="ewRow">{{{Description}}}</div>
{{{/page_2}}}
{{{page_3}}}
<div class="ewRow">{{{Picture}}}</div>
{{{/page_3}}}
<table class="ewTable">
<tbody>
CustomTemplateBody
<tr{{{row_attrs}}}>
<td>
<div class="ewRow">
<span class="ewCell"><b>{{{caption
Trademark}}}:</b> {{{Trademark}}}</span>
168
PHPMaker 12 Help
<span class="ewCell"><b>{{{caption
Model}}}:</b> {{{Model}}}</span>
</div>
<div class="ewRow">
<span class="ewCell"><b>{{{caption
HP}}}:</b> {{{HP}}}</span>
<span class="ewCell"><b>{{{caption
Liter}}}:</b> {{{Liter}}}</span>
</div>
<div class="ewRow">{{{list_options_2}}}</div>
</td>
</tr>
CustomTemplateFooter
</tbody>
</table>
Example 4 - Show each record in 2 rows in List page using {{{list_options n}}}
where n is the rowspan. Note: Do not confuse {{{list_options 2}}} with
{{{list_options_2}}}.
CustomTemplateHeader
<tr{{{row_attrs}}}>
{{{list_options 2}}}<td>{{{Trademark}}}</td><td>{{{Model}}}</td>
</tr>
<tr{{{row_attrs}}}>
<td>{{{HP}}}</td><td>{{{Liter}}}</td>
</tr>
CustomTemplateFooter
</tbody>
</table>
Important
169
PHPMaker 12 Help
table by Custom Template, it will NOT work without writing your own code. In
Add/Copy/Edit page, if a field is missing, no field value is submitted but the
generated scripts contain code for the field, unwanted results may occur, for
example, if a field is missing in the Edit page, the field value in the table will be
cleared after editing. If Multi-Page (see Table Setup(See 1.10.6)) is enabled for the
page, the Custom Templates should include templates for all pages using
{{{page_n}}} and {{{/page_n}}}, and each field should be placed in the same
page as in the original script.
2. Custom Template is HTML, if you want to embed PHP code, you need to use <?php
and ?> to enclose your code, if you want to use JavaScript, you need to use
<script type="text/javascript"> and </script>.
3. DO NOT use $this in your PHP code. There is no $this in the context, you can
however use CurrentPage() to get the current page object.
4. Avoid using JavaScript in the template. If you need to use JavaScript, try to put your
JavaScripts in Client Scripts and Startup Scripts of the page (see Server Events and
Client Scripts(See 1.10.9)). If you have to use JavaScript in the template, DO NOT
using document.write() because the script will be extracted from the template
and be executed at the end of the template, you can however use a DIV with unique
id and write to its innerHTML.
5. In List page, CustomTemplateBody is the template for a record. Your Custom
Template needs NOT to be a HTML table, but if it is (see the example above), then
CustomTemplateHeader and CustomTemplateFooter must at least contains
<table><tbody> and </tbody></table> respectively, and you need to provide
the <tr> and <td> tags in these templates. If the table uses Aggregate values
(see Field Setup(See 1.10.7)), you should also include <tfoot> in your
CustomTemplateFooter. If you want to use the PreviewRow extension (for
registered users only), your Custom Template must be a HTML table because the
extensions works by inserting a preview row in the table, and in
CustomTemplateBody each <tr> row must contain the attribute datarowindex="{{{row_cnt}}}" or {{{row_attrs}}} as the extension needs the
row index for inserting a row below it. The row index attribute is also required for
alternating/selected/highlighted row colors. Basic sample code of
CustomTemplateHeader/Body/Footer can be found in Code Repository (below
the editor).
6. Before the Custom Template is applied, the jQuery event "rendertemplate" will be
fired, you can use Client Script of the page (see Server Events and Client
Scripts(See 1.10.9)) to subscribe this event and pass custom data to the Custom
Template or even disable it.
7. Custom Template does NOT support the following:
o Export to CSV/HTML/PHPExcel/PHPWord/XML (the data is exported in
original tabular format)
o Add Blank Row in Grid-Add/Edit
o Detail grid in Master/Detail-Add/Edit/View
8. Custom Template supports Printer-Friendly/Export to Excel/Word/Email. Note
that Export to Excel/Word works by letting Word/Excel to import the exported
HTML, so make sure your Custom Template is simple enough for Word/Excel to
import. As for Export to Email, the exported HTML will be rendered by email
clients. Different email clients render HTML email content differently, the result may
vary with email client. In general, keep your Custom Template simple and stupid for
export. You can even use PHP's if/elseif/else to output different Custom
Template according to the value of CurrentPage()->Export. Also, Custom
Template will override Page_Loading, Row_Export and Page_Exported server
events, you can however use Page_Load server event to disable using Custom
Template for export, see Server Events and Client Scripts(See 1.10.9).
170
PHPMaker 12 Help
171
PHPMaker 12 Help
PHPMaker will give the new Custom View a temporary name, CustomView<n>, where n is
an integer. If you want to change the name, enter a new name in the [Custom View
name] edit box in the main toolbar.
It is recommended that the built-in visual query builder be used to build your SQL. The
query builder interface is intuitive and fully supports drag-n-drop, in most cases you don't
need to type the table or field names.
On the left hand side, the available tables are displayed in the table pane. On the right hand
side, there are three tabs: [Builder], [SQL] and [Result]. (The [Result] tab will only be
visible after you execute the SQL.)
Builder
To build your SQL, drag your tables from the table pane on the left to the builder area and
check the required fields.
To create a link between two objects (i.e. join them) you should select the field by which
you want to link an object with another and drag it to the corresponding field of another
object. After you finish dragging, a line will appear between the linked fields. The join type
created by default is INNER JOIN, i.e. only matching records of both tables will be included
in resulting dataset. To define other types of joins you should right click the link and select
the Edit... item from the drop down menu or simply double-click it to open the Link
Properties dialog. This dialog allows you to define join type and other link properties.
The easiest way to add a field to the list of query output fields is to check the checkbox at
the left of field name in the Query Building Area. To include all the fields of an object you
should click the checkbox at the left of the asterisk item of an object.
Note
You should select your fields explicitly, not using the * symbol.
172
PHPMaker 12 Help
Another way is to select a field name from the drop-down list of the Expression column in
the Columns Pane. And the most common way is to write any valid expression to the
Expression column in the Columns Pane.
To remove a field from the list of query output fields you should uncheck the checkbox at
the left of field name in the Query Building Area or you may remove it by unchecking the
Output column checkbox. Such operations as removing lines from the Columns Pane or reordering output fields are available by right clicking on the left-most gray column via the
drop-down menu.
To define sorting of output query fields you should use the Sort Type and Sort Order
columns of the Columns Pane.
The Sort Type column allows you to specify how the fields will be sorted - in Ascending or
Descending order.
The Sort Order column allows you to setup the order in which fields will be sorted, if there
are more than one field to sort specified.
To cancel sorting by some field you should clear the Sort Type column for this field.
To define criteria for the expression listed in the Columns Pane you must use the Criteria
column.
Here you should write the criteria omitting the expression itself. For get the following criteria
in your query
"Expression" and "Where": These values are used when no grouping is specified.
The "Expression" value is set when this expression is used as output expression in
the SELECT clause and nothing else. The "Where" value is set automatically when
you define a criteria to this expression that results in including this expression to the
WHERE clause. Normally you shouldn't care about value of the Group By column
when you don't want to define grouping.
"Group by" and "Having": These values are similar to the previous two, but used
when you want to define grouping in your query. In this case you should set the
"Group by" value for all columns you want to group by. Specifying criteria for the
grouped columns will include these criteria in the HAVING clause. If you want to
include an expression ONLY in the HAVING clause you should set the "Having" value
in the Group By column for this expression.
Aggregate functions (Count, Sum, etc): By selecting one of these values you will
create an aggregate expression for the value indicated in the Expression column.
173
PHPMaker 12 Help
SQL
You can always click the [SQL] tab to check the SQL generated by the query builder, the
SQL editor is also syntax-highlighted to enhance the readability of the SQL.
The SQL tab is actually an SQL editor, you can type your SQL directly without using the
query builder here, or paste your SQL from elsewhere, or open a saved SQL script (*.sql)
from file.
Notes
1. If the SQL is not generated by the built-in query builder, there are chances that
query builder cannot parse the SQL and display it visually in the [Builder] tab.
However, this does not necessarily mean that the SQL is invalid, you can verify its
validity by executing it (see below) and check if it returns the data you want in the
[Result] tab. And you can create the Custom View directly by click the OK button
without switching to the [Builder] tab.
2. If you type your SQL directly, always use aliases (use "AS") for fields whenever
applicable. Otherwise, the alias will be assigned by the database and you will not be
able to refer to the field with a known and meaningful name.
Result
When you have finished your SQL, you can test the SQL by any one of the following ways:
(for "DIRECT" connection only)
Clicking the
[Execute] button in the toolbar
Pressing [F9] on your keyboard
Clicking [Query] in the menu and then [Execute]
174
PHPMaker 12 Help
The [Result] tab will become visible and display the result data. If the data is correct, the
Custom View setup is almost done.
Note: Executing the SQL is for testing the SQL only. The data displayed in the [Result] tab
will not show the memo fields and blob fields, they may be represented by "(MEMO)" and
"(BLOB)" only. This is not related to the data that will be displayed by the generated scripts.
Since a Custom View is based on an existing table, there is an option that the fields in the
Custom View use the same Field Setup(See 1.10.7) (Edit Tags, View Tags, etc.) as the
source table. If you want to copy field settings, check the checkbox [Copy field settings
from source table (when applicable)]; if not, uncheck it. Then you can press [OK] to
finish.
Note: "when applicable" means that if enabled, field settings will be copied from the
source table when a new Custom View is created, or when a new field is found after editing
a Custom View, and the field can be found from existing tables. (This is also why building a
SQL with the built-in query builder and not using * symbol are recommended, these ensure
that the SQL can be parsed and therefore the source table and source field can be found.)
When a Custom View is added, PHPMaker will load it and display it in the database pane and
Table Setup page under the [Custom Views] node. To view the SELECT statement of the
Custom View, right click the Custom View in database pane and select [Object
Properties]. Alternatively, you can select the Custom View first, then click [Project] in the
main menu and then select [Object Properties].
To edit a custom view, right click the Custom View in the database pane and select [Edit
Custom View]. Alternatively, you can select the Custom View first, then click [Edit] in the
main menu and then select [Edit Custom View].
When a Custom View is added or edited, PHPMaker will check the SQL. If the SQL is invalid,
the icon of the Custom View will have a cross on it like
, you can view the error in the
[Object Properties] window and then edit the Custom View to correct the SQL.
Important
175
PHPMaker 12 Help
1. After a Custom View is created, it works independently from the table(s) it based on.
Changing the structure of the source table(s) does not change the Custom View. If
you delete a field in the source table that is used by a Custom View, the Custom
View will fail. You should edit the Custom View to update the SELECT statement.
Also, a Custom View has its own field settings, changing field settings in the source
table does not change the field settings in related Custom Views.
2. During searching, sorting and grouping, PHPMaker generated codes need to change
the WHERE and/or ORDER BY clause of SQL for the list page dynamically. For
Custom Views, since there might be fields with aliases, it is necessary to use the
actual expressions of the aliases in order to ensure the result SQL works. For
example, if you have a field, "UnitPrice*12 AS TotalPrice" in your SQL, you cannot
sort using "ORDER BY TotalPrice", you need to use "ORDER BY UnitPrice*12".
Therefore, if your Custom View contain fields with aliases, it is important that the
SQL can be parsed correctly by PHPMaker. To make sure that, here are the recaps:
a. It is recommended that the built-in visual query builder be used to build
your SQL.
b. You should select your fields explicitly, not using the * symbol.
c. If you type your SQL directly, always use aliases (use "AS") for fields
whenever applicable.
176
PHPMaker 12 Help
The Report Setup window has 4 tabs. Go through these tabs one by one to setup your
report.
General
PHPMaker will give the new Report a temporary name, Report<n>, where n is an integer. If
you want to change the name, enter a new name in the [Report name] edit box. Then you
can select a table, or a view, or a Custom View form the [Table or View] combobox.
The field in the table will be displayed in the [Available fields] listbox, select fields you
want to display by moving them to the [Selected fields] listbox. It is recommended that
you select only the fields you required or the report page may be too wide to view without
scrolling.
This settings in this tab are mandatory.
Grouping Levels
177
PHPMaker 12 Help
You can optionally add up to 6 grouping levels in either ascending or descending order and
choose to show summary for each level. Select the grouping field for each level in the
comboboxes and click the button next to the comboboxes to choose the sorting order. To
enable summary, check [Show Summary] next to the grouping fields. When any of the
[Show Summary] fields is selected, the [Summary Values] tab will appear for you to
setup the summary values later. (See below)
Sort Order
178
PHPMaker 12 Help
You can optionally sort records by up to 6 fields, in either ascending or descending order.
Select the sorting fields in the comboboxes. Press the button to change the sort order.
Summary Values
179
PHPMaker 12 Help
If any of the [Show Summary] checkboxes is selected in the [Grouping Levels] tab, this
tab will become visible. You can optionally select aggregate values for each selected numeric
field. Available summary values are [Sum], [Avg], [Min] and [Max]. These summary
values will be shown at the end of the grouping levels with [Show Summary] enabled.
In this tab, you can also choose to show [Detail and Summary] or [Summary only] for
your report. If [Detail and Summary] is selected, records belonged to each grouping level
will be displayed under the grouping level title, then followed by the summary. [Detail and
Summary] is the default.
Finally, you can choose to [Show grand summary] for all records at the end of the report.
This options is enabled by default.
Press [OK] to finish setup. When a report is created, the field settings will be copied from
the source table. But from then on, the Report has its own field settings and is much like
other table in PHPMaker.
To edit a Report, right click the Report in the database pane and select [Edit Report].
Alternatively, you can select the Report first, then click [Edit] in the main menu and then
select [Edit Report]. Note that the source table of a report cannot be changed.
Important
1. After a report is created, a report works independently from the source table it
based on. Changing the structure of the source table does not change the report. If
you delete a field in the source table that is used by a report, the report will fail.
Similarly, if the report is based on a Custom View and you change the SELECT
180
PHPMaker 12 Help
statement of the Custom View, the report may fail if a field in the report is missing.
However, in the latter case, when a Custom View is edited, PHPMaker will check the
validity of the SQL. If the SQL fails, both the Custom View and reports that based on
the Custom View will be displayed with a cross in the icon, like
and
. Also, a
Report has its own field settings, changing field settings in the source table does not
change the field settings in related Reports.
2. Report does not support exporting to CSV, XML or PDF. You should export from the
source table.
3. Report does not include BLOB fields or fields that use file upload.
4. Report is not updatable or searchable, but it supports User ID and User Level. (See
Security(See 1.10.4))
Also See:
Custom View(See 1.10.11)
Security(See 1.10.4)
Custom Files
Custom Files enables you to add your own files to the project. Basically, a custom file is a
blank page with the layout of the project for you to add your own content so it will have a
consistent look and feel like other generated files.
How to Use
To create a Custom File, simply right click the database pane or click Edit in the main menu,
then select Add File, the following form will show:
181
PHPMaker 12 Help
File name with extension.
Notes
File Name
Caption
Destination folder:
C:\Users\Administrator\Documents\mycompany.co
m\project1
and you want to generate your Custom File in the
destination folder, you should enter "project1/" (no
quotes).
Do NOT use parent path ".." or the file will be
generated outside the application root leading to
some unexpected results.
Note
After entering above properties, click OK button to save. The Custom File will show up in the
database pane under the Custom Files node:
182
PHPMaker 12 Help
To edit the Custom File properties, right click the Custom File in the database pane and
select Edit File.
To delete a Custom File, right click the Custom File in the database pane and select Delete
File.
To enter content for the file, select the Custom File in the database pane , then select the
Code tab (which contains Server Events, Client Scripts and Custom Templates) in the
right pane.
Scroll down the treeview or collapse the Server Events and Client Scripts node, select the
Custom Templates -> Table-Specific -> Custom File -> Content node, then you can
enter or paste your content in the editor:
183
PHPMaker 12 Help
Then just save your project generate and run your scripts in your browser as usual.
Although it is convenient to save your own files in the project, you should avoid
saving all the contents in the project or the project will become so large that the
performance of the UI will be affected. If the file content is large, you can put the content in
an external file and then include it in the Custom File. If the number of files is large, put the
minimum number of files in the project by Custom Files only, you can generate a blank
Custom File and duplicate it as containers for other files, then just add menu items to the
project by the Menu Editor for those external files.
Important
Examples
Example 1 - Include an external file instead of saving the page content in the project.
184
PHPMaker 12 Help
Example 3 - Add multiple Bootstrap Panels in the page as a dashboard page. Use database
helper to execute SQLs and display data as HTML table.
To use the database helper, click Tools -> Advanced Settings (see Tools(See 1.13))
and enable Generate database helper and make sure you generate the file named
ewdbhelper<version>.php. The database helper is generated in the destination folder of the
project. If Includes common files is enabled, it is auto-loaded so there is no need to
explicitly include the script.
Note
<?php
$db =& DbHelper(); // Create instance of the database helper class
by DbHelper() or by name c<database>_db where <database> is database
name of the project
?>
<div class="panel panel-default">
<div class="panel-heading">Out of stock products</div>
<?php
$sql = "SELECT DISTINCT " .
"`categories`.`CategoryName` AS `CategoryName`," .
"`products`.`ProductName` AS `ProductName`," .
"`products`.`QuantityPerUnit` AS `QuantityPerUnit`" .
" FROM `categories` JOIN `products` ON (`categories`.`CategoryID`
= `products`.`CategoryID`)" .
" WHERE " .
"`products`.`UnitsInStock` <= 0";
echo $db->ExecuteHtml($sql, array("fieldcaption" => TRUE, "tablename"
=> array("products", "categories"))); // Execute a SQL and show as
HTML table
?>
</div>
<div class="panel panel-default">
<div class="panel-heading">Discontinued products</div>
<?php
$sql = "SELECT DISTINCT " .
"`categories`.`CategoryName` AS `CategoryName`," .
"`products`.`ProductName` AS `ProductName`," .
"`products`.`QuantityPerUnit` AS `QuantityPerUnit`," .
"`products`.`UnitsInStock` AS `UnitsInStock`" .
" FROM `categories` JOIN `products` ON (`categories`.`CategoryID`
= `products`.`CategoryID`)" .
" WHERE " .
"`products`.`Discontinued` = '1'";
echo $db->ExecuteHtml($sql, array("fieldcaption" => TRUE,
"tablename" => array("products", "categories"))); // Execute a SQL and
show as HTML table
?>
</div>
The result:
185
PHPMaker 12 Help
Note
Other than ExecuteHtml(), there are a few other useful methods in the database
helper class, refer to the source code of the file ewdb.php in the template for details. You
can also extend the database helper class (e.g. in server side Global Code, see Server
Events and Client Scripts(See 1.10.9)) and add your own methods.
Custom Fields
The feature enables you to add your own Custom Fields to a table or view based on valid
SQL expressions. You can treat a Custom Field as a dummy field you added to the table and
the value of the Custom Field is evaluated from the specified SQL expression. Once added,
the field can be treated as a normal field and will appear in all generated pages. You can use
186
PHPMaker 12 Help
Server Events and Client Scripts to manipulate the Custom Field to display any content you
want.
Important Notes
1. The SQL expression must be a valid SQL expression for the database based on the
fields of the table/view. Otherwise, the Custom Field cannot be created.
2. If no SQL expression is entered, the Custom Field will be a blank field and you need
to write your own Server Events and/or Client Scripts to handle the value of the
Custom Field.
3. A Custom Field is not an actual field in the database table/view so input
value will NEVER be inserted/updated to the database.
How to Use
To add a Custom Field to a table/view, simply right click on any database table/view (in the
database pane) or click Edit in the main menu, then select Add Custom Field, the following
form will show:
Field name of the Custom Field. Note that the field name cannot be the same as
any fields/Custom Fields in the table/view
Caption
187
PHPMaker 12 Help
To edit the Custom Field, right click the Custom Field and select Edit Custom Field.
To delete the Custom Field, right click the Custom Field and select Delete Custom Field.
MyTable
If it works, your SQL expression is valid, then you can enter your SQL Expression and
CustomField to create your Custom Field and use them as Expression and Field Name in
the Add Custom Field dialog said above.
188
PHPMaker 12 Help
Enter your database connection information and click the [Connect] button to load the
database information. The list of tables/views of the selected database will be displayed.
189
PHPMaker 12 Help
The database combobox will show the database name, database variable name and the
database type. The database variable name is to be used for retrieving the database
information in server side code such as server events (see Server Events and Client
Scripts(See 1.10.9)). By default it is same as the database name if the database name
contains alphanumeric characters and underscore only. Otherwise, the database variable
name will be different, with non-alphanumeric characters replaced. Besides, the database
name of a Linked Table can be same as the main database or database of other Linked
Tables. If database names are the same, an index will be appended to the database variable
name. If your project uses databases with the same name and you need to write server side
code, make sure you check the variable name here.
Note
Select the tables/views you need and click [OK]. The selected tables/views will be added to
the project as a Linked Table and will appear under the [Linked Tables] node of the database
pane. You can then manipulate the Linked Table as a regular table/view.
190
PHPMaker 12 Help
Note that if the database related with the Linked Table being deleted no longer has any
other Linked Tables associated, you may want to remove this database from the project as
well.
To do that, right click the database pane or click [Edit] in the main menu, then select [Add
Linked Table]
Select the database you want to remove from the dropdown selection, and click the
[Remove Database] button. Click "OK" to confirm deletion.
191
PHPMaker 12 Help
To do that, right click the database pane or click [Edit] in the main menu, then select [Add
Linked Table], select the database and click the [Synchronize Database] button.
Change the connection information if necessary and then press the [Synchronize] button.
192
PHPMaker 12 Help
If you create a Linked Table and then rename the table in your database, the Linked
Table will fail, synchronizing with the database will NOT fix it since if a table is a renamed
table cannot be determined. You need to delete the old Linked Table and create a new one.
Note
Multi-Language Project
Important
1. Multi-Language project must use utf-8 for everything. The charset of the
project must be "utf-8".
2. The data in your database must be stored in unicode, otherwise your data will
not be displayed properly.
3. If you have to customize the template and put unicode characters directly in the
template instead of using language file, always use utf-8 encoding and enable the
Advanced Setting UTF-8 output files (see Customizing Template(See 1.14) and
Tools(See 1.13)).
4. Only the English language file is provided by our products, you'll need to prepare the
language files for other languages yourself. You may also check our website and see
if there are any user submitted language files. If you want to share your language
files with others (without any conditions), you can submit your language file to us
too.
Value Language
Value Language
Value
Arabic
ar
German (Austria)
de-AT Portuguese
pt
Bengali
bn
German
(Switzerland)
de-CH
Bulgarian
bg
Greek
el
Portuguese (Brazil)
pt-BR
193
PHPMaker 12 Help
Catalan
ca
Hebrew
iw
Romanian
ro
Chinese
(Simplified)
zh-CN
Hindi
hi
Russian
ru
Chinese
(Traditional)
zhTW
Hungarain
hu
Serbian
sr
Indonesian
id
Slovak
sk
Croatian
hr
Italian
it
Slovenian
sl
Czech
cs
Japanese
ja
Spanish
es
Danish
da
Kannada
kn
Spanish (Latin
America)
es419
Dutch
nl
Korean
ko
Swedish
sv
English (UK)
en-GB Latvian
Tamil
ta
English (US)
en
Lithuanian
lt
Telugu
te
Estonian
et
Malay
ms
Thai
th
Filipino
fil
Malayalam
ml
Turkish
tr
Finnish
fi
Marathi
mr
Ukrainian
uk
French
fr
Norwegian
no
Urdu
ur
Persian
fa
Vietnamese
vi
de
Gujarati
gu
lv
Polish
pl
The name is for displaying the language name in the user interface (which does not
support unicode), it should contain alphanumeric characters, underscore and spaces
only.
The desc is for displaying the language name in generated scripts, it can be in the
encoding of the XML file.
For example, if you want to make language file for Traditional Chinese, you may
rename the file as chinese.xml and modify the node as:
<locale>
<phrase id="locale" value=""/><!-- *** system locale for this
language -->
194
PHPMaker 12 Help
<phrase id="use_system_locale" value="0"/><!-- *** change to "0"
to disable system locale and use the following settings *** -->
<phrase id="decimal_point" value=","/>
<phrase id="thousands_sep" value="."/>
<phrase id="mon_decimal_point" value="."/>
<phrase id="mon_thousands_sep" value=","/>
<phrase id="currency_symbol" value="$"/>
<phrase id="positive_sign" value=""/>
<phrase id="negative_sign" value="-"/>
<phrase id="frac_digits" value="2"/>
<phrase id="p_cs_precedes" value="1"/>
<phrase id="p_sep_by_space" value="0"/>
<phrase id="n_cs_precedes" value="1"/>
<phrase id="n_sep_by_space" value="0"/>
<phrase id="p_sign_posn" value="3"/>
<phrase id="n_sign_posn" value="3"/>
<phrase id="time_zone" value="US/Pacific"/><!-- *** used for
multi-language site only *** -->
</locale>
If use_system_locale is set to "1", only the locale setting will be used. If
use_system_locale is set to "0", the locale setting will be ignored and other
settings (i.e. decimal_point, thousands_sep, etc.) will be used.
Note
3. You can edit or even add your own phrases. Just open the language file with any
text or XML editor, edit/add your <phrase> nodes. Make sure you provide an unique
id to each phrase. The id must be alphanumerical only.
The phrases are not limited to text, you can also use HTML, e.g.
195
PHPMaker 12 Help
Click [Tools] -> [Languages] to select the languages you want to use in the project. If
more than one language is selected, a combobox will appear on the top of the generated
scripts for user to select language.
196
PHPMaker 12 Help
Some text properties support Multi-Language. This editor allows you to enter your
property values for each language. Supported properties are:
Table/Field Captions
Menu Text
Site Title and Footer Text
Table Page Names
Field Edit Tag Title
Field Error Message
Field Image Tag Alt
Field User Values
To edit these properties, click [Tools] -> [Multi-Language Property Editor] to open the
editor. Alternatively, you can also click the small button next to above properties in the user
interface to open.
Select a property in the Property pane on the left to edit, then enter your properties in
unicode. For example, you can copy and paste from Word.
The editor supports import/export of the phrases (of the mutli-language properties only, not
including the phrases in the language files):
197
PHPMaker 12 Help
Click the export button to export the phrases to a XML file so you can edit the file with text
or XML editor or share the file with other project. Click thie import button to choose the XML
file that you want to import so you can quicky use edited phrases or easily reuse other
project's XML file.
Previously saved properties are displayed in bold font. Once you use this editor to save
your unicode text, the saved unicode property values will always be used prior to the original
property values (in the general user interface) . The original property value will only be used
if unicode property value of the language cannot be found. If you want to edit the property,
always go back to this editor. After editing and saving unicode properties, remember
to re-generate the languages file and upload them again.
Note
changepwd.html
forgotpwd.html
notify.html
register.html
resetpwd.html
The content of these files are in English. To make email templates in other langauges, copy
the files and rename the files and translate the content to the your languages. The files must
be renamed as <original_file_name>_<language_id>.html. For example, the file nofify.html
should be renamed as notify_zh-TW.html if the file is to be translated into traditional
Chinese.
Remember to put the translated files back into the "html" subfolder of the template archive.
If translated files not found in the "html" subfolder of the template archive and hence
translated files not copied to the generated "phphtml" subfolder, the default English version
will be used.
Note
198
PHPMaker 12 Help
In this case, the Root Relative Path is therefore the parent folder of the script, i.e. "..". The
scripts will use this relative path to find the application root.
It is recomended that you set the [Application root folder] to the root folder of your
Website where is accessed by http://www.mycompany.com/ so you can specify your upload
folder and audit trail folder straightforwardly using the Website root as a starting point. For
example, if you specify "upload/" as upload path, since it is relative to application root, the
upload folder will be accessible by http://www.mycompany.com/upload/.
On your testing server, you may work with multiple projects and test your projects one
folder level lower at http://localhost/<projectname>/ (cf. http://<projectname>/). In this
case you should set the [Application root folder] in each project as the root folder of the
project (the folder that is accessed by http://localhost/<projectname>/). After uploading to
the production server, the site may be then accessed by http://www.mycompany.com/ (cf.
199
PHPMaker 12 Help
http://localhost/<projectname>/), but as long as the relative location of the two folders
(Application Root folder and the script folder) are the same, the scripts will still work
properly.
2. Document root
If Root Relative Path is empty, the script checks the following variables:
$_SERVER["APPL_PHYSICAL_PATH"] (for Windows) or $_SERVER["DOCUMENT_ROOT"]
or $_ENV["DOCUMENT_ROOT"] (for Linux).
When you generate scripts, you still need to specify the [Application root folder] and the
[Destination folder] based on your folder structure so that the relative location of the two
folders is correct.
3. Script Path
If both Root Relative Path and Document Root are empty, the script will use the path of the
current script.
4. Custom Path
The above three approaches should handle most cases. If in some special cases they don't
return the path you want, you can modify the function ew_AppRoot() in phpfn*.php. You can
simply customize the template and specify your real server path directly. For example,
Windows:
function ew_AppRoot() {
return 'C:\Inetpub\wwwroot\MyWebRoot\'; // replace with your real
server path directly, include the trailing path delimiter
}
Linux/Unix:
function ew_AppRoot() {
return '/home/username/public_html/'; // replace with your real
server path directly, include the trailing path delimiter
}
Remember that you must also check the value of the constant EW_ROOT_RELATIVE_PATH,
make sure it correctly points to your application folder relative to the script folder. Using
above example, you specify that the application root is "C:\Inetpub\wwwroot\MyWebRoot",
if your scripts are placed in "C:\Inetpub\wwwroot\MyWebRoot\MyScripts\", then
EW_ROOT_RELATIVE_PATH should be "..".
TIP: You can call the PHP function phpinfo() (i.e. <?php phpinfo(); ?>) to view your
server information, including the server paths. Alternatively, in the generated scripts (that
includes phpfn<version>.php), you can call the PHPMaker function ew_WritePaths() (i.e.
<?php echo ew_WritePaths(); ?>) to view the path settings in your project.
200
PHPMaker 12 Help
Auto Backup
PHPMaker supports auto-backup. When you save a project, the old version will be saved to
the subfolder <Documents folder>\<product name>\Backup folder first, you can recover
older versions of your project from the backup folder in case of corrupted projects or other
accidental losses. Note that only the latest 10 versions will be kept, older versions will be
deleted.
The Documents folder is your personal folder in which you can store your personal
files. For example, in Windows Vista (or later), the folder is C:\Users\<user
Name>\Documents.
Note
Project Name
Each project has a project name. By default the file name (without extension) of the project
file is used as project name. Before you name your project file when saving it for the first
time, a temporary name, Project<n>, where n is a number, is used. The project name is an
important property, it is used in the generated codes to identify your project.
Note
If you need to change the project name, use Advanced Settings(See 1.13).
Project ID
Each project has a project ID which is a GUID (globally unique identifier). The value of a
GUID is represented as a 32-character hexadecimal string, such as {095F6728-DF53-4763A372-D8F2EAC959F2}. It is used to identify the project and the scripts generated by it.
Each script generated by the project has the project ID. An XML file named <GUID>.xml is
also generated for each project in the subfolder named by the project name under the
application root(See 1.11). The XML file contains some project information and is used to
share with other projects (e.g. PHP Report Maker project) with the same project name. So
201
PHPMaker 12 Help
do not reveal the project ID to public and do not change the project ID unless absolutley
necessary. If you really need to, use Advanced Settings(See 1.13).
If you use Dynamic User Level (see Advanced Security(See 1.10.4)), the project ID is also
used in the User Level Permission table as a prefix of the table name so that the table
names from different projects will not clash.
Also See:
Template Object Properties(See 1.14.3)
1.13 Tools
Tools
Click [Tools] in the main menu bar to access the following useful tools available in
PHPMaker.
Synchronization
Extensions
Advanced Settings
Copy Table Settings
Copy Field Settings
Sort Tables Alphabetically
Languages
Multi-Language Property Editor
Delete Template Cache
Menu Editor
Synchronization
During the course of project development, it is common that you have altered your database
schema. To save the effort of doing the customization from scratch again, PHPMaker
202
PHPMaker 12 Help
provides you with the ability to synchronize your project data with the database. The
synchronization process can be invoked in the following situations:
Extensions
Click [Tools]->[Extensions] to enable or disable these extensions. Before enabling the
extension, make sure you read the notes about the extension first. If the extension has
advanced settings (NOT every extension has it), you'll see the [Advanced] tab after
selecting the extension. Click the [Advanced] to configure advanced settings for the
extension.
203
PHPMaker 12 Help
Advanced Settings
Advanced Settings are some advanced general settings for PHPMaker, or some rarely
changed settings for the project, or custom defined settings for use during code generation.
Click [Tools] -> [Advanced Settings] to change these settings:
General
Auto-Update values
204
PHPMaker 12 Help
function name for both languages. You can put
your server-side and client-side validation
function in the Global Code (see Server
Events and Client Scripts(See 1.10.9)) section
of server-side and client-side respectively.
Script engine timeout (milliseconds)
205
PHPMaker 12 Help
IIS Express uses php-cgi.exe to run the testing
site, make sure you have included php-cgi.exe
when you install PHP on your PC. If not,
download the zip file from php.net and put the
php-cgi.exe in your installation folder for PHP
(usually <Program Files>\PHP).
PHPMaker will try to find automatically where
php-cgi.exe is installed. If not found, enter
your path here.
Format project file
Project
Project name
Project ID
Debug
206
PHPMaker 12 Help
for details.
File system encoding
207
PHPMaker 12 Help
clicking the submit button) when the browser
is submitting the form.
Allow login by URL
login.php?username=xxx&password=yyy
(where "yyy" is a plain text password)
For example, this allows user login by using
PHP cURL from your own scripts.
For security, you should pass an encrypted
password whenever possible. In fact, usually
you can retrieve an encrypted password (e.g.
a md5 hashed password) from other web
application only, if it is same as the encrypted
password for your project (e.g. MD5
password is enabled in the project, or the
project uses the same user table), then you
can pass an additional URL parameter
encrypted=1 to let the scripts know how to
compare the passwords, e.g.
login.php?username=xxx&password=xyz
&encrypted=1 (where "xyz" is an encrypted
password)
Allow login by session variables
$_SESSION[EW_PROJECT_NAME .
"_Username"] = "xxx"; // where
EW_PROJECT_NAME is the constant of
your project name (see above) and
"xxx" is user name
$_SESSION[EW_PROJECT_NAME .
"_Password"] = "yyy"; // where
"yyy" is a plain text password
For security, you should pass an encrypted
password whenever possible. In fact, usually
you can retrieve an encrypted password (e.g.
a md5 hashed password) from other web
application only, if it is same as the encrypted
password for your project (e.g. MD5
password is enabled in the project, or the
project uses the same user table), then you
can pass an additional session variable to let
208
PHPMaker 12 Help
the scripts know how to compare the
passwords, e.g.
$_SESSION[EW_PROJECT_NAME .
"_Username"] = "xxx"; // where
"xxx" is user name
$_SESSION[EW_PROJECT_NAME .
"_Password"] = "xyz"; // where
"xyz" is an encrypted password
$_SESSION[EW_PROJECT_NAME .
"_Encrypted"] = TRUE;
Remove XSS
209
PHPMaker 12 Help
to a positive value.
Session keep alive interval (seconds)
210
PHPMaker 12 Help
Export master record
Show vertical master record in List Page Specify if master record in List page of detail
table should be displayed in vertical format.
Default is true.
Language files
211
PHPMaker 12 Help
can be done by using subquery but not all
databases support subquery, you may want to
disable this setting in such cases. On the other
hand, if you have large number of detail
records and not using subquery makes the
SQL too long for your database, then enable
this setting if your database supports
subquery.
Initiate search panel as collapsed
Oracle charset
Oracle compare
Oracle sort
212
PHPMaker 12 Help
search you can enter "BINARY_CI" (no double
quotes).
Auto-Suggest maximum display entries
213
PHPMaker 12 Help
Multiple file upload separator
Always keep aspect ratio (image resize) Keep aspect ratio during image resize.
214
PHPMaker 12 Help
meet the search criteria (OR condition)
Replace textarea by text input for search Replace textarea by textbox in Search page
and Extended Search. Default is TRUE.
Use ILIKE operator (PostgreSQL)
Generate password
Password length
215
PHPMaker 12 Help
form, NOT table.
2. The mobile detection is done on the
server side for this feature. Unlike
other pages, resizing desktop browser
will NOT change the page from
desktop mode to mobile mode.
Use dropdown for button group in
mobile
Use css-flip
None - no placeholder
Caption - use field caption (see Field
Setup)(See 1.10.7) as placeholder
attribute value (default)
Title - use field title (see Field
Setup)(See 1.10.7) as placeholder
attribute value
The settings are defined in the settings.xml located at the "src" folder. If you are an
advanced user who customize templates, you can also add your own settings to the
"Project" section. Open the settings.xml with a text or XML editor, add a <setting> node
under the "Project" section. Make sure you provide an unique id to the setting. Supported
data type is "String", "Integer" and "Boolean". If not specified, default is "String". The
setting value can be retrieved in the template during code generation (NOT during runtime
of the generated script) using the PROJ.GetV(id) method. Also read Template Tags(See
Note
216
PHPMaker 12 Help
Copy Table Settings
If you use database built-in query/view to make an alternate version of a table, you need to
set up the table and field settings again, this tool help you quickly copies table and field
settings from the source table to the view. Click [Tools] -> [Copy Table Settings] to open
the following form:
Select the [Source table] and the [Target table] (e.g. the query/view), click OK to copy
the table settings. If a field in the target table has the same name as that in the source
table, field settings will also be copied.
This feature copies setting without validation. If settings from the source table/field are
not applicable to the target table/field, errors may result. Check the settings after copying.
Note
217
PHPMaker 12 Help
Select the [Source table] and the [Target table] (e.g. the query/view), the fields of the
target table will be listed in the left column, you can then select the respective source fields
(from the specified source table) in the right column and click OK to copy the field settings.
1. Re-arranging the table display order by drag-and-drop in the Table Setup page is
still supported, so the display order will NOT be re-sorted automatically after
synchronizing the project with your database even there are new tables added to the
database. Use this tool to sort again if necessary.
2. Only tables are sorted, the display order of the fields in the user interface or in the
generated scripts will NOT be affected by this tool.
3. The display order of the menu items in the generated scripts is still controlled by the
Menu Editor, using this tool will NOT affect the menu items.
Languages
218
PHPMaker 12 Help
If you want to use multi-language project, click [Tools] -> [Languages] to select the
languages you want to use in the project. See Multi-Language Project(See 1.10.16) for more
details.
Menu Editor
219
PHPMaker 12 Help
PHPMaker allow you to modify the menu in the generated site, to open the menu editor,
click [Tools] -> [Menu Editor] in the main menu or click the "Menu Editor" icon in the
toolbar.
Delete
Edit item
Post
Cancel
220
PHPMaker 12 Help
focused menu item
Refresh
Move Up
Move Down
Import items from PHP Report Maker projectImport menu items from PHP Repot Maker
project
Delete imported menu items
Multi-Language
Your can show/hide the menu items by checking/unchecking the checkboxes beside the
menu item text. If a parent menu item is hidden, all the child items will also be hidden.
If you want to use special characters in the menu caption, you can use HTML entities such as
&#euro;.
If your custom menu items requires login, uncheck [Allow Anonymous User]. For other
(non custom) menu items, this setting is same as the List/Search/View permission for
Anonymous User in Advanced Security. (See Security Settings(See 1.10.4).)
After modifying, make sure you click [OK] to save the changes.
By default, the menu is vertical.
221
PHPMaker 12 Help
Registered user can use the Horizontal Menu(See 1.7) extension, click [Tools] ->
[Extensions] to enable the graphical extension, then click [Advanced] tab to set the
menu options.
Grouped menu items is supported. Grouped menu items are to be set up in the same way as
a sub menu. You can check the title menu item in the Group Title column of the Menu
Editor:
222
PHPMaker 12 Help
Since horizontal menu cannot display menu groups like vertical menu, group title
should not be enabled for root level menu items in horizontal menu. If enabled, they will
only be displayed as normal submenus. However, since submenu is vertical, you can use
group title for menu items in submenus.
Note
223
PHPMaker 12 Help
If you want to customize a template, normally you customize the files in the zipped
template, but you'll need to zip it back after customization, for example, by dragging the
customized files back to the zipped template. The unzipped template under the Documents
folder provides an optional way to customize the template without re-zipping the template.
Either way, you should zip it back after all the customizations are done.
The Documents folder is your personal folder in which you can store your personal
files. For example, in Windows 7, the actual location of the Documents folder is
C:\Users\<user name>\Documents by default, where C is the drive in which Windows is
installed, and <user name> is the currently logged-on user.
Note
If you prefer to work with the unzipped template but you have not generated any files yet,
do once first. Then you can modify the unzipped files under the subfolder named "Script".
For example, if the template archive is named as "default.zip", it will be unzipped to the
folder <document folder>\<product name>\Templates\default.zip\, you can modify files
under the subfolder "Script" under it.
The customized files will not be zipped back to the template archive automatically. It
you want to transfer or share your template, you need to zip the template files back to a
template archive yourself. When you zip the template files, make sure you zip the files and
subfolders in the unzipped folder, not the unzipped folder itself. Otherwise there will be one
level different. Using above example, you should add the files and subfolders under
<document folder>\<product name>\Templates\default.zip\ to the template archive, NOT
the whole folder.
Note
When changes in the zipped template is detected, the code generator will ask you to confirm
overwriting the old unzipped version, you should answer carefully, especially if you've
implemented some customizations previously. Always back up your customized
template first!
Control File
The core of the template file is a control file named control.xml. It is an XML file containing
all the necessary instructions for the generation process. During generation the code
generator will parse the control.xml and follows the instructions to generate the output files
one by one. If you want to add an output file, you need to add a <control> tag in the control
file. If the file is to be included in other file(s), you may need to add <session> tags in
control.xml also. See Control File(See 1.14.1) for details.
Language File
All the phrases in the template are separated into a single XML language file for easy
translation to other languages and sharing. If you want to translate a template, this should
be the only file you need to translate.
Language files are placed in the subfolder "languages" under the installed folder. The files
are used for all templates.
Note
The language file contains a <locale> node, if you use Multi-Language, you must
224
PHPMaker 12 Help
2. If you do not know the correct locale string, you can set use_system_locale to "0"
to disable system locale and customize the other locale settings.
The time_zone setting is only used in Multi-Language project.
If you are not using Multi-Language, it is recommended that you set the locale settings in
the user interface (see PHP Settings(See 1.10.2)) although customizing language file also
works. Note that if use_system_locale is set to "0", the locale settings in language file will
override the settings in the user interface.
You can edit or even add your own phrases. Just open the language file with any text or XML
editor, edit/add your <phrase> nodes. Make sure you provide an unique id to each phrase.
The id must be alphanumerical only.
The phrases are not limited to text, you can also use HTML, e.g.
1. Language file is an XML file, when you edit the file, make sure that you keep
it well-formed. If you use HTML tags or special characters in the attributes
of the XML tags, you need to use entity references. For example, to insert the
> symbol, you need to use <. Make sure your characters are supported by the
encoding of the XML file specified in the processing instruction node (the first line).
You can load the file in your browser to check if the file is well-formed, if it is, the
browsers should be able to load and display it without any errors.
2. Only the English language file is provided by our products, you'll need to prepare the
language files for other languages yourself. You may check our website and see if
there are any user submitted language files. If you want to share your language files
with others (without any conditions), you can submit your language file to us too.
File Encoding
The template files and output files are in ASCII encoding by default. Since the phrases are
separated into XML language files in utf-8 encoding, ASCII encoding will suit most cases as
the scripts contain code only. When you customize a template, it is recommended you use
the language file also. If you have to put unicode characters directly in the template files,
you must always use utf-8 and save the file in utf-8 encoding with the byte order mark (EF
BB BF), and enable the Advanced Setting UTF-8 output Files (see Tools(See 1.13)) to
make the code generator output files in utf-8 encoding.
225
PHPMaker 12 Help
General Layout
To change the general layout, just modify the file "template.php" in the template. This file
will be generated as header and footer.
Images
If you want to add or change images, you can add to the "images" subfolder. The "images"
folder will be copied to the destination folder by default. If you replace the provided images
and the file names or dimensions are different from the original ones, remember to
customize the corresponding phrases in the language file(s) also.
Subfolders
Subfolders are defined in control.xml, if you want to add and copy additional subfolders, you
also need to add a <control> tag in the control file(See 1.14.1).
Extensions
Integrating third-party tools can be done by extensions. An extension is modification of
template to make the template supports additional feature(s) implemented in the extension.
Extensions may add or change code sessions in the template.
An extension has the same structure as template and you can modify them in exactly the
same way as modifying the main template.
Extensions files (in zipped format) must be placed under the subfolder "extensions" of the
installation folder. Each extension must have a XML description file so the product can load it
226
PHPMaker 12 Help
in the user interface for selection. You can open an XML file in the "extensions" subfolder to
see the content, which is self-explanatory. Unzip the extension and see how it is
implemented.
Read Tools(See 1.13) on how to select extensions for a project before generation.
An extension is NOT a template, do NOT select an extension as a template for
generation.
Note
Note that all extensions are provided as examples on how to customize and extend the
template only, the third party tools used in them are not developed by the author of
PHPMaker and are not part of PHPMaker, NO TECHNICAL SUPPORT WILL BE PROVIDED. Also
see Third-party Tools(See 1.7) for more information on the third-party tools.
Also See:
Control File(See 1.14.1)
Template Tags(See 1.14.5)
Template Object Properties(See 1.14.3)
Using User Code(See 1.14.4)
Third-party Tools(See 1.7)
Tools(See 1.13)
227
PHPMaker 12 Help
<session/>
</control>
...
<control>
<session/>
...
<session/>
</control>
</product>
1. <product>
The top level is the product level identified by the <product> tag. (The tag name "product"
will be replaced by unique product name identifier in respective products.) It gives a brief
description of the template and serves for product and version information purpose.
PHPMaker will check changes in this tag every time you generate scripts with a template.
Syntax:
<product
date="release_date"
version="version_number"
desc="description"
language="lang_name"
author="author_name">
...
</product>
AttributesDescription
date
version
desc
language
author
2. <control>
The next level is the control level identified by the <control> tag. Each <control> specify an
output file or a set of output files that will be generated by the code generator.
Syntax:
<control
id="control_id"
type="control_type"
228
PHPMaker 12 Help
ofile="output_file_name"
oext="output_file_extension"
ifiles="input_files"
space="True/False"
ofolder="output_file_folder"
cond="conditions">
...
</control>
AttributesDescription
ofile
oext
type
Control type:
"table" - table-related files:
For example, the scripts that will perform "list", "view", "add", "edit" and "delete"
functions for the table. The output of this type is a set of file, one for each table.
"other" - include files:
These files are usually include files that may be included by other files. For
example, the header file and footer file.
"copy" - files that will be directly copied:
These files that will be copied directly from the templates, such as image files.
The target to be copied can be a file or a folder.
id
ifiles
ofolder
space
cond
229
PHPMaker 12 Help
action
3. <session>
The third level is the session level (identified by the <session> tag). For each <control>,
there can be multiple sessions that will constitute the output. Each session can be a specific
segment from the input files or an include statement.
Syntax:
<session
type="session_type"
value="session_value"
/>
AttributesDescription
type
Session type:
"key" - output the code segment identified by the key from the list of input files
"include" - create an include statement
value
Session value:
type="other"
key value of code segment (identified by session tags in input files)
type="include"
include file name
action
Conditions
Condition checking is used extensively in templates to control the code generation process.
Codes will only be generated if the condition specified is met.
The syntax of condition checking is as follow:
condition1[,condition2...]
Condition format:
Object_Type/Object_Property/Operator/Value1[|Value2...]
Object Type and Object Property:
See Template Object Properties(See 1.14.3) for details
230
PHPMaker 12 Help
Operator:
EQ = equal
NE = not equal
GT = greater than
GE = greater than or equal to
LT = less than
LE = less than or equal to
IN = contain value
NI = not contain value
Value:
value for comparison
(Note that single/double quotes are NOT required for string type values.)
Description
ew_SetDb(tablename) (v12+)
ew_GetDbId(tablename) (v12+)
ew_DbType(dbid) (v12+)
ew_MultiPageFldAttr(f) (v12+)
ew_IsAutoSuggest(f)
ew_UseForLabel(f)
ew_HasUserTable() (v11+)
ew_IsNotEmpty(val) (v9+)
ew_IsEmpty(val) (v9+)
231
PHPMaker 12 Help
ew_InArray(val, ar) (v9+)
ew_FormObj(ctlid) (v9+)
ew_RemoveAlias(fld) (v10+)
ew_CustomScriptRowCnt() (v9+)
ew_CustomScriptRowStartVar() (v9+)
ew_CustomScriptRowVar() (v9+)
232
PHPMaker 12 Help
ew_CustomScriptVar() (v9+)
ew_GetJsScript(html) (v9+)
ew_RemoveJsScript(html) (v9+)
ew_ContainText(str, find)
ew_FldTagValues(fld) (v8.0+)
ew_SplitTagValues(str)
ew_IsBinaryField(fld)
233
PHPMaker 12 Help
bQuoted - return as quoted string
ew_GetTblObj(tablename) (v12.0+)
ew_GetParentSelect(f, i) (v12.0+)
ew_GetParentSelectTbl(f, i) (v12.0+)
ew_CssInherit(val)
ew_RowCntVar(v) (v7.0+)
ew_RowCntVarQuoted(v) (v7.0+)
ew_RowVar(v)
ew_RowVarQuoted(v)
ew_AddSquareBrackets(varname, fld)
ew_PageObj()
ew_GetPageObjByCtrlId(ctlid) (v8.0+)
ew_GetCtrlById(id) (v8.0+)
234
PHPMaker 12 Help
ew_Val(v) (v7.0+)
ew_JsVal(v) (v7.0+)
ew_PhpCode(php, typ)
ew_RandomKey()
ew_FolderPath(id)
ew_GetFileNameByCtrlID(id)
ew_RelFolder(f)
ew_RelPath(f1, f2)
ew_OutputRelPath(p)
ew_DestRelPath(p)
ew_AppRootRelPath(p)
ew_EscapeString(sSrc, sEsc)
235
PHPMaker 12 Help
sSrc - source string
sEsc - escape type (double quote for VB,
back slash for js)
ew_DoubleQuote(str, cnt)
ew_Quote(str)
ew_Quote2(str)
SQuote(str)
ew_UnformatName(name)
ew_HtmlValue(str)
ew_JsEncode(val)
ew_HtmlEncode(str)
ew_PhpValue(str)
ew_GetFieldType(ftype)
236
PHPMaker 12 Help
ew_SetDefaultValue(ftype, defvalue)
ew_BoolFieldTagValues(ftype, tagvalues)
ew_SQLPart(sSQL, sId)
ew_RecPerPageList(sList, iRec)
ew_GetEditDateFormat(dateformat) (v9+)
ew_IsFldFloatFormat(fld) (v9+)
ew_IsFldVirtualLookup(fld) (v7.0+)
ew_IsFldForceSelect(fld) (v8.0+)
ew_VirtualLookupFldName(fld) (v7.0+)
ew_EscapeRegExChars(str) (v12.0+)
ew_QuotedName(name) (v7.0+)
237
PHPMaker 12 Help
name - table/field name
ew_SqlConcatName(name1, name2, fld, idx)
(v9+)
ew_FieldSqlName(fld) (v7.0+)
ew_CustomViewFieldName(fld) (v9+)
ew_VirtualTableInCustomView(CustomSQL,
TblName) (v9+)
ew_EncodeName(Name)
Description
CharSet()
FavIcon() (v7.0+)
CSSFile()
238
PHPMaker 12 Help
ScriptName - script name
GetTemplateScript(Type,Name) (v9+)
GetServerScript(CodeType, ScriptName)
GetClientScript(CodeType, ScriptName)
ServerScriptExist(CodeType, ScriptName)
ClientScriptExist(CodeType, ScriptName)
CustomTemplateExist() (v9+)
CustomMultiPageTemplateExist() (v9+)
CustomListOptions() (v9+)
CustomTemplateSearchExist() (v9+)
GetCustomTemplate() (v9+)
GetCustomTemplatePage(pageid) (v9+)
ParseTemplate(template,id) (v9+)
GetCustomTemplateSearch() (v9+)
RenderCustomTemplate() (v9+)
RenderCustomTemplateSearch() (v9+)
239
PHPMaker 12 Help
GetCustomViewTemplate(fld) (v9+)
ScriptTimeout()
IsBoolFld()
PhpCgiPath()
PhpDirective()
IncludeFile(fn, parm)
Security()
ScriptInsert()
ScriptUpdate()
Script(ctlid)
ScriptUpdateFile()
ScriptUpdateFileData()
ScriptUpdateSpecial()
ScriptCommon()
ScriptViewRefer()
ScriptEditRefer()
ScriptView()
ScriptViewCall(cv, vv)
240
PHPMaker 12 Help
vv - view value
ScriptViewNo(cv, vv)
ScriptViewText(cv, vv)
ScriptViewHighlightSearch(cv, vv)
ScriptViewFormat(fld,parm) (v9+)
ScriptViewPassword(cv, vv)
ScriptViewRadio(cv, vv)
ScriptViewValues(cv, vv)
ScriptViewCheckbox(cv, vv)
ScriptViewSelect(cv, vv)
ScriptViewTextarea(cv, vv)
ScriptViewHidden(cv, vv)
ScriptViewFile(cv, vv)
ScriptViewVirtual(wrk)
ScriptAdd()
241
PHPMaker 12 Help
ScriptEdit()
ScriptEditFormat(ctl) (v9+)
ScriptSearch()
ScriptSearch2()
ScriptEditDefaultValue()
242
PHPMaker 12 Help
ScriptEditHidden(cv, ev, ctlid)
ScriptAggregate()
FieldCaption()
FieldSearchCaption()
FieldList()
FieldAggregate()
FieldView()
FieldViewHref(ctl)
FieldUpdate()
FieldEdit()
FieldEditPrimaryKey()
FieldEditDetailKey()
FieldAdd()
FieldSearch()
243
PHPMaker 12 Help
FieldSearch2()
FieldOperator()
FieldOperator2()
244
PHPMaker 12 Help
ctl - control
val - search value
opr - operator
FieldSearchCondition()
OrderByFieldSources()
JsReqValidator()
JsReqErrMsg()
JsValidator()
Return JS validator
JsDefaultMsg()
PhpReqValidator()
PhpReqErrMsg()
PhpReqDefaultMsg()
PhpSearchValidator()
PhpValidator()
PhpFileValidator()
PhpValidatorCommon(fld, msg)
PhpErrMsg()
PhpDefaultMsg()
IsAggregate()
HasFileField()
IsMultiPage()
IsAutofillMasterField(ctlid)
245
PHPMaker 12 Help
IsFileRelatedField(fldname)
SelectionList(ctlid)
ConnectionString(db) (v12.0+)
DatabaseConnection(db) (v12.0+)
246
PHPMaker 12 Help
I. Objects
Project
Description
CTRL
Control Object
PROJ
Project Object
MASTERDETAILS
CUSTOMSCRIPTS
MENULIST
MenuList Object
DB
Database Object
TABLE
Table Object
FIELD
Field Object
PROJ.LINKDBS (v12.0+)
You can view the object properties by opening your Project File(See 1.12) with a text
editor. Project file is an XML file, each object is represented by an XML node in the project
file. The object properties are saved as attributes of the node. The property name is same as
the attribute name.
Note
II. Properties
You can use the standard dot notation to access properties of the objects.
Example
<!--##=PROJ.ProjName##-->
This line will write the project name in the output file.
CTRL Object
The CTRL Object points to the current control in control.xml that is being generated.
Property
Description
Data Type
CtrlId
String
CtrlType
String
PROJ Object
The PROJ Object points to the current project. You can access the current project properties
by PROJ.PropertyName.
247
PHPMaker 12 Help
Property
Description
Data
Type
ProjID (v9+)
Project ID (GUID)
String
ProjName
Project name
String
ProjVar
Project variable
String
MultiLanguage
Boolean
DefaultLanguageFile
String
LanguageFiles
String
AppCompatVersion
Compat version
Integer
AppRelatedProject
String
SqlQuote
String
CodePage
Code page
Long
LCID
Locale id
Long
Cache
Allow cache
Boolean
CharSet
Character set
String
CSS
String
OutputNameType
String
OutputNameExt
String
OutputNameLCase
Boolean
BodyTitle
String
BodyFont
Body font
String
BodySize
Body size
String
BodyBgColor
String
BodyTextColor
String
BodyLnkColor
String
248
PHPMaker 12 Help
BodyVLnkColor
String
BodyALnkColor
String
BodyLeftMargin
Integer
BodyTopMargin
Integer
DocType (v6.0+)
Document Type
String
ApplicationTheme (v6.0+)
Application Theme
String
HeaderColor (v5.0+)
String
HeaderLogo (v5.0+)
String
HeaderHeight (v5.0+)
Integer
MenuColor (v5.0+)
String
FooterColor (v5.0+)
String
FooterFontColor (v5.0+)
String
FooterText (v5.0+)
String
TblWidth
Table width
String
TblPadding
Table padding
Integer
TblBorder
Table border
Integer
TblSpacing
Table spacing
Integer
TblBgColor
String
TblHdrFontColor
String
TblHdrColor
String
TblAltColor
Boolean
TblAltColor1
String
TblAltColor2
String
Template
String
Destination
String
SecType
Security type:
"None" - no security
String
"Hard Code" - use hard coded administrator login /
password
"Use Table" - use security table
249
PHPMaker 12 Help
"Both" - Use both security table & hard coded
administrator login / password
SecLoginID
Administrator login id
String
SecPasswd
Administrator password
String
SecTbl
String
SecLoginIDFld
String
SecPasswdFld
String
SecEmailFld
String
SecForgetPwdPage
Boolean
SecChangePwdPage
Boolean
SecChangeEmail
Boolean
SecRegisterPage
Boolean
RegisterReturnPage (v6.0+)
String
RegisterMultiPage (v6.0+)
Boolean
RegisterMultiPageLabels
(v6.0+)
String
SecRegisterConfirm (v5.0+)
Boolean
SecRegisterCaptcha (v5.0+)
Boolean
SecRegisterActivate (v5.0+)
Boolean
String
Boolean
SecLoginCaptcha (v9+)
Boolean
SecForgotPwdCaptcha (v9+)
Boolean
SecChangePwdCaptcha (v9+)
Boolean
SecRegisterEmail
Boolean
SecSenderEmail
String
SmtpServer
String
SmtpServerPort
Long
250
PHPMaker 12 Help
SmtpSecureOption (v9+)
String
MemoCRLFReplace
Boolean
SessTimeOut
Integer
ServerScriptTimeout
Integer
TestWebServer
Integer
Integer
DateSeparator
String
SetLocale
Set locale
Boolean
Locale
String
CGI
Use CGI
Boolean
CGIPath
CGI path
String
Ext
Extension
String
DefaultPage
String
UseMySqli
Boolean
StartPage (v9+)
String
XMLEncoding
String
HighlightColor
String
SelectColor
String
EditBackColor
String
PagerBackColor
String
DefaultDateFormat
251
PHPMaker 12 Help
FooterBackColor
String
UploadPath
String
UploadAllowedFileExt
String
CssStyles
String
AutoSync
Boolean
AutoBrowseURL (v9+)
String
AutoBrowse
Boolean
OtherGen
Boolean
OtherGenList (v7.0+)
String
Boolean
OtherExpanded (v7.0+)
OtherOverwrite (deprecated in
Overwrite other scripts
v7.0+)
Boolean
DynamicLoadDB
Boolean
MD5Password (v6.0+)
Boolean
Boolean
ServerValidate (v6.0+)
Boolean
ClientValidate (v6.0+)
Boolean
RptIndent
Integer
RecPerPage
Integer
RecPerPageList
PrinterFriendly (v6.0+)
Printer Friendly
Boolean
ExportHtml
Export to HTML
Boolean
ExportWord
Export to Word
Boolean
ExportExcel
Export to Excel
Boolean
ExportXml
Export to XML
Boolean
ExportCsv
Export to CSV
Boolean
252
PHPMaker 12 Help
ExportEmail (v7.0+)
Export to email
Boolean
ExportPDF (v8.0+)
Export to PDF
Boolean
ExportType (v7.0+)
Export Type:
"SELECTED" = export selected records
"PAGE" = export current page
"ALL" = export all records
String
RecPerRow
Integer
MultiDelete
Boolean
SortType
Sort type
0 - no sort
1 - single column sort
2 - multi-column sort
Integer
Pager style:
1 - numeric pager
2 - nextprev pager
Integer
TopPageLink
Pager on top
Boolean
BottomPageLink (v5.0+)
Pager on bottom
Boolean
ViewExport (v5.0+)
Boolean
ListExport (v8.0+)
Boolean
LinkOnLeft
Links on Left
Boolean
InlineDelete
Inline delete
Boolean
DetailViewPaging (v5.0+)
Boolean
DetailEditPaging (v10.0+)
Boolean
ModalSearch (v11.0+)
Boolean
RepeatColumns
Integer
AppRootFolder
String
RootRelativePath
String
DeleteUploadedFile
Boolean
AuditTrailPath
String
RecipientEmail
Receiver email
String
SMTPServerUsername
String
PagerStyle
253
PHPMaker 12 Help
SMTPServerPassword
String
FavIcon (v7.0+)
String
LoginOption (v7.0+)
String
BlankPage (v8.0+)
Boolean
UseButtonsForLinks (v10.0+)
Boolean
UseDropDownForExport
(v10.0+)
Boolean
UseDropDownForAction
(v10.0+)
Boolean
UseDropDownForListOptions
(v10.0+)
Boolean
String
MultiPageType (v10.0+)
You can further define custom Project Level properties and put it in the "Advanced
Settings" file (under "src\settings.xml" in the program folder). The setting is accessible in
the UI via [Tools] -> [Advanced Settings] under the "Project" node. You can then access the
custom properties in the template by means of PROJ.GetV("<property name>"). To avoid
clashing with PHPMaker default project settings, always prefix your settings with "USER_".
Note
MASTERDETAILS Object
The MASTERDETAILS Object contains the collection of all master/detail relationships defined
in the current project. Each master/detail relationship has the following properties.
Property
Description
Data Type
MasterTable
String
DetailTable
String
Boolean
CascadeUpdate (v10.0+)
Cascade update
Boolean
CascadeDelete (v10.0+)
Cascade delete
Boolean
FieldCount
Integer
254
PHPMaker 12 Help
CurrentField
CurrentMasterField
String
CurrentDetailField
String
CUSTOMSCRIPTS Object
The CUSTOMSCRIPTS Object contains the collection of all custom scripts defined in the
current project. Each custom script has the following properties.
Property
Description
Data Type
ScriptType
String
ScriptCodeType
String
ScriptName
Script name
String
ScriptCtrlID
Script control id
String
ScriptL1Key
String
ScriptL2Key
String
ScriptCode
String
MENULIST Object
The MENULIST Object contains the menu items defined in the current project. It has the
following properties.
Property
Description
Data Type
Count
Integer
Item(i)
Item Object
Description
Data Type
MenuID
Menu id
Integer
MenuText
String
MenuParentID
Menu parent id
Integer
MenuGroup (v8.0+)
Boolean
MenuSource
Menu source
String
255
PHPMaker 12 Help
MenuExtUrl
String
MenuAnonymous (v7.0+)
Boolean
MenuSecurity
String
MenuUrl
Menu url
String
MenuCustomUrl
Boolean
MenuLevel
Menu level
Integer
MenuShow
Boolean
MenuDisplayOrder
Integer
DB Object
The DB Object points to the current database. You can access the current database
properties by DB.PropertyName.
Property
Description
Data Type
DBSeq (v12.0+)
Database sequence
Integer
DBID (v12.0+)
Database id
String
DBName
Database name
String
DBVar (v11.0+)
Database variable
String
DBType
Database type
String
DBPath
Database path
String
DBUseServerMapPath
Boolean
DBPhyPath
String
DBUID
Database user id
String
DBPwd
Database password
String
DBQuoteS
String
DBQuoteE
String
DBConnstr
String
DBADOVer
ADO version
String
DBDBMSName
DBMS name
String
256
PHPMaker 12 Help
DBDBMSVer
DBMS version
String
DBOLEDBVer
OleDb version
String
DBProviderName
Provider name
String
DBProviderVer
Provider version
String
DBSchema
Schema name
String
MaxUploadSize
Integer
SecUserLevelFld
String
SecDefault
String
SecuUserIDFld
String
SecUserProfileFld (v7.0+) User profile field name (used by the advanced security
features: concurrent user login / Login retry / Password String
expiry)
UseDynamicUserLevel
Boolean
UserLevelTbl
String
UserLevelIdFld
String
UserLevelNameFld
String
UserLevelPrivTbl
String
String
String
UserLevelPrivPrivFld
String
SecuParentUserIDFld
String
TABLE Object
The TABLE Object points to the current table. You can access the current table properties by
TABLE.PropertyName.
Property
Description
Data Type
TblSchema (v7.0+)
String
TblName
Table name
String
TblType
String
Table type
257
PHPMaker 12 Help
(TABLE/VIEW/CUSTOMVIEW/REPORT/LINKTABLE)
TblKey
Table key
String
TblGen
Boolean
TblGenList (v7.0+)
TblList
Boolean
TblView
Boolean
TblInlineEdit
Boolean
TblGridEdit (v5.0+)
Boolean
TblEdit
Boolean
TblEditConfirm (v5.0+)
Boolean
TblEditCaptcha (v7.0+)
Boolean
TblGridAdd (v7.0+)
Boolean
TblAdd
Boolean
TblAddReturnPage (v6.0+)
String
TblAddOpt (v6.0+)
Boolean
TblAddConfirm (v5.0+)
Boolean
TblAddCaptcha (v5.0+)
Boolean
TblInlineAdd (v5.0+)
Boolean
TblInlineCopy (v5.0+)
Boolean
TblMultiUpdate (v5.0+)
Boolean
Boolean
TblAnonymous (v5.0+)
Integer
TblDelete
Boolean
TblCaption
Table caption
String
TblVar
String
TblSrchType
258
String
PHPMaker 12 Help
"ADVANCED" - advanced search
"BOTH" - both basic & advanced search
TblSearchHighlight (v5.0+)
Search highlight
Boolean
TblSearchColor (v5.0+)
String
TblSearch (v8.0+)
Boolean
TblBasicSearch (v8.0+)
Boolean
TblExtendedBasicSearch
(v8.0+)
Boolean
TblExtSearchFldPerRow
(v8.0+)
Integer
TblBasicSearchDefault (v9+)
String
TblBasicSearchTypeDefault
(v9+)
String
TblDefault
Boolean
TblCopy
Boolean
TblFilter
String
TblUserIDFld
String
TblSecurity
String
TblUserIDAllow (v9+)
Integer
TblExpanded (v7.0+)
Boolean
TblLoaded
Table is loaded
Boolean
TblRptShowDetails
Boolean
TblRptShowGrandTotal
Boolean
OutputFolder (v11.0+)
String
IncludeFiles (v11.0+)
Boolean
TblReportType (v11.0+)
String
TblCustomSQL
String
TblCustomError
String
TblRptSrc
Boolean
259
PHPMaker 12 Help
TblRptIndent
Integer
TblUseGlobal
Boolean
TblRecPerPage
Integer
TblRecPerPageList
String
TblPrinterFriendly (v6.0+)
Printer Friendly
Boolean
TblExportHtml
Export to HTML
Boolean
TblExportWord
Export to Word
Boolean
TblExportExcel
Export to Excel
Boolean
TblExportXml
Export to XML
Boolean
TblExportCsv
Export to CSV
Boolean
TblExportEmail (v7.0+)
Export to email
Boolean
TblExportPDF (v8.0+)
Export to PDF
Boolean
TblExportType (v7.0+)
Export Type:
"SELECTED" = export selected records
"PAGE" = export current page
"ALL" = export all records
String
TblRecPerRow
Integer
TblMultiDelete
Boolean
TblSortType
Sort type
0 - no sort
1 - single column sort
2 - multi-column sort
Integer
Pager style:
1 - numeric pager
2 - nextprev pager
Integer
TblTopPageLink
Pager on top
Boolean
TblBottomPageLink (v5.0+)
Pager on bottom
Boolean
TblViewExport (v5.0+)
Boolean
TblListExport (v8.0+)
Boolean
TblLinkOnLeft
Links on Left
Boolean
TblInlineDelete
Inline delete
Boolean
TblPagerStyle
260
PHPMaker 12 Help
TblDetailViewPaging (v5.0+)
Boolean
TblDetailEditPaging (v10.0+)
Boolean
TblModalSearch (v11.0+)
Boolean
TblAuditTrail
Boolean
TblSendMailOnAdd
Boolean
TblSendMailOnEdit
Boolean
TblSendMailOnDelete
Boolean
TblShowBlankListPage
Boolean
TblDetailShowCount (v7.0+)
Boolean
TblDetailAdd (v9+)
Boolean
TblDetailEdit (v9+)
Boolean
TblDetailView (v10.0+)
Boolean
TblShowMultipleDetails
(v10.0+)
Boolean
TblEditReturnPage (v6.0+)
String
TblMultiPageLabels (v6.0+)
String
TblMultiPageAdd (v6.0+)
Boolean
TblMultiPageEdit (v6.0+)
Boolean
TblMultiPageView (v6.0+)
Boolean
TblMultiPageSearch (v8.0+)
Boolean
TblCheckConcurrentUpdate
(v7.0+)
Boolean
TblUserLevelPriv (v9+)
Boolean
Boolean
TblUseButtonsForLinks
(v10.0+)
Boolean
TblUseDropDownForExport
(v10.0+)
Boolean
TblUseDropDownForAction
(v10.0+)
Boolean
261
PHPMaker 12 Help
TblUseDropDownForListOptions
Use dropdown for list option links
(v10.0+)
Boolean
String
LinkDBID (v12.0+)
String
LinkTableName (v12.0+)
LinkTableType (v12.0+)
TblMultiPageType (v10.0+)
String
FIELD Object
The FIELD Object points to the current field. You can access the current field properties by
FIELD.PropertyName.
Property
Description
Data Type
FldName
Field name
String
FldAlias
String
FldSourceName
String
FldSourceTable
String
FldSourceField
String
FldType
Integer
FldTypeName
String
NativeDataType
Integer
FldSQL (v12.0+)
String
FldIsCustom (v12.0+)
Boolean
FldSupport
Field is supported
Boolean
FldSize
Field size
Long
FldUniqueIdx
Boolean
FldZeroLen
Boolean
262
PHPMaker 12 Help
FldReq
Boolean
FldIsPrimaryKey
Boolean
FldAutoIncrement
Boolean
FldAttribute
Long
FldMin
Variant
FldMax
Variant
FldErrMsg
String
FldValidate
String
FldServerValidateArgs (v7.0+)
String
FldClientValidateArgs (v7.0+)
String
FldRequired
Boolean
FldPopCalendar
Boolean
FldGenerate
Boolean
FldList
Boolean
FldExport (v6.0+)
Boolean
FldView
Boolean
FldEdit
Boolean
FldAdd
Boolean
FldAddOpt (v6.0+)
Boolean
FldSearch
Boolean
FldBasicSearch
Boolean
FldExtendedBasicSearch
Boolean
FldRegister
Boolean
FldSrchOpr
String
FldSrchOpr2
String
FldDefault
Variant
FldSearchDefault (v9+)
String
263
PHPMaker 12 Help
FldSearchDefault2 (v9+)
String
FldDbDefault (v7.0+)
Variant
FldCaption
Field caption
String
FldVar
Field variable
String
FldViewTag
String
FldViewThumbnail (6.0+)
Boolean
FldHtmlTag
String
FldHtmlTagReadOnly
Boolean
FldTagSize
Integer
FldTagMaxLength
Integer
FldTagHiddenValue
String
FldSelectType
String
FldTagValues
String
FldTagLnkTbl
String
FldTagLnkFld
String
FldTagLnkDisplay
String
FldTagLnkDisp2
String
FldTagLnkDisp3 (v8.0+)
String
FldTagLnkDisp4 (v8.0+)
String
FldTagLnkOrderBy
String
FldTagLnkOrderType
String
FldTagLnkDistinct
Boolean
FldTagCols
Integer
FldTagRows
Integer
FldTagImgWidth
Integer
FldTagImgHeight
Integer
FldTagAType
Href type
String
264
PHPMaker 12 Help
FldTagATarget
String
FldTagAPrefix
String
FldTagASuffix
String
FldBold
Boolean
FldItalic
Boolean
FldAlign
Field alignment
String
FldFmtType
String
FldDtFormat
Integer
FldNumDigits
Integer
FldIncLeadDigit
Integer
FldUseParen
Integer
FldGpDigits
Integer
FileNameFld
String
FileTypeFld
String
FileSizeFld
String
ImageWidthFld
String
ImageHeightFld
String
FldHrefFld
String
FldHrefFldOrig (v5.0+)
Boolean
FldStrFunc
String
FldUseDHTMLEditor
Boolean
FldMemoMaxLength
FldSelectSize
Integer
FldSelectMultiple
Boolean
265
PHPMaker 12 Help
FldSelectFilter
String
FldAutoFillSourceFields (v9+)
String
FldAutoFillTargetFields (v9+)
String
FldSelectFilterFld
String
FldSelectFilterFld2 (v9+)
String
FldSelectFilterFld3 (v9+)
String
FldSelectFilterFld4 (v9+)
String
FldParentSelect
String
FldParentSelect2 (v9+)
String
FldParentSelect3 (v9+)
String
FldParentSelect4 (v9+)
String
FldParentSelectTbl (v12.0+)
String
FldParentSelectTbl2 (v12.0+)
String
FldParentSelectTbl3 (v12.0+)
String
FldParentSelectTbl4 (v12.0+)
String
FldSelectAllowAdd
Boolean
FldQuoteS
String
FldQuoteE
String
FldColumnWidth
String
FldColumnWrap
Boolean
FldAggregate
String
FldGroupBy
Integer
FldGroupByShowSummary
Boolean
FldOrderBy
Integer
FldOrder
String
FldRptAggSum
Boolean
FldRptAggAvg
Boolean
266
PHPMaker 12 Help
FldRptAggMin
Boolean
FldRptAggMax
Boolean
FldRepeatColumns
FldUploadPath
String
FldUploadMultiple (v10.0+)
Boolean
UploadAllowedFileExt (v11.0+)
Boolean
UploadMaxFileSize (v11.0+)
Long
UploadMaxFileCount (v11.0+)
Long
FldCheckDuplicate
Boolean
FldPageIndex
Integer
FldAjax
Boolean
FldAutoUpdateValue (v5.0+)
String
FldUploadResize (v5.0+)
Boolean
FldResizeWidth (v5.0+)
Integer
FldResizeHeight (v5.0+)
Integer
FldResizeInterpolation (v5.0+)
Integer
FldMultiUpdate (v5.0+)
Boolean
FldTitle (v5.0+)
String
FldAlt (v5.0+)
String
String
FldViewCustomAttributes
(v5.0+)
String
FldTagACustomAttributes
(v8.0+)
String
Boolean
FldAutoFill (v6.0+)
Boolean
FldMemoCRLFReplace (v6.0+)
Boolean
267
PHPMaker 12 Help
FldTooltipFld (v7.0+)
String
FldTooltipWidth (v7.0+)
Long
FldVirtualLookup (v7.0+)
Boolean
FldViewTemplate (v9+)
String
FldOptionTemplate (v12.0+)
String
FldDropdown (v12.0+)
Boolean
FldDropdownWidth (v12.0+)
Dropdown width
Integer
FldDropdownHeight (v12.0+)
Dropdown height
Integer
PROJ.LINKDBS Object
The PROJ.LINKDBS Object contains the collection of all link databases defined in the current
project. The object can be accessed via PROJ.LINKDBS as follows.
HKEY_CURRENT_USER\Software\<product name>\<version>\Settings\General
Value name: UserCode
Using User Code requires knowledge in JScript. If you are not familiar with the scripting
language, refer to the JScript. In most cases you only need to use the most basic string
functions.
Note
268
PHPMaker 12 Help
Script_View - This function generates code to render the fields in list, view and delete
pages.
Script_Edit - This function generates insert/update codes for the fields in add/copy and edit
pages.
FieldView - This function outputs code for displaying the field in list, view and delete pages.
FieldEdit - This function outputs code for the field as form elements in add/copy, edit and
search pages.
In general, you compare the generated codes with the corresponding page in the template,
find out which tag generate the codes you want to customize. Then you can call the replace
or concat method of the system function in the User Code File. Both mehtod is same as the
JavaScript replace and concat methods.
SYSTEMFUNCTIONS.FieldView.modifiers.push(function() {
alert(this.result); // View the old value
});
Step 2 - Generate scripts, view the generated code, copy the code you want to replace,
modify it as you need.
Step 3 - Replace it.
Example 1 - Directly replace part of the code
269
PHPMaker 12 Help
SYSTEMFUNCTIONS.FieldView.replace(OldCode, NewCode); // Replace
the old code
}
Example 3 - Append your code to the end of the original code
SYSTEMFUNCTIONS.FieldView.modifiers.push(function() {
//alert(this.result); // View the old value
var newvalue = <your code here>; // Modify the oldvalue or write
your own code
this.result = newvalue; // Overwrite value
});
var <Ext> = {
FieldEdit_Prefix: function(ctl, ctlid) {
return "...";
}
FieldEdit_Suffix: function(ctl, ctlid) {
return "...";
}
}
It is a user object with name <Ext> which should be the same as the extension name. It
contains two methods "FieldEdit_Prefix" and "FieldEdit_Suffix". The "FieldEdit_Prefix"
method returns a prefix value which is appended to the start of the output from the
"FieldEdit" system function. Similarly, the "FieldEdit_Suffix" method returns a suffix value
which is appended to the end of the output from the "FieldEdit" system function. Both
methods take on a parameter "ctl" which contains the name of the field control to be
created. The parameter "ctlid" contains an ID which denotes the mode of the control, e.g.
"add", "edit", etc.. (See usercode.js in the "jscalendar" and "fckeditor" extensions as
examples.)
Also See:
Customizing Template
(See 1.14)Template Tags(See 1.14.5)
Template Object Properties(See 1.14.3)
System Functions(See 1.14.2)
270
PHPMaker 12 Help
1. Session Tags
Syntax:
<!--##session session_name##-->
...session content here...
<!--##/session##-->
Notes
2. Script Block
To generate codes according to the project settings, there are many script blocks in each
session. Each script block is enclosed by special start and end tags.
Syntax:
<!--##
...Script here...
##-->
The scripting language used in the script block is JScript provided by Windows Script. To
customize template, you need to know JScript.
In a script block, you can create variables and constants, use conditional statements, do
looping, write procedures, etc. You can also access all settings in the project within the
271
PHPMaker 12 Help
script block. (See Template Object Properties(See 1.14.3) for details.) With script blocks,
you can generate virtually any codes you want.
Example
3. Function Block
Function block output an object property as string or output a string return by a function.
Syntax:
<!--##=...##-->
Note the "=" symbol immediately after the start tag.
The function can be a built-in system function or an user function defined in user code file
(see Using User Code(See 1.14.4)). You can refer to the System Functions(See 1.14.2) list
for functions that you can call or override.
Format
Syntax:
<!--##=Object.Property##-->
<!--##=PROJ.ProjName##-->
This line will write the project name in the output file.
Example 2 - Calling a function
<!--##
// This is a script block
function MyFunction() {
return "This is my custom function";
}
##-->
<!--##=MyFunction()##-->
This line calls the function "MyFunction" and write the string returned by the function in the
output file. In real cases, the returned string is the code you want to generate.
272
PHPMaker 12 Help
Syntax:
<!--##~...##-->
Note the "~" symbol immediately after the start tag. This function is same as function block
above except that output block will be indented with the space before the block.
Also See:
Template Object Propeties(See 1.14.3)
System Functions(See 1.14.2)
Using User Code(See 1.14.4)
1.15 Tutorials
Master/Detail(See 1.15.2)
Inline Add, Inline Copy, Inline Edit, Grid Add and Grid Edit(See 1.15.8)
Report(See 1.15.13)
273
PHPMaker 12 Help
b.
Enter the connection information and and select the encoding if necessary, click
[Get Database List], a combobox populated with the available databases should be shown.
Select the Database you want to connect, click [View Schema]
274
PHPMaker 12 Help
c.
If you can view the schema of database in XML like the follows, the script is working
properly. PHPMaker will talk to this script similarly and get the database schema over HTTP.
3. Loading PHPMaker
Open PHPMaker, enter the connection information, URL of the script and encoding if
necessary.
Note that you are actually connecting to your database through the PHP script on the server,
so in most cases the host/server name is "localhost" unless the database server is not
installed on the same server as the Web server.
275
PHPMaker 12 Help
Click the dropdown button of database combobox, you should be able to see the available
database. Select your database, click the [Connect] button. The database info should be
loaded and displayed in the left pane.
1.15.2 Master/Detail
In this tutorial we will show you how to setup Master/Detail table view in PHPMaker. We will
use the demo database for demonstration.
In the demo, there are two tables called "orders" and "orderdetails". We will set up the
master/detail relation between these two tables.
Fields in Table "orders"
276
PHPMaker 12 Help
277
PHPMaker 12 Help
Then in [Master/Detail] panel at the bottom right corner of the page, click [Modify...] to
bring up the visual master/detail relationship editor. Drag the detail table from the table list
on the left to the diagram on the right.
Then create a relationship between them by dragging from the master field (key field in
master table) to the detail field (foreign key field in the detail table).
278
PHPMaker 12 Help
If there are more linked field, repeat the step until all the relationships are setup. In this
tutorial, we only have one detail field (`orderdetails`.`OrderID`) and one master field
(`orders`.`OrderID`).
PHPMaker supports multiple master/detail, if the table has other master tables or detail
tables, just repeat above process. In this example, we have only one master/detail
relationship, so we click [OK] to confirm. The master/setail relationship is setup.
If you want referential integrity, you can enable Referential Integrity, Cacade Delete
and/or Cascade Update, see Table Setup(See 1.10.6) -> Master/Detail(See 1.10.6) for
detail.
If you want to enable Master/Detail-Add, Master/Detail-Edit and/or Master/DetailView, enable them for the detail table in the Table Setup page:
279
PHPMaker 12 Help
If the master table has more than one detail tables, you can choose Multiple detail tables.
By default each detail table occupies a column in the main table of the List page, if Multiple
detail tables is enabled, the columns will be combined as one.
If you have the Preview extension (for registered users only) and want to enable detail
record preview by Ajax, you can click Tools(See 1.13) -> Extensions(See 1.13) to enable it.
Also see Third-Party Tools(See 1.7).
Enable the extension and then click the Advanced tab to set your settings for each table:
280
PHPMaker 12 Help
Notes
1. The Preview extension works best when the number of the fields and number of
records are not too many so the size of the preview area will not be too large.
Otherwise the preview area may exceed the browser area and therefore the detail
records cannot be viewed completely at a glance.
2. If PreviewRow is enabled, the individual detail table columns will become hidden.
3. PHP Script Generation
Click the [Generate PHP] icon to go to the [Generate] tab, click the [Generate] button.
PHPMaker will generate the required PHP scripts automatically.
4. Running the PHP Application
Click on the link to the "orders" table, there will be a new column for the "orderdetails "
table. Click on the "orderdetails" button to access the order details for the selected record.
Click the down arrow button and then click Master/Detail View, Master/Detail Edit or
Master/Detail Copy to view/edit/copy and selected record and its detail records.
281
PHPMaker 12 Help
If you have enabled Preview extension and enable PreviewOverlay, move your mouse
cursor over the "orderdetails" button and you'll see detail records preview:
If you have enabled Preview extension and enable PreviewRow, click the [+] button in
the row and and you'll see the preview row:
282
PHPMaker 12 Help
Click the Master/Detail View link/button, the View page of the master table with a detail
table grid of the detail table will be shown.
283
PHPMaker 12 Help
Click the Master/Detail Edit link/buttonk, the Edit page of the master table with a detail
table grid of the detail table will be shown.
284
PHPMaker 12 Help
Click the Master/Detail Copy link/button, the Add page (in Copy mode) of the master
table with a detail table grid of the detail table will be shown.
Click the Add orders/ordertails button in the paging section, the Add page of the master
table with a detail table grid of the detail table will be shown.
285
PHPMaker 12 Help
In Master/Detail-Add/Copy/Edit mode, you can click Add Blank Row or Delete button to
add or delete rows wiithout refreshing the page. Note this feature is implemented by
JavaScript.
286
PHPMaker 12 Help
We want to setup the "Picture" field in the "Cars" table for image upload to database.
Note
287
PHPMaker 12 Help
You can optionally set up the following fields in Edit Tag panel. If the files to be uploaded
are of normal browser supported image types (e.g. jpg/gif), you can skip the file type field,
otherwise the File Type Field should be set.
File type field - save the file content type of the uploaded file/image (Mandatory)
File name field - save the name of uploaded file/image (Optional)
File size field - save the size of uploaded file/image (Optional)
288
PHPMaker 12 Help
Image width field - save the width of the image (Image Only, Optional)
Image height field - save the height of the image (Image Only, Optional)
Once setup, PHPMaker will use these fields for storing/displaying the uploaded file/image
information.
Do not specify file name field if you want IE to open the file automatically. (IE may fail
to open non-image files retrieved from database.) Only use file name field if you want IE to
popup a File Download dialog for user to save the file with the filename specified in the file
name field.
Note
Again, since we upload to database, the uploaded files will be stored in database as binary
data, there is no need to set the Upload folder.
If you are uploading image, you can choose to resize the image. Check Resize image and
enter the Resize width and Resize height.
Note
Requires PHP GD extension and supports GIF, JPEG and PNG only.
289
PHPMaker 12 Help
You can choose to display the file/image field using the Formatted Text
Image
View Tag or
Formatted Text View Tag will display the field as a hyperlink to the file/image.
Image View tag will display the field as image using <IMG> tag and is also hyperlinked to
the image. To change image display style to Image, click on the Image
Tag Panel for the settings.
Only image files can use the Image View Tag. Other files such as PDF cannot be
displayed as image. If the field contains mixed file types, do not use Image View Tag.
Note
If the dimensions of the image you want to display are different from the stored image, you
can choose to Resize image. If enabled, the image will be resized to the specified width
and/or height on display. Again, resizing requires PHP GD extension, see the note above.
If you want to add hyperlink to the image, set the HREF field. If you want the image linked
to the file, select the field itelf as the HREF field. If you want to image linked to other URL,
select another field which stores the URL. You can also optionally set the target of the
hyperlink.
5. PHP Script Generation
Click the Generate button and PHPMaker will generate the required PHP scripts
automatically.
6. Running the PHP Application
Click on the link to the Cars table. You should now be able to add, view, edit and delete
records with file/image fields.
Formatted Text View Tag will display the field as a hyperlink to the file/image if you have
selected the field itself as the HREF field:
Image View tag will display the field as image using <IMG> tag and is also hyperlinked to
the image:
290
PHPMaker 12 Help
The Add/Edit page will allow you to delete or upload another file/image:
Also see:
File/Image Upload to Folder(See 1.15.4)
291
PHPMaker 12 Help
We want to setup the "PictureName" field in the "Cars" table for image upload to folder. Note
that unlike in the tutorial File Upload to Database(See 1.15.3) in which we used a binary
field ("Picture") to store data in database, this time we choose "PictureName" which is a text
field only. It is because this field will be used for storing the filename, the uploaded file will
be stored in the upload folder as a physical file.
Note
of PHP, web server and database affects max file size also, read PHP
Settings(See 1.10.2).
In Allowed file type, enter the file extensions that you allow user to upload.
Then, you need to enter the Upload folder. (Do NOT leave it empty.) This folder should be
a subfolder relative to the root of the PHP application. For example, you can enter "uploads/"
(use slashes "/" as path delimiter). If the root of the PHP application is
C:\Inetpub\wwwroot\projectname\, then the upload folder is
C:\Inetpub\wwwroot\projectname\uploads\.
Make sure that the Web server user has read/write access to the folder. See Application
Root(See 1.11).
292
PHPMaker 12 Help
NoteThe
Max file size (bytes), Allowed file type and Upload Folder here are global
settings for all fle upload fields, you can also enter field specific settings in the Edit Tag
panel (see below).
If want to delete the uploaded file when the field value is replaced, removed or if the record
is deleted, check Delete file on update/delete.
If Delete file on update/delete is enabled, the uploaded file will be deleted. If the deleted
record is a copied record, deleting the uploaded files will affect the original record. To
prevent such possible problem, enable Advanced Setting Create upload file on copy (see
Advanced Settings(See 1.13)) to duplicate the uploaded file when copying a record.
293
PHPMaker 12 Help
If you want to allow mulitple file upload, enable Multiple. If enabled, the field value will
store comma separated file names of the uploaded files.
File type field, File name field, File size field, Image width field and Image
height field are NOT applicable to upload to folder. It is because the files uploaded to folder
are physical files on your server, there is no need to store the file information in the
database except the file name for identifying the file.
Note
If you are uploading image, you can choose to resize the image. Check Resize image and
enter the Resize width and Resize height.
Note
Requires PHP GD extension and supports GIF, JPEG and PNG only.
If you have field specifc settings for Upload folder, Allowed file types, Max file size
(bytes) and Max number of files, enter them as needed. See Field Settings(See 1.10.5)
for detail.
294
PHPMaker 12 Help
You can choose to display the file/image field using the Formatted Text
Image
View Tag or
Formatted Text View Tag will display the field as a hyperlink to the file/image.
Image View tag will display the field as image using <IMG> tag and is also hyperlinked to
the image. To change image display style to Image, click on the Image
Tag Panel for the settings.
Only image files can use the Image View Tag. Other files such as PDF cannot be
displayed as image. If the field contains mixed file types, do not use Image View Tag.
Note
If the dimensions of the image you want to display are different from the stored image, you
can choose to resize it. If enabled, the image will be resized to the specified width and/or
height on display. Again, resizing requires PHP GD extension, see the note above.
If you want to add hyperlink to the image, set the HREF field. If you want the image linked
to the file, select the field itelf as the HREF field. If you want to image linked to other URL,
select another field which stores the URL. You can also optionally set the target of the
hyperlink.
5. PHP Script Generation
Click the Generate button and PHPMaker will generate the required PHP scripts
automatically.
6. Running the PHP Application
Click on the link to the Cars table. You should now be able to add, view, edit and delete
records with file/image fields.
Formatted Text View Tag will display the field as a hyperlink to the file/image.
Image View tag will display the field as image using <IMG> tag and is also hyperlinked to
the image:
295
PHPMaker 12 Help
The edit page will allow you to delete or replace an existing file/image:
If you upload files to folder and the destination file already exists, the file name will be
changed automatically. By default an index in the format of "(n)" will be appended to the
end of the file name where n is an integer. If you prefer renaming the file with another
name, you can use Row_Updating and/or Row_Inserting server event and change the
file name field value, see Server Events and Client Scripts(See 1.10.9).
Note
Also see:
File Upload to Database(See 1.15.3)
296
PHPMaker 12 Help
Table "trademarks" - Lookup Table for the parent field "Trademark" in "cars" table
Table "models" - Lookup Table for the child field "Model" in "cars" table
Each child field's lookup table must have a Filter field storing key field value of the
parent field.
Note
In this example, the "Models" table has an integer field named "Trademark" storing the
trademark ID of the model.
To set up child fields, click [Child lookup fields...] and enter the following settings:
297
PHPMaker 12 Help
[Link field] is the field (in lookup table) whose value is actually saved. In this example, the
field value of models.ID (NOT models.Model) will be saved to the field cars.Model.
[Filter field] is the field (in lookup table) by which the lookup table records are filtered.
Only records with a Filter field value matching the selected value of the parent selection list
will be shown. In this example, only models with Trademark field value matching the
selected Trademark ID in the parent selection list are shown.
Click [OK] to confirm.
If you now select the Model field, you'll see:
You can optionally check Use Ajax for both selection lists. If Use Ajax is enabled, the
selection list will be updated by Ajax. The advantage of using Ajax is that if you have large
lookup tables, the time to load the page will be much shortened because there are only
Note
298
PHPMaker 12 Help
selected option(s) in the selection lists initially. The disadvantage is that it takes some time
for Ajax to populate the selection lists after the page is loaded in the browser.
3. PHP Script Generation
Click the [Generate] button and PHPMaker will generate the required PHP scripts
automatically.
4. Running the PHP Application
Click on the link to the "Cars" table and go to the Edit page. The options in the model
selection list will be changed automatically when the selected option in trademark selection
list is changed:
Total
Count
Average
The "Order Details Extended" view in the demo will be used in this example. We will set up
"Field Average" for the Quantity field and "Field Total" for the ExtendedPrice field.
Fields in view "Order Details Extended"
299
PHPMaker 12 Help
To set up the Field Total for the "ExtendedPrice" field, select "TOTAL" for the "Aggregate"
column of the "ExtendedPrice" field.
300
PHPMaker 12 Help
3. PHP Script Generation
Click the [Generate] button and PHPMaker will generate the required PHP scripts
automatically.
4. Running the PHP Programs
The Field Aggregate will be shown in the footer of the "Order Details Extended" list page as
follow:
301
PHPMaker 12 Help
Steps to Setup Registration System
1. Loading PHPMaker
Open PHPMaker and connect to the demo database.
2. Enabling Security and Setting up User Table
Advanced Security has to be enabled first. Click the [Security] tab, check [User Existing
Table], select the [Table], the [Login Name Field] and the [Password Field]. The
[Advanced] button will be enabled.
302
PHPMaker 12 Help
303
PHPMaker 12 Help
Email Field
User Email Address Field in user table used for sending email
Activated Field
User Activated Field in user table used for storing the status of
user. A boolean field is recommended, although an integer field
or a string field will also work.
To enable user account activation, the Requires activation
and Send email options under User Registration Page must
be checked. The user needs to click an activation link in the
email sent after registration to activate the user account.
Note
Click [>] to select the field or [>>] to select all fields to be included in registration page.
Note that the password field is mandatory. Since we have chosen options that will send
emails, the Email field must be included also.
If you use User Level Security also, you should not include the User Level field because a
new user is not supposed to choose his/her own User Level. If the User Level field is not
included, the default User Level for new user will be 0 (Anonymous). You can assign a
suitable User Level to the user later by logging in as an administrator. Alternatively, you can
also set a default value for the User Level field in your database or in PHPMaker. Then the
new user will get the default User Level immediately after registration.
Click [OK] to finish.
If you have enabled any of the email sending features, you must enter the SMTP server
information in the [PHP]->[Email Settings] tab:
304
PHPMaker 12 Help
Click the "Register" link, you will be redirected to the registration page. Note that a "Confirm
Password" field and JavaScript validation are added automatically.
305
PHPMaker 12 Help
Click the "Forget Password" link, you will be redirected to the request password page.
If the email address entered by the user can be found in the user table, the password will be
sent to the email address.
After login, a "Change Password" link is added in the menu before "Logout". Click it and
you'll be redirect to the change password page.
The contents of the email contents can also be modified in the template. The files are
register.html, changepwd.html and forgotpwd.html.
For example, the forgot password email content template (forgotpwd.html) is like the
follows. The format is self-explanatory.
306
PHPMaker 12 Help
Cc:
Bcc:
Format: HTML
<p>Dear Sir/Madam,</p>
<p>Please see below for the requested information:</p>
<p>
Username: <!--$UserName--><br>
Password: <!--$Password-->
<p>
<p>Please feel free to contact us in case of further queries.</p>
<p>
Best Regards,<br>
Support
</p>
The following special tags are used in the email templates:
307
PHPMaker 12 Help
Note: Make sure you table has primary key, or records cannot be located and
edited.
Click the table "Suppliers" on the database pane. The Field Setup page for the table
Suppliers is displayed.
308
PHPMaker 12 Help
The fields to be displayed in the list page is shown in the [List] column under the [List
Page] Section. These fields are editable in the Inline/Grid Add/Copy/Edit mode.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHPMaker will generate the
required PHP scripts automatically.
4. Running the PHP Application
Run the scripts in your browser, click on the link to the "Suppliers" table, there will be new
links for "Inline Add", "Inline Edit", "Inline Copy", "Grid Add" and "Grid Edit".
Click on the "Inline Edit" link to enter Inline Edit mode. The selected record will be
highlighted and entered into Inline Edit mode. Click on the "Update" link to update the
record or click "Cancel" to cancel update.
309
PHPMaker 12 Help
Now, click on the "Inline Copy" link for a record to enter Inline Copy mode.
Click on the "Insert" link to insert the new record or click "Cancel" to cancel.
Now click on the "Inline Add" link to enter Inline Add mode.
Click on the "Insert" link to insert the new record or click "Cancel" to cancel.
Now click on the "Grid Edit" link to enter Grid-Edit mode.
310
PHPMaker 12 Help
Click on the "Save" link to update the records or click "Cancel" to cancel.
Now click on the "Grid Add" link to enter Grid-Add mode.
Click on the "Insert" link to insert the new record or click "Cancel" to cancel.
In Grid-Add/Edit mode, you can click "Add Blank Row" or "Delete" to add or delete rows
without refreshing the page. Note that this feature is implemented by JavaScript.
311
PHPMaker 12 Help
312
PHPMaker 12 Help
2. Setting up Security
Click on the [Security] tab, there are two sections for the login process:
Administrator Login
If you tick this option, a hard-coded Administrator account will be generated which has all
access right to all tables/views.
Use Existing Table
Tick this option to set up the user access levels. You should select the security table and the
corresponding Login Name and Password fields.
To set up the user ID, click on the [Advanced] button. A popup window will appear.
3. Setting up User Access Own Data
You can set up the [User ID] Field and [Parent User ID] as follow:
313
PHPMaker 12 Help
As the caption suggests, the User ID Field is a field to identify users. The field values for
each user must be unique. So typically the primary key of the User Table is used as User ID
Field.
To identify the records owned by a user, the records must also have a field to store the User
ID value. Therefore, all protected tables must have an User ID field, the field names can be
different though. To setup User ID field for each table,
1. Click on User ID in the left pane,
2. Select the User ID field from your user table, (otherwise the feature is disabled)
3. In the User ID Field column, select the User ID Field for the tables/views that
requires User ID security
[Parent User ID] field stores the parent User ID that the user belongs to. For example, a
parent user can be the manager that the employee reports to. You can select an Parent User
ID for users so the parent user can modify the child users' records as his/her own.
(otherwise the feature is disabled)
Parent User ID is hierarchical, parent users can access the records owned by the child
users of their child users, and there is no limit of levels.
Note
In this example, we set the Parent User ID Field as the "ReportsTo" field.
4. PHP Script Generation
Click the [Generate] button and PHPMaker will generate the required PHP scripts
automatically.
5. Running the PHP Programs
Login as employee #1 using "nancy" and user name and "1234" as password. Go to the
"Orders" table. As we have used User ID security for the table, although we can still view all
the records, we can only modify employee #1 (nancy)'s records.
314
PHPMaker 12 Help
If you now log out and login again as employee #3 using "janet" as user name and "1234"
as password, you can only modify employee #3 (janet)'s records:
But if you now logout and login again as employee #2 using "andrew" as user name and
"1234" as password, you can only access employee #1(nancy), #3 (janet), #4(margaret),
315
PHPMaker 12 Help
#5(steven) and #8(laura)'s records because "andrew" is the parent user of them, all these
users report to "andrew".
Notes
316
PHPMaker 12 Help
There are 2 types of User Level security:
1. Static User Levels - the User Levels and the permissions are defined in the project and
the User Levels are not to be changed after script generation.
2. Dynamic User Levels - the User Levels and the permissions are defined in 2 tables in
the database, the User Levels can still be changed with the generated scripts.
In this tutorial we use static User Level Security.
The "Employees" table and "Orders" table in the demo will be used in this example.
Fields in Table "Employees"
317
PHPMaker 12 Help
318
PHPMaker 12 Help
To set up the user levels, click on the [Advanced] button. A popup window will appear.
Click on the [User Levels] button. Select the User Level Field.
The User Level field must be of integer data type. Non integer fields will not be
seen in the User Level Field combobox.
Important
319
PHPMaker 12 Help
Click
finish.
to add a new user level. Enter the description, and default permissions. Click OK to
For each user level, you can set refine the permission for different tables/views. Click OK to
finish.
320
PHPMaker 12 Help
If you go to Field Setup Page now and view the Edit Tag for the User Level Field, you should
see that the Edit Tag has been setup as "SELECT" and the user levels have been added
automatically in the value list:
321
PHPMaker 12 Help
We assign a password and the user level "Sales" to the employee #1 (the employee with
EmployeeID equals 1). Then we logout.
To see the Advanced Security works, we login again as employee #1 using "nancy" as user
name and "1234" as password.
According to the user level defined by us, users with "Sales" level has view and add
permissions to the "Orders" table only. They are not allowed to update or delete records.
Employee #1 belongs to the "Sales" level, so we do not see the links to the edit/delete page.
Notes
1. Users have no right to change his own user level. Only Administrator can change an
user's user level. If you want to assign user levels in the generated scripts, a hardcoded administrator login account must also be created. Alternatively, an user must
be assigned with the Administrator level. However, you may still need to use the
hard-coded Administrator Login to log in and assign user levels to users initially. Of
course, you can also modify data in your database directly. The value of the
Administrator level is -1.
2. Since User Level works at table level only, if an user has permissions to the User
Table, he/she may be able to modify personal information (including user level and
user id) of other users. Therefore you should not expose the User Table to normal
users. If you want to expose the User Table and restrict users to access their own
data only, you need to use User ID Security, which controls permissions at record
level. (See Advanced Security - User ID Security) (See 1.15.9)
322
PHPMaker 12 Help
3. There are two types of Advanced Security implemented in PHPMaker - User ID
Security and User Level Security. User ID Security secures data at record level; User
Level Security secures data at table level. They can work independently or work
together. (See Advanced Security - User ID Security) (See 1.15.9)
Also see:
Advanced Security - User ID Security(See 1.15.11)
Advanced Security - Dynamic User Level Security(See 1.15.9)
323
PHPMaker 12 Help
Dynamic User Level Security stores the User Level information in the database, so you need
to add 2 tables to your database - User Level Table and User Level Permission Table
which must have the following fields, note the data types, User Level ID and the Permission
fields must be of integer type, the field names can be different though:
324
PHPMaker 12 Help
You can create these 2 tables in the database yourself or you can use PHPMaker to create
these 2 tables for you, please see below.
325
PHPMaker 12 Help
To set up the user levels, click on the [Advanced] button. A popup window will appear.
Click on the [User Levels] button. Select the User Level Field.
The User Level field must be of integer data type. Non integer fields will not be
seen in the User Level Field combobox.
Important
To use dynamic User Levels, switch to the [Dynamic User Levels] and check [Enable
Dynamic User Levels].
326
PHPMaker 12 Help
If you want PHPMaker to create these 2 tables in your database, click the [Create tables]
button, the following form will display for you to change the table/field names if necessary.
You can change the table/field names and then click OK to continue.
If you have projects created by previous versions of PHPMaker you may want to use
dynamic User Levels and migrate the previously defined static User Levels in the project to
the database. After selecting or creating the User Level and User Level Permission
tables/fields, just click the [Migrate] button to let PHPMaker do that for you.
You'll need to specify the User Level Table and the User Level Permission Table and the
related fields. (If you use PHPMaker to create the tables, PHPMaker will set up the
tables/fields automatically also.)
User Level Table - the table for storing the User Levels
User Level ID Field - the ID of an User Level, this field must be integer type
User Level Name Field - the name of an User Level, this field should be string field
A typical User Level Table should contain data like this:
327
PHPMaker 12 Help
Default - Default user level is built-in user level with user level = 0. Since User Level field is
an integer field, if you set a default value of 0 for this field, this user level will become the
default user level for the user after registration and before the Administrator assigning
another higher user level.
You can add your own User Levels with User Level ID starting from 1.
User Level Permission Table - the table for storing the permission of the User Levels
Table Name Field - the table name of each table in the database, this field should be of
string type
User Level ID Field - the ID of an User Level, this field must be integer type
Permission Field - the permission of the specified User Level ID in the specified table, this
field must be integer type also.
A typical User Level Permission Table should contain data like this: (Note: Table names will
be prefixed with Project ID, see Project File(See 1.12).)
328
PHPMaker 12 Help
1. Only administrators can manage User Levels, you must login as the hard coded
administrator or as a member of the built-in Administrator User Level.
2. You manage the User Level permissions via the scripts generated for the User Level
Table and the User Level Permssions page (userpriv.php), NOT via the scripts
generated for the User Level Permission Table directly. If you go to the scripts for
the User Level Permission Table directly, you'll only see the permissions in integer
format.
.
If the User Level table is not created by PHPMaker, you may not have the Anonymous,
Administrator and Default User Level in the table yet. You'll need to add them yourself.
Note
329
PHPMaker 12 Help
In this example, we add 2 more user levels - Sales and Manager, click the Add link and enter
the User Level ID, User Level name and default permissions as follows:
Click "Add" button to confirm. If you click the "Permission" link now, you can set refine the
permission for different tables/views:
We assign a password and the user level "Sales" to the employee #1 (the employee with
EmployeeID equals 1). Then we logout.
To see the Advanced Security works, we login again as employee #1 using "nancy" as user
name and "1234" as password.
According to the user level defined by us, users with "Sales" level has view and add
permissions to the "Orders" table only. They are not allowed to update or delete records.
Employee #1 belongs to the "Sales" level, so we do not see the links to the edit/delete page.
330
PHPMaker 12 Help
Notes
1. Users have no right to change his own user level. Only Administrator can change an
user's user level. If you want to assign user levels in the generated scripts, a hardcoded administrator login account must also be created. Alternatively, an user must
be assigned with the Administrator level. However, you may still need to use the
hard-coded Administrator Login to log in and assign user levels to users initially. Of
course, you can also modify data in your database directly. The value of the
Administrator level is -1.
2. Since User Level works at table level only, if an user has permissions to the User
Table, he/she may be able to modify personal information (including user level and
user id) of other users. Therefore you should not expose the User Table to normal
users. If you want to expose the User Table and restrict users to access their own
data only, you need to use User ID Security, which controls permissions at record
level. (See Advanced Security - User ID Security) (See 1.15.9)
3. There are two types of Advanced Security implemented in PHPMaker - User ID
Security and User Level Security. User ID Security secures data at record level; User
Level Security secures data at table level. They can work independently or work
together. (See Advanced Security - User ID Security) (See 1.15.9)
Also see:
Advanced Security - User ID Security(See 1.15.11)
Advanced Security - Static User Level Security(See 1.15.10)
331
PHPMaker 12 Help
database allow you to use them more like regular tables. If you use MySQL 5, you should
ALWAYS use MySQL view.
Note
Before reading this tutorial, please read Using Custom View(See 1.10.11) first.
In this tutorial we will show you how to create a Custom View. We will use the demo
database for demonstration.
We will build a SELECT statement which can show the customer's company name, the
product name and total price of an order item. Four tables, "orderdetails", "orders",
"customers" and "products" table.
Fields in Table "orderdetails".
332
PHPMaker 12 Help
333
PHPMaker 12 Help
334
PHPMaker 12 Help
Click [SQL] tab and edit the SELECT statement in the SQL editor directly, add a calculated
field in the SELECT clause:
Change the name of the custom view from the temporary name "CustomView1" to that you
want, in this example, we use "Order Details Extended".
On the toolbar, there is a checkbox labeled [Copy field settings from source table
(when applicable)]. We keep this checked so the Field level setup (Edit Tag, View tag,
etc.) will be copied from the field's source table.
335
PHPMaker 12 Help
Click [OK] to finish. The custom view is added under [Custom Views] in database pane.
336
PHPMaker 12 Help
1.15.13 Report
Note
Before reading this tutorial, please read Using Report(See 1.10.12) first.
In this tutorial we will show you how to create a report using custom view with summary in
PHPMaker. We will use the demo database for demonstration.
We will use "Order Details Extended" custom view in the Custom View Tutorial(See 1.15.12)
to create a report which shows the order items in orders of each customer.
SQL of Custom View "Orders Details Extended":
337
PHPMaker 12 Help
Click the [Grouping Levels] tab, since we want to group the order items by company and
then by order, we select "CompanyName" and then "OrderID" as grouping level. We check
[Show summary] for both levels (the [Summary Values] tabs become visible).
338
PHPMaker 12 Help
Click the [Sort Order] tab, since we want to sort the order items by product name, we
select "ProductName" as sorting field. (If you want to sort in descending order, click the
button next to the field to switch the order.)
339
PHPMaker 12 Help
Now click the [Summary Values] tab. We want to see total price and average quantity of
order item in an order, so we check [Avg] for the field "Quantity" and check [Sum] for the
field "Extended Price".
We want to see details of each order item, so we use the default option [Details and
summary]. We also leave [Show grand summary] checked as default because we want
to know the total price and average quantity of order item for all orders.
340
PHPMaker 12 Help
341
PHPMaker 12 Help
342
PHPMaker 12 Help
343
PHPMaker 12 Help
Steps to Setup Compatibility Properties
1. Make Sure the Advanced Security Settings in Both Projects Are the Same
The Advanced Security settings in both projects must be the same. Open the PHP Report
Maker project you previously used in the Advanced Security tutorials (Tutorial - User ID
Security(See 1.15.9) or Tutorial - User Level Security(See 1.15.10)). Compare the Advanced
Security settings with that in your PHPMaker project. Check the User ID field, Parent User ID
field, User Level field and User Levels.
Close the project. (In next step, PHPMaker may need to change your project settings, so you
should not open the project in PHP Report Maker.)
2. Setting up Compatibility Properties
Compatibiltiy can be set up easily in the PHPMaker project. PHPMaker can load the PHP
Report Maker project, set up above properties automatically and load the menu items from
the PHP Report Maker project to the PHPMaker project. Since PHPMaker will update your PHP
Report Maker project, to avoid overwriting each other, you should save your PHP Report
Maker project and close PHP Report Maker first. Then in PHPMaker, open the Menu Editor,
click the [Import] button in the toolbar,
344
PHPMaker 12 Help
If you change User Level settings in your PHP Report Maker project later, the imported
menu items in the PHPMaker project will NOT be updated automatically, you'll need to
repeat above again.
Note
If you open your report project again in PHP Report Maker (not PHPMaker) and click [Tools]
-> [Compatibility Properties], you should see that PHPMaker has changed some settings
for compatibility:
1. The project name has been set as the same as that of PHPMaker project,
2. [Enable compatibility properties] is enabled,
3. The file names of the shared files has been setup. If they are not correct, enter the
file name of the header, footer, login, logout and default pages in your PHPMaker
project.
345
PHPMaker 12 Help
346