Advanced examples
#How to embed a Catalog to any layout - two options
You can insert records from any other table using "tables.getrecords" tag:
Example:
{{ tables.getrecords("CountriesPage","population>1000000","name",20) }}
Where CountriesPage is the layout name.
"population>1000000" where condition or the filter
"name" - the field to sort the records by. Descending order is also possible "name desc"
20 - number of records (limit)
You can also do it using IFrame
In case you want to have a functional catalog embedded to a Layout or an article - use HTML IFrame tag. You can provide some URL query parameter to filter catalog records.
Below is an example of a Catalog in side Edit Record Layout:
Where "/index.php/subjects-list" is the link to a menu item that has Custom Tables - Records menu type
"type=3" is a query parameter that we want to pass as a filter parameter.
Where "3" is the ID of the current record, if the page where you want to have a functional catalog is Add/Edit Record or Record Details type.
"tmpl=component" is to not avoid rendering the front-end template.
This is Custom Tables - Records type menu item.
I passed parameter type with the URL query. Now we will use it to filter catalog records.
I have a field "type" in my table. I want to show all the records that have the type id equal to type URL parameter.
{{ url.getint("query parameter" }} is the tag to get URL parameter value.
#How to show records created by the current user
Add menu type: "Custom Tables - Catalog"
Click on Filter tab and the parameter "Search Parameter", set it to "
authoruser={{ user.id }}", where "user" is the name field in your custom table where user ID is stored.
{{ user.id }}will be replaced by the current user id automatically.
This is equal to MySQL query example:
SELECT * FROM #__customtables_table_myfirsttable WHERE es_user=200042
"myfirsttable" is the name of the table, for example.
#How to include one Layout code into another layout
Layout tag example:
{{ document.layout("LayoutName"}}
How it works
The Included layout code and parent layout code will be processed as a single layout.
Works as the "include" method in other computer languages.
This helps to structure layouts.
The
{{ document.layout("LayoutName"}}tag takes all the text/code/markup that exists in the specified layout and copies it into the parent layout that uses the "layout" tag.
Including layouts is very useful when, for example, you want to insert the same Javascript, HTML, or text to multiple pages of a website.
It works recursively.