|
|
User-Defined TypesIntroduction | Definition | Settings | Forms | Advanced Search IntroductionThe types module allows you to add your user-defined fields to users, products, items, schedules and events. The most obvious application is to have Types of product - with fields specific to that type - giving the website's customers more information about the products. For example an electricals website could have a type for 'television' with fields like 'screensize', 'nicam', 'freeview'. Products or Items with type data can be compared in a Compare List (which is simply the shopping cart displayed in a different container) in which all the features for all things in the basket are shown in a big table for comparison. O3 comes with an example Compare container. Users can have a type - in which case their extra data can be used like a profile, and can contain search preferences and any other data. Related ModulesThe Types module is required for the List Items module. The Scheduler module can use types to give more depth to schedules and events. Defining Your TypesYou define your Types in the Types Manager. It allows you to create, update delete and copy types, and add columns (fields) to them. It gives you a lot of control over how the database implements the table - with indexing & uniqueness. Type data is stored in database table of the name Types have these fields:
Type Columns have these fields:
SettingsThere is only 1 setting for types: The User-Type. If set - this defines the type data that is associated with the website's users. Users can edit this data in the login page, or you can build forms to display / update their details easily. FormsThe types module includes the Forms Manager. This is primarily designed to allows you to define forms to manipulate items, but they work with all O3 things... You can include a form in most containers using the SHOW-FORM# macro, or by using the Forms are type-data aware, and will fill in select and checkboxes for you if you set up the Validation Rule for the type-data column. For example: a validation rule of 'Y|N' is assumed to be a checkbox, and a rule of pipe delimited strings (like 'House|Chalet|Flat') is assumed to be a select list. Forms have these fields:
Form MacrosThe following macros can be used in forms:
O3 comes with examples of forms for common actions like creating, updating and deleting items, user preferences etc... Advanced SearchO3's standard display functions surpass many website's 'Advanced' serach options, but O3 can go even deeper - into the type data - to give you a totally flexible advanced search. You do have to write a bit of SQL to do it - though there are examples and it's not that hard. The advanced search is displayed in the catalog page by passing in the The options for the search can be passed in the command line, or better, taken from the user's type data - that way their serach preferences are always stored - a nice user-friendly feature. The advanced search scripts are held in the directory 'o3/as'. They must return the search results by generating the SQL needed in the WHERE clause, setting the ORDER BY clause, and calling the appropriate show_...() function. They take this form (example - a search by country):
In this example there are 2 possible item listing types free, and premium listings. The more types there are, the longer these two clauses will be as you need to include all the combinations for the query to work. |