| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Creating your own pages

Page history last edited by majd87@... 12 years, 6 months ago

To generate a CRUD, CodeExtinguisher needs to know what table you're using, what controller is associated with the page, and what kind of plugins you want to populate the form. Because the process of creating a new controller, writing the PHP syntax for the array, and hand-writing all the options can be very repetitive, a default controller is provided for you. The controller is called CRUD and is located in codex/application/controllers/crud.php. If you opt to use the CRUD controller, then you don't need to configure a table, or a controller name, as the controller generates them automatically. You do however, still need to write your form configuration, as well as any optional parameters you would like to include.

 

To generate a basic CRUD page, you simply create the table in your database, and CodeExtinguisher will take care of the rest for you. The form that gets generates however is very basic, and often needs to be customized. To do that, you create a file in the definitions/ directory whose name correlates to the table name. The only semantic requirement for the file is to contain the form_setup directive, which outlines which plugins are associated with what fields.

 

If you want to create a new page called Posts, you first create the table in phpMyAdmin (or whatever database management software you prefer), and then you create a file called posts.yml in the definitions/ directory with the following format:

 

form_setup:
  first_field:
    ...
  second_field:
    ...

If you would like to add validation rules, then you define them in the rules directive. Your file would now look like:

 

rules:
  first_field: trim|required
form_setup:
  first_field:
    ...
  second_field:
    ...

 

These options (rules, form_setup) are called directives, and there are a few directives you can define:

 

db_table  yes  The name of the database table associated with that page 
form_setup  yes  The form layout
controller_name  yes  The name of the controller (used to build the links) 
table_access_restrictions  no  Imposes restrictions on the content that the user can see in the Overview page 
order_by  no  The default field to order the results by
order_type   no  The default type of ordering  
page_header  no  The name to be displayed in the crumbs and the title bar of the browser 
view_mode  no  The view mode to use in the Overview page
rules  no  Validation rules 
display_fields  no  The table fields to display in the Overview page 
on_one_page   no  The number of results to display on each page (pagination) 
first_item  no  The first item to display (this is set by default) 
add_link  no  The link to the "Add New" page (this is set by default) 
edit_link  no  The link to the "Edit Existing Item" page (this is set by default) 
add_action  no  The action of the "Add New" form (this is set by default) 
edit_action  no  The action of the "Edit Extisting Item" form (this is set by default) 
delete_action  no  The action of the "Delete Selected" form (this is set by default) 
search_action  no  The action of the search form (this is set by default) 
controller_link  no  The link to the controller 

 

 

Note:  CodeExtinguisher will automatically generate links for you. If you create your own controller, then you need to stop CodeExtinguisher from generating the link (by adding it to codex_exclude_tables in config/codex.php) and adding it to codex_navigation in the same file.

Comments (0)

You don't have permission to comment on this page.