Course plan for introduction to extrapolation in Cotonti using the example of the Page module (pages and articles)
- Introduction
- Part 1. What extrafields are — the essence and concept in simple words
- Part 2. Where extrafields are built into Cotonti and how they work
- Part 3. All thirteen field types: a detailed breakdown
- Part 4. Preparatory steps before creating an extrafield
- Part 5. Step-by-step creation of an extrafield for the Page module
- Part 6. How to output extrafields in templates
- Part 7. Practical examples for different types of websites
- Part 8. Common mistakes and how to solve them
- Part 9. Advanced techniques
- Part 10. Answers to beginner questions
- Conclusion
Introduction
This article is for people who have never worked with the Cotonti website management system before and want to understand extrafields. We won't use complex terminology, won't make you write code, and won't require knowledge of programming languages. All explanations are in simple words, with analogies, examples, and tables.
The material is structured so that you can read it sequentially, chapter by chapter. If you need an answer to a specific question — open the table of contents and jump to the section you need.
After studying this article, you will be able to:
- Understand what extrafields are and why they're needed.
- Independently create any extrafield for pages.
- Output it in the site template.
- Solve typical problems that arise when working with extrafields.
Part 1. What extrafields are — the essence and concept in simple words
Chapter 1.1. Everyday analogy: a wardrobe and a shelf
To understand the essence of extrafields, let's imagine an ordinary wardrobe. The wardrobe has several shelves: for shirts, for trousers, for shoes. These shelves are built into the design from the start — everyone who buys such a wardrobe has them. Nobody plans to change them.
But one day you bring home a collection of hats from vacation. There's no space for them in the wardrobe. What do you do? You nail on an additional shelf. This shelf wasn't provided by the manufacturer — you came up with it yourself for your specific task.
That additional shelf is an extrafield in the world of Cotonti. It's a field that wasn't in the standard data structure, but which you created yourself because you need it.
Another example: a job application form. The standard form has fields for "Last Name," "First Name," "Date of Birth," "Education." But your HR department additionally needs to know whether the candidate has a driver's license. You add an extra line to the form. That's also an extrafield — an additional field that you came up with.
Chapter 1.2. What a field in a database is
All information on a website is stored in a database. A database is a set of tables. Each table resembles an Excel sheet: there are rows (records) and columns (fields).
For example, the pages table (cot_pages) contains all the pages of your website. Each row is one page. Each column is a characteristic of the page.
Standard columns of the pages table:
| Column | What it contains |
|---|---|
page_id | Unique page number (auto-increment) |
page_alias | Alternative page address (SEO-friendly URL) |
page_state | Publication state: 0 — draft, 1 — published, 2 — pending moderation |
page_cat | Code of the category the page belongs to |
page_title | Page title |
page_desc | Short description |
page_keywords | SEO keywords |
page_metatitle | Meta title tag |
page_metadesc | Meta description tag |
page_text | Main page text |
page_parser | Which parser to apply to the text |
page_author | Page author |
page_ownerid | Page owner's ID |
page_date | Creation date (timestamp) |
page_begin | Publication start date |
page_expire | Publication end date |
page_updated | Last update date |
page_file | Flag indicating an attached file exists |
page_url | Page address |
page_size | Page size |
page_count | View counter |
page_filecount | Number of attached files |
As you can see, there's everything needed for a typical page: title, description, text, author, dates. But something might be missing. For example, if you sell products through the "Pages" module, where do you store the price? Where do you store the SKU? Where do you store the manufacturer? There are no standard fields for this. And that's where extrafields come to the rescue.
Chapter 1.3. How extrafields appear in the database
When you create an extrafield through the Cotonti admin panel, the following happens:
- A new column with the name you specified is added to the
cot_pagestable. - A record describing this field (its type, settings, and which table it belongs to) is added to the service table
cot_extra_fields. - Cotonti starts automatically displaying this field in the page edit form.
- Cotonti automatically creates tags for outputting this field's value in the template.
Thus, the extrafield becomes a full-fledged part of the system. It behaves just like built-in fields: it can be filled in when creating a page, it can be output in a template, it can be changed during editing.
Schematically it looks like this:
Admin creates a field
↓
Record in cot_extra_fields
↓
ALTER TABLE cot_pages (adding a column)
↓
Field in the edit form
↓
Tag in the template (PAGE_FIELD_NAME)
↓
Value on the site
Chapter 1.4. Which entities can extrafields be added to
In Cotonti, extrafields can be added not only to pages, but also to other entities. The main ones are:
| Entity | Table | What it stores | Usage examples |
|---|---|---|---|
| Pages | cot_pages | Articles, news, products | Price, SKU, author, source |
| Users | cot_users | Profiles | Skype, Telegram, city, position |
| Structure categories | cot_structure | Site sections | Icon, color, SEO description |
| Market products | cot_market | Store products | Specifications, warranty |
| Forum topics | cot_forum_topics | Forum threads | Importance, status |
| Forum posts | cot_forum_posts | Forum messages | Attached file |
| Comments | cot_com | Comments | Rating, status |
In this article we'll focus on pages (cot_pages), because it's the most commonly used entity, especially on catalog and store websites.
Chapter 1.5. Why extrafields are needed: real examples
To better understand the scope of extrafields, let's look at a few scenarios.
Scenario 1. Online store on the Page module. You sell electronics. For each product page you need to specify: price, SKU, manufacturer, warranty period, stock availability, link to the manual. The standard Cotonti fields aren't enough. You create six extrafields.
Scenario 2. Travel blog. You write articles about different countries. For each article you'd like to specify: country, city, season, trip budget, duration. You create five extrafields.
Scenario 3. Real estate catalog. You publish apartment listings. You need to specify: area, number of rooms, floor, building type, balcony availability, price. You create six extrafields.
Scenario 4. News portal. You publish news. You want to specify: source, author, event city, event time. You create four extrafields.
Scenario 5. Photographer's portfolio. Each work has technical parameters: camera, lens, ISO, shutter speed, aperture. You create seven extrafields.
Scenario 6. Culinary website. Each recipe has: cooking time, number of servings, calories, difficulty. You create four extrafields.
In all these cases, extrafields are the only way to add the needed information without rewriting the system's core.
Chapter 1.6. What would happen without extrafields
If extrafields didn't exist, each such task would require:
- Editing the site's database structure manually — that is, going into MySQL via phpMyAdmin, adding columns, risking data loss.
- Writing code that would read and save these new columns.
- Editing templates to output the new data on the page.
- Redoing all the edits with every Cotonti update.
With extrafields, none of this is needed. The system itself creates the columns in the database, picks them up in the edit form, and generates tags for templates.
Chapter 1.7. Limitations of extrafields
To give the full picture, let's also mention the downsides:
- The field type cannot be changed after creation. Created a field as a number — it stays a number forever. If you made a mistake, you'll have to delete the field and create it again, losing data.
- Deleting a field deletes the data. If you delete an extrafield, all values stored in it are erased permanently.
- Extrafields are not a replacement for table relationships. If you need a relationship between two entities (e.g., "a product belongs to a seller"), that's done with a different mechanism.
- The interface is limited to field types. Only about thirteen types are available. If you need very complex input (a map, a code editor, multiple files with sorting), you'll need a separate plugin.
- You can't make a dropdown list with dependencies. For example, "country → city" cannot be done through standard extrafields.
All these limitations aren't critical if you understand them in advance.
Part 2. Where extrafields are built into Cotonti and how they work
Chapter 2.1. General data storage scheme
Cotonti stores data in a MySQL database. Each entity has its own table:
| Entity | Table name (with site prefix) |
|---|---|
| Pages | cot_pages |
| Users | cot_users |
| Categories | cot_structure |
| Extrafields (descriptions) | cot_extra_fields |
When you create an extrafield for pages, two things happen:
- A record with your field's parameters appears in the
cot_extra_fieldstable. - A new column with the name you specified is automatically created in the
cot_pagestable.
All this happens "under the hood," the user only sees the result.
Chapter 2.2. The cot_extra_fields table
The cot_extra_fields table contains metadata about all extrafields. Conditionally, it can be represented like this:
| Field | What it stores | Example |
|---|---|---|
field_location | Which table it's attached to | cot_pages |
field_name | Field name | product_price |
field_type | Field type | currency |
field_html | HTML template for display | <input …> |
field_variants | Value variants | Draft, Published |
field_params | Additional parameters | 0,1000 |
field_default | Default value | 0 |
field_required | Whether it's required | 0 or 1 |
field_enabled | Whether it's enabled | 0 or 1 |
field_parse | Parse HTML or not | HTML or Text |
field_description | Field description | "Product price" |
This data is needed by the core to understand how to display the field, how to validate the data, and where to save it.
Chapter 2.3. What happens when a page is saved
When you open a page in the admin panel and fill in an extrafield, the following happens:
- Cotonti receives the data from the form.
- It validates it against the rules specified in the field's metadata (for example, whether it's a number, whether it falls within a range).
- It saves the values into the corresponding columns of the
cot_pagestable.
Every time a page is updated, extrafield values are updated just like standard fields.
Chapter 2.4. How tags for templates are formed
A template tag is formed from the field name by a simple rule:
| Field name in the admin panel | Template tag |
|---|---|
product_price | {PAGE_PRODUCT_PRICE} |
author_name | {PAGE_AUTHOR_NAME} |
release_year | {PAGE_RELEASE_YEAR} |
Rule: the field name is converted to uppercase, PAGE_ is prepended, and everything is wrapped in curly braces.
Exception: if the field is created for another module, the prefix will be different. For example, USERS_ for users, MARKET_ for products.
Chapter 2.5. How Cotonti knows where to output the field
Cotonti doesn't know exactly where you want to insert the field. It doesn't "guess" the place. Therefore, all responsibility for placement lies with you: you need to open the template file in a text editor, find the right place, and insert the tag there.
This is both flexible (you can output the field anywhere on the page) and demanding (you need to understand how templates are structured).
Chapter 2.6. Scheme: the path of data from form to page
Page edit form
↓
Cotonti core
↓
Data validation
↓
cot_pages table (extrafield columns)
↓
page.tpl template
↓
Final HTML on the site
This scheme helps to understand that every time data is changed in the form, the entire chain runs again.
Part 3. All thirteen field types: a detailed breakdown
Cotonti supports thirteen field types. Let's look at each.
Chapter 3.1. Input — single-line text
What it is. A standard text field where you can enter up to 255 characters.
What to use it for. Names, titles, short descriptions, codes, SKUs, links, authorship.
Example. Field "Article author" — you enter the name of the person who wrote the text.
Settings. No special parameters besides the name and description.
Limitations. Text only, 255 characters max. If you need multiline text, use textarea.
How it looks in the form. A simple input line.
How it looks on the site. Exactly what you entered, unchanged.
Chapter 3.2. InputInt — integer
What it is. A field where you can only enter whole numbers (no dots or commas).
What to use it for. Quantity, year, rating, age.
Example. Field "Stock quantity" — you can enter "150".
Settings. You can set a minimum and maximum value.
Limitations. Whole numbers only. For decimals, use double or currency.
How it looks in the form. An input line with a numeric keyboard on mobile.
How it looks on the site. The number, unchanged.
Chapter 3.3. Double — floating-point number
What it is. A field for numbers that have a fractional part.
What to use it for. Weight, volume, distance, coefficients.
Example. Field "Product weight, kg" — you can enter "2.45".
Settings. You can specify the number of decimal places.
Limitations. Not suitable for money — there's a separate currency type for that.
How it looks in the form. A regular input line, but with number validation.
How it looks on the site. The number, unchanged.
Chapter 3.4. Currency — monetary amount
What it is. A field specifically for money. It differs from double in that formatting is automatically applied to the value.
What to use it for. Prices, costs, budgets.
Example. Field "Price" — you enter "1500", and on the site it displays as "1500.00".
Settings. Number of decimal places (usually 2).
How it looks in the form. A regular input line.
How it looks on the site. A number with two decimal places.
Chapter 3.5. Textarea — multiline text
What it is. A large text input field where you can fit several paragraphs.
What to use it for. Short descriptions, specifications, comments, notes.
Example. Field "Package contents" — a list of what's included with the product.
Settings. You can specify the number of rows and columns for display.
Limitations. This is not a visual editor, but a simple text field. For formatted text, use Cotonti's standard fields with an editor enabled.
How it looks in the form. A large block for entering text.
How it looks on the site. Text with line breaks (if HTML is allowed).
Chapter 3.6. Select — dropdown list
What it is. A dropdown list from which you can choose only one option.
What to use it for. Statuses, categories, conditions, types.
Example. Field "Product condition" — options: "New," "Used," "Refurbished."
Settings. A list of variants, each variant on a new line in a special field.
Limitations. You can't select several values at once. For that, use checklistbox.
How it looks in the form. A dropdown list with one active option.
How it looks on the site. The text of the selected option.
Chapter 3.7. Checkbox — flag
What it is. A single checkbox that can be turned on or off.
What to use it for. Yes/no, on/off.
Example. Field "Featured" — if the box is checked, the product goes into the featured block.
Settings. None.
Limitations. Only two states. If you need several options, use radio.
How it looks in the form. A single checkbox that can be checked or unchecked.
How it looks on the site. 0 or 1. Usually used in conditions (IF).
Chapter 3.8. Radio — group of radio buttons
What it is. Several radio buttons from which you can choose one option.
What to use it for. When there are few options and you want them all visible at once.
Example. Field "Delivery type" — "Courier," "Mail," "Pickup."
Settings. List of variants.
Limitations. Not suitable for long lists — select is better for that.
How it looks in the form. Several round buttons, one of which is selected.
How it looks on the site. The text of the selected option.
Chapter 3.9. Datetime — date and time
What it is. A field for entering a date and time.
What to use it for. Event dates, deadlines.
Example. Field "Promotion start date" — chosen via a calendar.
Settings. Date display format, year range.
Limitations. Always includes both date and time. If you need only time, set the date conventionally.
How it looks in the form. Several dropdown lists (day, month, year, hour, minute).
How it looks on the site. A date in the specified format (e.g., 12.10.2026).
Chapter 3.10. Country — country
What it is. A dropdown list of countries standardized by the system.
What to use it for. Country of manufacture, country of delivery, citizenship.
Example. Field "Country of manufacture."
Settings. None — the country list is already built in.
How it looks in the form. A dropdown list with country names.
How it looks on the site. A two-letter country code.
Chapter 3.11. Range — integer within a range
What it is. A field where you can enter a whole number within specified bounds.
What to use it for. Ratings, scores, levels.
Example. Field "Product rating" — from 1 to 5.
Settings. Minimum and maximum.
How it looks in the form. A dropdown list with numbers in the range.
How it looks on the site. The number.
Chapter 3.12. Checklistbox — multi-select list
What it is. A list in which you can check several options at once.
What to use it for. Tags, categories, groups of characteristics.
Example. Field "Tags" — you can check "New," "Best seller," "Sale."
Settings. List of variants.
Limitations. It's more difficult to output values in templates — you need special loops.
How it looks in the form. Several checkboxes.
How it looks on the site. Values separated by commas.
Chapter 3.13. File — file upload
What it is. A field for uploading a file from your local computer.
What to use it for. Attaching PDF manuals, documents, images.
Example. Field "Manual" — a PDF file is attached.
Settings. Allowed formats, upload folder.
Limitations. For images, Cotonti's standard fields are usually used; file is for documents.
How it looks in the form. File selection button + delete checkbox.
How it looks on the site. A link to the file.
Part 4. Preparatory steps before creating an extrafield
Chapter 4.1. What you need to know before starting
Before creating extrafields, make sure you have:
- Access to the Cotonti admin panel. Admin login and password.
- Administrator rights. Not all users can create extrafields — you need administrator-level rights.
- Database backup. Be sure to make a backup before creating new fields.
- Understanding of your site's structure. Think about which fields you actually need.
Chapter 4.2. Creating a backup
A backup is sacred. Never neglect it. You can create a database backup:
- Through your hosting control panel (usually there's a "Backups" section).
- Through phpMyAdmin (database export).
- Through Cotonti plugins (e.g.,
dbbackup).
It's advisable to store the backup in three places: on the server, on your local computer, and in cloud storage.
Chapter 4.3. Planning extrafields
Before creating extrafields, make a list of the fields you need. For each field, define:
- Field name (Latin letters, no spaces)
- Field type
- Description (what the user will see in the form)
- Required or not
- Where it will be used (in which template it will be output)
Example planning table:
| Name | Type | Description | Where used |
|---|---|---|---|
price | Currency | Product price | Product card, product list |
sku | Input | SKU | Product card |
vendor | Input | Manufacturer | Product card |
warranty | InputInt | Warranty (months) | Product card |
stock | Checkbox | In stock | Product card, filter |
manual_url | Input | Link to manual | Product card |
With such a table, the field creation process will go faster and without errors.
Chapter 4.4. Recommendations for field names
The field name is what will be used in the database and in templates. It should be:
- In Latin letters.
- Without spaces.
- Without hyphens.
- Without dots.
- With underscores for separating words.
- Meaningful.
Examples of good names:
product_price— product priceauthor_name— author nameevent_date— event dateis_featured— featured
Examples of bad names:
field1— unclear what's storedtemp— doesn't reflect the essenceabc— means nothing at all
Part 5. Step-by-step creation of an extrafield for the Page module
Step 1. Logging into the admin panel
- Open your site in a browser.
- Add
/adminor/ru/adminto the address, depending on the site's language version. - Enter the admin login and password.
- Click the "Log in" button.
Step 2. Going to the "Extrafields" section
- In the left menu, find the "Site management" section.
- Expand it.
- Select the "Extrafields" item.
- The direct link usually looks like
https://your-site.com/admin/extrafields.
You'll land on a page with a list of all tables to which additional fields can be added.
Step 3. Selecting the pages table
A list of tables will open on the page. Find the cot_pages table in the list (in your installation, the prefix may differ, e.g., x92374_pages). This is the table of the "Pages" (Page) module.
Click on the table name. You'll go to the page for managing extrafields of that specific table.
Step 4. Examining existing fields
On the page that opens, you'll see a table with existing additional fields. In a standard Cotonti installation, there may be none — the table will be empty.
You'll also see a form for adding a new field. Usually it's located at the bottom of the page.
Step 5. Filling out the add form
The add form consists of several fields.
| Field | What to enter |
|---|---|
| Enabled | Leave the checkbox ticked |
| Field Name | Unique, in Latin letters, e.g., product_price |
| Description | A clear name for the editor, e.g., "Product price" |
| Field HTML code | Leave empty — Cotonti will generate it |
| Field type | Select from the list, e.g., currency |
| Selection values | Fill only for select/radio/checklistbox |
| Parameters | Fill only for numeric types and datetime |
| Default value | Optional |
| Required | Tick only if the field is critical |
Step 6. Selecting the field type
To the right of or below the name and description block, there's a dropdown list "Field type" (Type). By default, input is selected. Click on it and choose the desired type.
After choosing the type, the form may rearrange: some additional fields will appear, others will disappear.
Step 7. Configuring additional parameters
Different field types require different parameters.
For Input — no additional parameters.
For InputInt:
| Parameter | Description |
|---|---|
| Minimum | Minimum value |
| Maximum | Maximum value |
For Currency:
| Parameter | Description |
|---|---|
| Decimal places | Usually 2 |
For Double:
| Parameter | Description |
|---|---|
| Decimal places | Usually 2-4 |
For Textarea:
| Parameter | Description |
|---|---|
| Width | In characters |
| Height | In rows |
For Select:
| Parameter | Description |
|---|---|
| Selection values | Each value on a new line |
For Radio and Checklistbox:
| Parameter | Description |
|---|---|
| Selection values | Each value on a new line |
For Datetime:
| Parameter | Description |
|---|---|
| Year range | From year and to year |
| Format | For example, d.m.Y H:i |
For Range:
| Parameter | Description |
|---|---|
| Minimum | Minimum value |
| Maximum | Maximum value |
For File:
| Parameter | Description |
|---|---|
| Upload folder | Where to save the files |
| Allowed formats | For example, pdf,doc,zip |
Step 8. Saving the field
- Check all the filled-in fields.
- Click the "Save" or "Add" button.
- If everything is filled in correctly, the field will appear in the table of existing extrafields.
Step 9. Checking in the page edit form
- Go to the "Pages" section.
- Open any page for editing.
- Scroll down the form — you should see the new field.
Step 10. Filling in a value
Enter a test value in the new field and save the page. Nothing has changed on the site yet, because the template doesn't know about the new field. That's the next step.
Step 11. Creating the remaining fields
Repeat steps 5–10 for all planned fields.
Part 6. How to output extrafields in templates
Chapter 6.1. Understanding the template structure
Cotonti templates are located in your theme's folder. For the Page module, it's:
/themes/your_theme/modules/page/
Main files:
| File | Purpose |
|---|---|
page.tpl | Viewing a single page |
page.list.tpl | List of pages in a category |
page.add.tpl | Add form |
page.edit.tpl | Edit form |
Chapter 6.2. Tags for outputting extrafields
Cotonti automatically creates tags for each extrafield. The naming scheme is:
| Tag | What it outputs |
|---|---|
{PAGE_FIELD_NAME} | Field value |
{PAGE_FIELD_NAME_TITLE} | Field description |
{PAGE_FIELD_NAME_VALUE} | Value (alternative tag) |
For example, if you created a field named product_price, you can use this in the template:
{PAGE_PRODUCT_PRICE}
Chapter 6.3. Inserting the tag into the template
- Open the
page.tplfile in any text editor. - Find the place where you want to output the field.
- Insert the tag.
Example of outputting the price:
<div class="product-price">
Price: {PAGE_PRODUCT_PRICE}
</div>
Example of outputting the author:
<div class="author">
Author: {PAGE_AUTHOR_NAME}
</div>
Chapter 6.4. Conditional output
If a field may be empty, wrap it in a condition:
<!-- IF {PAGE_PRODUCT_PRICE} -->
<div class="product-price">
Price: {PAGE_PRODUCT_PRICE}
</div>
<!-- ENDIF -->
Such code will only display the block if the field is filled in.
Chapter 6.5. Output with field description
<div class="extrafield">
<strong>{PAGE_PRODUCT_PRICE_TITLE}:</strong>
{PAGE_PRODUCT_PRICE}
</div>
If the field is described in the admin panel as "Product price," the site will show: "Product price: 1500.00."
Chapter 6.6. Loop through all extrafields
If you have many extrafields:
<!-- BEGIN: PAGE_EXTRAFLD -->
<div class="extrafield">
<strong>{PAGE_EXTRAFLD_TITLE}:</strong>
{PAGE_EXTRAFLD_VALUE}
</div>
<!-- END: PAGE_EXTRAFLD -->
This block will automatically loop through all filled-in fields of the page.
Chapter 6.7. Output in the pages list
In the page.list.tpl file, the tags are slightly different:
{PAGE_ROW_PRODUCT_PRICE}
Note the ROW_ in the middle. That's because in a list, each page is a separate loop row.
Chapter 6.8. Clearing the cache after changes
After editing the template:
- Save the file.
- Open the admin panel → "Site management" → "Cache" → "Disk cache."
- Click "Clear all."
- Open the page on the site and check the result.
Chapter 6.9. Tag formation scheme
Field name in admin panel: product_price
↓
Conversion: PRODUCT_PRICE (to uppercase)
↓
Adding prefix: PAGE_PRODUCT_PRICE
↓
Wrapping in braces: {PAGE_PRODUCT_PRICE}
↓
Insertion into the template
Part 7. Practical examples for different types of websites
Chapter 7.1. Online store on the Page module
Extrafields:
| Name | Type | Description |
|---|---|---|
product_price | Currency | Price |
product_old_price | Currency | Old price |
product_sku | Input | SKU |
product_brand | Input | Brand |
product_warranty | InputInt | Warranty, months |
product_instock | Checkbox | In stock |
Output in the product card:
<h1>{PAGE_TITLE}</h1>
<!-- IF {PAGE_PRODUCT_SKU} -->
<div>SKU: {PAGE_PRODUCT_SKU}</div>
<!-- ENDIF -->
<!-- IF {PAGE_PRODUCT_BRAND} -->
<div>Brand: {PAGE_PRODUCT_BRAND}</div>
<!-- ENDIF -->
<!-- IF {PAGE_PRODUCT_PRICE} -->
<div>Price: {PAGE_PRODUCT_PRICE}</div>
<!-- ENDIF -->
Chapter 7.2. Travel blog
Extrafields:
| Name | Type | Description |
|---|---|---|
travel_country | Country | Country |
travel_city | Input | City |
travel_season | Select | Season |
travel_budget | Currency | Budget |
travel_days | InputInt | Days |
Values for travel_season:
Spring
Summer
Autumn
Winter
Year-round
Chapter 7.3. Real estate catalog
Extrafields:
| Name | Type | Description |
|---|---|---|
estate_area | Double | Area |
estate_rooms | InputInt | Rooms |
estate_floor | InputInt | Floor |
estate_floors_total | InputInt | Total floors in the building |
estate_has_balcony | Checkbox | Balcony |
estate_price | Currency | Price |
Chapter 7.4. Photographer's portfolio
Extrafields:
| Name | Type | Description |
|---|---|---|
photo_camera | Input | Camera |
photo_lens | Input | Lens |
photo_iso | InputInt | ISO |
photo_shutter | Input | Shutter speed |
photo_aperture | Input | Aperture |
Chapter 7.5. Culinary website
Extrafields:
| Name | Type | Description |
|---|---|---|
recipe_time | InputInt | Time, min |
recipe_portions | InputInt | Servings |
recipe_calories | InputInt | Calories |
recipe_difficulty | Select | Difficulty |
Values for recipe_difficulty:
Easy
Medium
Hard
Part 8. Common mistakes and how to solve them
Error 1. Field doesn't display on the page
| Cause | Solution |
|---|---|
| Typo in the tag name | Check the spelling and case |
| Field is not filled in | Fill it in the admin panel |
| Cache not cleared | Clear the cache |
| Wrong template | Make sure you're editing page.tpl, not another file |
Error 2. Field doesn't display in the edit form
| Cause | Solution |
|---|---|
| Field is disabled | Tick the "Enabled" checkbox |
| Field created for another table | Check field_location |
| No rights | Log in as a super administrator |
Error 3. Field can't be created
| Cause | Solution |
|---|---|
| Name contains forbidden characters | Only Latin letters, digits, underscore |
| Name is taken | Come up with another one |
| No rights | Check your group's rights |
Error 4. Error when saving a page
| Cause | Solution |
|---|---|
| Value out of range | Check min/max |
| Invalid number format | Use a dot, not a comma |
| Value doesn't match the type | Check your input |
Error 5. Value displays incorrectly
| Cause | Solution |
|---|---|
| HTML code in the value | Use the correct filter |
| Date in timestamp format | Configure the format in the parameters |
| Special characters | Check the file encoding |
Error 6. Field disappeared after an update
| Cause | Solution |
|---|---|
| Core update | Check cot_extra_fields, restore from backup |
Error 7. Field duplicated in the form
| Cause | Solution |
|---|---|
| Field created twice | Delete the duplicate |
| Plugin adds its own field | Disable the plugin |
Part 9. Advanced techniques
Chapter 9.1. Grouping fields by sections
If there are many extrafields, the edit form becomes unwieldy. One way is to use categories for grouping.
Chapter 9.2. Required fields
Make critical fields required so that authors don't forget to fill them in.
Chapter 9.3. Default values
For status fields, it's useful to set a default value: for example, when a new page is created, the status automatically becomes "Draft."
Chapter 9.4. Using for SEO
Extrafields can be used for SEO: outputting meta tags, descriptions, keywords.
Chapter 9.5. Output in other places on the site
Extrafields can be output not only on the page, but also in lists, widgets, and special blocks.
| Where | Tag prefix |
|---|---|
| Page (single) | PAGE_ |
| Pages list | PAGE_ROW_ |
| Widget on the home page | Depends on the widget |
Chapter 9.6. Sorting and filtering
You can sort and filter pages by extrafields, but this requires special plugins or additional configuration.
Chapter 9.7. Exporting and importing values
If you have thousands of pages, filling in extrafields manually is inconvenient. There are two paths: direct work with the database or plugins for import.
Chapter 9.8. Backup
Before creating new extrafields, always back up the database.
Part 10. Answers to beginner questions
Question 1. How many extrafields can I create?
Technically — up to a thousand fields per table. Practically — no more than 20–30 is recommended, so as not to overload the edit form.
Question 2. Can extrafields be used in other modules?
Yes, each module has its own extrafields: users, forums, store.
Question 3. What if an extrafield is no longer needed?
You can disable the field or delete it. Disabling is safer — the data is preserved.
Question 4. How do I change the field type?
The field type cannot be changed after creation. You need to delete the old one and create a new one.
Question 5. Can I make an extrafield required?
Yes, there's a "Required" checkbox in the settings.
Question 6. What happens to extrafields when Cotonti is updated?
Extrafields are preserved during updates.
Question 7. How do I move extrafields to another site?
By exporting/importing the cot_extra_fields and cot_pages tables.
Question 8. Can extrafields be used in filters?
Yes, but this requires development or ready-made plugins.
Question 9. Can I create an extrafield via the API?
Yes, there's an API for creating fields.
Question 10. How do I optimize work with a large number of extrafields?
Tips: don't create unused fields, use caching, divide fields into groups.
Question 11. Do extrafields affect site speed?
One or two fields — no. Many fields (30+) can slow down data retrieval.
Question 12. How do I check that an extrafield works?
Create a page, fill in the field, save it, open the page.
Question 13. What if an extrafield displays in the wrong place?
Check the tag insertion point in the template.
Question 14. Can extrafields be styled?
Yes, you can assign a CSS class to each field.
Question 15. Do extrafields work in the mobile version?
Yes, if they're correctly inserted into the template.
Conclusion
Extrafields are a powerful and convenient Cotonti tool that allows you to expand a site's functionality without programming. With them, you can add any fields to pages, users, products, and other entities.
We've covered and hopefully helped find answers to the questions:
- What are extrafields and why are they needed?
- Which field types does Cotonti support?
- How do I create an extrafield for the Page module?
- How do I output an extrafield in templates?
- What mistakes can occur and how do I solve them?
- What advanced capabilities exist?
Main rules:
- Always make a backup before creating extrafields.
- Plan fields in advance.
- Give meaningful names.
- Clear the cache after changes.
- Use conditional output so that empty fields are not shown.
Ask any questions about extrafields in Cotonti on the forum!