Field Groups and SQL Source
Field Groups
Groups organise the fields of a type into tabs, sliders or blocks on the form and in the record.
- Open the type and click Manage Groups
- Click New and add as many groups as you need; drag them to reorder
- When you create or edit a field, assign it to a group
SQL Values Source
Radio, Checkbox, Select, Multiple Select and List Auto Complete can take their values from an SQL query instead of a fixed list.
- In the field parameters, set List values from SQL query to Yes
- Write a query that returns exactly two columns, aliased
idandtext
Example: let users pick one of their HikaShop orders when they open a support ticket.
SELECT order_id AS id, CONCAT('Order: ', order_number) AS text
FROM #__hikashop_order
WHERE order_user_id = [USER_ID]
[USER_ID] is replaced with the ID of the logged-in user.
Process into link
Turn the chosen value into a link. Enter a URL starting with index.php (it goes through Joomla routing) or a full external URL:
index.php?option=com_hikashop&view=order&id=[ID]&Itemid=23
Placeholders: [ID] (the id column of the query), [USER_ID] (the logged-in user) and [AUTHOR_ID] (the record author).
Simple Relations with SQL
For a plain list of linked records, an SQL source is lighter than Parent/Child fields: no templates, just links, and a faster site.
All records of section 3:
SELECT id, title AS text FROM #__js_res_record WHERE section_id = 3
Only type 6, in categories 2 and 3:
SELECT r.id, r.title AS text
FROM #__js_res_record AS r
WHERE r.section_id = 3
AND r.type_id = 6
AND r.id IN (SELECT record_id FROM #__js_res_record_category WHERE catid IN (2,3))
Show the creation date under the title:
SELECT id, CONCAT(title, '<br><small>On: ', DATE_FORMAT(ctime, '%d %M %Y'), '</small>') AS text
FROM #__js_res_record
WHERE section_id = 3
Then link each value to its record:
index.php?option=com_joomcck&view=record&id=[ID]&Itemid=140
Use the Itemid of the section's menu item, so the link opens in the right place.