A Thelia module to add custom fields to products, content, categories, and folders with multi-language support.
- Create custom fields with different types (text, textarea, wysiwyg, content (ID), product (ID), folder (ID), category (ID))
- Assign custom fields to multiple sources (product, content, category, folder, general)
- Multi-language support for field values
- Tab integration in back-office edit pages
- Twig function for front-office display
composer require thelia/custom-fields-module- Activate the module in the back-office
-
Create Custom Fields: Go to Tools > Custom Fields
- Enter a title and unique code (e.g.,
warranty_period) - Select field type
- Choose which sources can use this field (product, content, category, folder, general)
- Enter a title and unique code (e.g.,
-
Edit Field Values: When editing a product/content/category/folder:
- Navigate to the "Custom Fields" tab
- Enter values for each language using the language selector
- Save changes
-
Edit Field Values General: Go to Tools > Custom Fields
- Navigate to the "General Fields" tab
- Enter values for each language using the language selector
- Save changes
Use the custom_field_value function to display custom field values:
{* Display custom field for current locale *}
{{ custom_field_value('warranty_period', 'product', product_id) }}
{* Display custom general field *}
{{ custom_field_value('warranty_period') }}
{* Display custom field for specific locale *}
{{ custom_field_value('warranty_period', 'product', product_id, 'en_US') }}Parameters:
code: The custom field codesource: Source type (product,content,category,folder) - default :generalsource_id: The entity ID (no need to specify forgeneralsource)locale(optional): Specific locale (defaults to current session locale)
{* In a product template *}
{if custom_field_value('warranty_period', 'product', $PRODUCT_ID)}
<div class="warranty">
<strong>Warranty:</strong>
{custom_field_value('warranty_period', 'product', $PRODUCT_ID)}
</div>
{/if}