The Fabrik content plug-in allows you to embed Fabrik content within
- Joomla articles
- Joomla "Custom" Modules (enable "Prepare content" option)
- Fabrik list or form intros/outros
Embedding Forms
Add a new record into a form whose ID is 1:
Add a new record into a form whose ID is 1 and passing parameters to fill
Elements :
Code:
{fabrik view=form id=1 table___element_1=2 table___element_2=1}
Edit form 1, row 1:
Code:
{fabrik view=form id=1 rowid=1}
Show details view of form 1, row 1:
Code:
{fabrik view=details id=1 rowid=1}
Searching for form records to edit
Load form 1, and look for an existing record where the 'user' element has a value of 62. If the record is found, the record will be loaded for editing; if not found, a new record can be entered.
Code:
{fabrik view=form id=1 usekey=user rowid=62}
Load form 1 and look for an existing record where 'user=62 AND status=1'. You can add as many key/value pairs as long as you ensure that each value is separated by a pipe ( | ).
Code:
{fabrik view=form id=1 usekey=user|status rowid=62|1}
Embedding Lists
Embed a list with an ID of 1 into an article.
Options:
- random=1 - Starts showin the ordered records at a random start point (3,1 since 20/11/2013)
- limit=5 limit the # of records shown (3,1 since 20/11/2013)
- fabrik_show_nav=0 hides the list navigation
- elements=732|734 - list of element ids to show separated by a '|' (3,1 since 20/02/2014)
- list-picker=0 - hides the list picker (drop down which appears in admin to swap the list being viewed (3,1 since 20/02/2014)
- hide-add=1 Hide the add button - overrides list's ACL settings, if set to 1. (3,1 since 20/02/2014)
Ordering
Lists
- orderby=tablename___elementname
- orderdir=desc
Reset ordering: clearordering=1
Filtering
Lists
Filter a list to show only records where 'elementname' has a value of 'foobar'.
Code:
{fabrik view=list id=1 tablename___elementname=foobar}
Accessing URL parameters to filter a list:
Code:
{fabrik view=list id=1 tablename___elementname=[param1]}
[param1] is replaced with the value of param1 in the URL (e.g. URL ...option=com_content&view=article&id=11&
param1=foobar)
Reset applied filters (except prefilters):
Code:
{fabrik view=list id=1 resetfilters=1}
Hide the filters:
Code:
{fabrik view=list id=1 showfilters=0}
Filtering
Lists - Advanced
Show rows where
elementname1 is 'abc' AND
elementname2 is one of 1, 4, 8, or 2:
Code:
{fabrik view=list id=4 listname___elementname1=abc listname___elementname2[value]=1,4,8,2 listname___elementname2[condition]=IN}
As you can see you may use almost any string as a condition value.
Those strings have to be "url encoded". So any characters which aren't "legal" on a URL have to be replaced with their %xx equivalent. The most common example is a space (%20), but there are others like single or double quotes.
You can generate urlencoded strings by using online tools like ...
http://www.opinionatedgeek.com/dotnet/tools/urlencode/Encode.aspx
Pay attention that when you use [condition] or similar (see below) for any field, you MUST use [value] for this field too.
You may specify several values for one field using this syntax (may be necessary for some operations like BETWEEN, see example below):
Code:
{ ... listname___elementname[value][]=100 listname___elementname[value][]=200 ... }
By default
is equal condition is used for any value specified for row field. You may specify your own condition for each such field. List of possible conditions is :
Note: Custom template are actual PHP files, rendering directly, so < or a > to render correctly, you have to encode them like:
- <> for <>
- < for <
- > for >
IN(you need a comma-separated list of integers without surrounding quotes or parentheses as a value, see example above. I know nothing about list of text values but suppose each list item should be quoted)
CONTAINS (you should specify a string as a value, and rows containing this string in specified field will be listed)
BETWEEN - see example below
By default all conditions specified joins with logical
AND - they should match all together. If you want
OR instead of
AND - add this for all your conditions (may be except the first):
Code:
{ ... listname___elementname1[value][]=xxx listname___elementname2[value][]=yyy listname___elementname2[join]=OR}
Theoretically you may combine
AND and
OR joins but I'll not explain it because of :
- complexity
- lack of use. AND always executes before OR and I know no 'operation parentheses' for Content plugin. So most likely the result of combining AND and OR will be not those you want.
Ranged filters:
Code:
{ fabrik view=list id=4 listname___elementname[value][]=28/10/1999 listname___elementname[value][]=28/10/2000 listname___elementname[condition]=BETWEEN }
NOTE that the date should be in the table view format, not as a mysql date format.
To get the next 7 days worth of records :
Code:
{fabrik view=list id=1 listname___date_time[value][]=now listname___date_time[value][]=now%2B7+DAYS listname___date_time[condition]=BETWEEN}
The "%B7" is decoded to a '+' and the following '+' is decoded to a space, giving '+7 Days' as the top ranged filter value.
Notice: the element name format listname___elementname
_raw is not usable here although we use this kind of element name when filtering
Lists by database join or
Cascading DropDown element data. Use just
listname___elementname instead, especially when we want display data dynamically using placeholder for a variable (e.g listname___elementname=[rowid]). In content plugin, it retrieves raw data for filter even when there are dbjoin or cdd
Elements while _raw could generate some problems.. See
https://fabrikar.com/forums/index.p...o-_raw-in-j-fabrik-content-plugin-code.22860/
Notice: Filters defiined inside {fabrik view=list......} are
sticky and can not be unset by the user. As such they behave in a similar fashion to list prefilters
Visualizations
Show visualization id 1
Code:
{fabrik view=visualization id=1}
resetfilters and showfilters can be used - see "
Lists"
Element data
Insert list 11 row 239's
Checkbox element's data
Code:
{fabrik view=element list=11 rowid=239 element=element_test___checkbox}
- repeatcounter=X- specify the repeat records value you want to use. Defaults to 0
- repeatcounter=all - will render all the repeat group data, inside a <ul> (3.0 & 3.1 ince 09/10/2013)
- If no rowid is specified then the first row is loaded (3.1 since 16/09/2013)
- random=1 - loads a random record (3,1 since 20/11/2013)
Accessing URL parameters
Code:
{fabrik view=list id=1 tablename___elementname=[param1]}
[param1] is replaced with the value of param1 in the URL (e.g. URL ...option=com_content&view=article&id=11&
param1=foobar)
Common modifiers
Templating
For which ever view you choose, you can change its template by adding :
Hide Form title
Item ID
If you want URL's within the list / form to be routed with a different menu item than the one the plugin is being displayed on, add itemId=X