PluginList format control block
The FORMAT control block is used to create individually formatted objects that can then be used in any of the individual OUTPUT methods.
- Available filters
- Basic example
- Examples of the use of the FORMAT control block (format and default value)
- Example with comments
- Using Font Awesome icons instead of content depending on the value of the field content
- Editable inline sample using the table template
- Editable inline sample in a smarty (or wiki) template
- Using Font Awesome icons instead of content depending on the value of the field content
- Display an Item Link (tracker item) linked to another item within a template page
Available filters
Name | Description | Boolean | Sample | Tiki Version |
---|---|---|---|---|
default | Display a default value or a default file when no value is available | no | "empty", "1140" (fileId) | - |
format | format the displayed value to something different that the db value (human readable) | no | "trackerrender", "date", "objectlink", etc. (see format parameters here) | - |
editable | Make the field editable so the value can be changed from the results display. Inline editing (found in admin control panels => trackers) must be enable. Must be used in conjunction with the trackerrender format (see above) and may require mode="raw" when using it with the table output template} | editable="inline" | - |
Note that in some cases the field that will be displayed has its own behavior and it can clash with the format you selected.
IE: A tracker field that is a "title" is pre-formatted as a link. If you set the format as "objectlink" (or you set the display inside a link) the display will end broken as Tiki will try to display a link inside a link.
For the default parameter, it's important to remember that the tracker field "Files" works a bit differently than the others with this parameter. The tracker field Files expect an Id from the File Gallery. When most of the other fields type will display the text of the default parameters the default for "Files" must be an existing file in a gallery. The file can be an "anonymous" portrait file or a plain white image or an image with only the text "Not Available", etc. Whatever you feel right for your usage.
Basic example
In most of the examples shown in PluginList output control block and PluginList advanced output control block you will see a FORMAT control block have been used. E.g. in the example shown for Table output as below, two FORMAT control blocks are used:
{LIST()} {filter type="trackeritem"} {filter content="water"} {OUTPUT(template="table")} {column field="title_link" sort="title" label="Title" mode="raw"} {column field="description" label="Description"} {column field="event_date" sort="tracker_field_18" label="Event Date"} {OUTPUT} {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT} {FORMAT(name="event_date")}{display name="tracker_field_18" format="date"}{FORMAT} {LIST}
The first FORMAT control block defines an object with the name title_link
that is displayed in a specific way - this object reference is then used in the column control block in the body of the table OUTPUT. Similarly the second FORMAT control block defines the event_date
object which is also used in a column control block.
A similar use of the FORMAT control block allows the normal set of Smarty variables, eg {user}
etc, to be made available in Smarty templates - for example:
{FORMAT(name="theuser")} { {user} } {FORMAT}
{{}}
) around user
should have no spaces between them. Spaces are used here only to keep the user variable from being interpreted. This creates a reference object theuser
with the userId of the current user which can then be invoked in a server stored smarty template using the variable {$row.theuser}
.
Examples of the use of the FORMAT control block (format and default value)
{LIST()} {filter field="tracker_id" content="1"} {filter field="tracker_status" content="o"} {OUTPUT()} {DIV(class="h3")}{display name="name"}{DIV} {display name="photo"}%%% {display name="email"} {OUTPUT} {FORMAT(name="name")}{display name="tracker_field_userName"}{FORMAT} {FORMAT(name="photo")}{display name="tracker_field_userPhoto" format="trackerrender" default="1140"}{FORMAT} {FORMAT(name="location")}{display name="tracker_field_userLocation" format="trackerrender" default="Unknown"}{FORMAT} {LIST}
Default parameter applied on the "photo" field will display a default generic image if not file found.
Default parameter applied on the "location" field will display the text "Unknown" if the field is empty.
Example with comments
You might want to display all comments, and this script will retrieve them:
{LIST(cache="n")} {filter type="comment"} {pagination max="10"} {OUTPUT( template="table")} {column field="title"} {column field="comment_content"} {column field="object_link" mode="raw"} {column field="date"} {OUTPUT} {FORMAT( name="object_link")} {display name="object_id" format="objectlink"} {FORMAT} {sort mode="date_desc"} {LIST}
The FORMAT control block defines an object with the name object_link which is displayed in such a way that it is object_id which is displayed and formatted as objectlink; which makes the id clickable. This object reference is then used in the column control block in the body of the OUTPUT table.
This gives us the following result:
Title | Comment | Thread Id | Date |
---|---|---|---|
Non-fatal errors during ugrade | Moving from 1.9.8.3 to 1.10 (3rd Dec) gives a lot of error messages - AFAICS all the ones I saw could be ignored as the changes had already been applied. It would be nice if the setup could detect this a bit more cleanly. MySQL 5.0.45, table type is MYISAM, results are based on post install checks 1) Command: ALTER IGNORE TABLE tiki_comments ADD UNIQUE parentId(parentId, userName, title, commentDate, message_id, in_reply_to) Message: Specified key was too long; max key length is 1000 bytes - Index currently exists as 'no_repeats' with this structure 2) Command: #2005-10-24 sylvieg to boost tiki_stats and tiki_orphan CREATE INDEX toPage on tiki_links (toPage) Message: Duplicate key name 'toPage' - index already exists with this structure 3) Command: #2005-10-25 sylvieg sped up refresh index CREATE INDEX locationPage on tiki_searchindex (location, page) Message: Specified key was too long; max key length is 1000 bytes - index currently exists as 'location' with this structure 4) Command: #2005-11-14 sylvieg CREATE INDEX positionType ON tiki_modules (position, type) Message: Duplicate key name 'positionType' - index currently exists with this structure 5) Command: CREATE INDEX login ON users_users (login) Message: Duplicate key name 'login' - index already exists with this structure 6) Command: # 2006-06-07 sylvieg (merge from 1.9) insert into users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_objects','Can edit object permissions', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_objects' for key 1 - row already exists 7) Command: insert into users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_polls','Can admin polls', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_polls' for key 1 - row already exists 8) Command: INSERT INTO users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_rssmodules','Can admin rss modules', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_rssmodules' for key 1 - row already exists 9) Command: #sylvieg 2006-12-08 ALTER TABLE tiki_objects ADD KEY type (type, objectId) Message: Duplicate key name 'type' - index already exists but with structure 'type','itemId' 10) Command: ALTER TABLE tiki_comments DROP KEY parentId Message: Can't DROP 'parentId'; check that column/key exists - no such index - see 1 above 11) Command: ALTER TABLE tiki_comments DROP KEY parentId_2 Message: Can't DROP 'parentId_2'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_3 Message: Can't DROP 'parentId_3'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_4 Message: Can't DROP 'parentId_4'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_5 Message: Can't DROP 'parentId_5'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_6 Message: Can't DROP 'parentId_6'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_8 Message: Can't DROP 'parentId_8'; check that column/key exists - keys do not exist 12) Command: ALTER TABLE tiki_comments DROP KEY no_repeats Message: Can't DROP 'no_repeats'; check that column/key exists - ? see 1 above. Was this created later? 13) Command: alter table tiki_comments change userName userName varchar(200) not null default '' Message: Specified key was too long; max key length is 1000 bytes - Error seems incongruous since 200 | 548 | 2007-12-03 15:05:14 |
Re: Not in my install | > I've just done a clean install of v1.9.8.3, and there is no WYSIWYG editor in the features, no FCKeditor dir in lib/ > > 🙁 > Note at the top of the documentation page for this feature that it says Since version 1.10, Tikiwiki includes a Wysiwyg... 1.9.8.x still uses the normal editor. You need to upgrade to 1.10 in order to use the new one. Mike. | 547 | 2007-11-29 21:55:35 |
Not in my install | I've just done a clean install of v1.9.8.3, and there is no WYSIWYG editor in the features, no FCKeditor dir in lib/ 🙁 | 546 | 2007-11-29 16:42:54 |
Which Version of Tiki? | Which version of Tiki do the screenshots and such apply to? | 544 | 2007-11-27 02:58:51 |
Re: 404 Error on images | > 🙁 All images on this page show this error message: > "Not Found > > The requested URL /tmp/_htaccess_subdir was not found on this server. > > Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." Thanks, maryluke for reporting: fixed. 😉 Cheers | 543 | 2007-11-24 15:15:36 |
agreed | "Why? You guys do not realize how difficult it is for a newbie to get into Wiki. (You have forgotten?)" I agree. How can we get your help? | 542 | 2007-11-24 13:22:12 |
serious problem | Following this thread I see the details of my problem. But nothing tells me where to find the Smarty php code I need to change (fix) ??? | 541 | 2007-11-22 16:26:52 |
Executive Summary and newbie support | As a newbie, I find becoming familiar with Tiki daunting. I suggest an executive summary (for newbies). It would answer some of the following questions(with links): Where can I find a brief but comprehensive description of Tikiwiki and available features? I am an experienced professional editor but cannot figure out where or how to edit the documentation (without messing something up). The question marks (in the author documentation invitation) do not work (link?)for me. Solution: Assign a "councilor" to each newbie to answer quetions. Why? You guys do not realize how difficult it is for a newbie to get into Wiki. (You have forgotten?) By listening to newbies you will come to realizer how obscure current help documentation is (and can therefore fix it. I will help as soon as I figure out how. I also suggest a "newbie dumb question forum", where newbies can describe the difficulties that they are encountering. (I could fill many pages right now.) This would inform the documentation team. donz minor points: Why is there no edit help here in the comments section? Why is Tikiwiki underlined as misspelled? Why does it not correct? Where can I find answers to questions like these? Where can I post questions like these? | 539 | 2007-11-17 15:11:42 |
Who is "User?" | Is this page for Joe User, who just wants to type a word or two into the search box and find what he's looking for? If so, shouldn't this be where the Boolian search terms, etc., are found? I think Joe wants to know what to put into the search box and what he can expect out of it. I've been VERY frustrated by the results of the search module and have been looking all over tw.o sites unsuccessfully for some help. The feature needs BIG help if my experience is what others also experience. | 538 | 2007-10-30 22:46:04 |
Case insensitive search | The search is performed in case-insensitive fashion. It means that if you look for "tiki", you will find objects than contain the word "Tiki" and not "tiki". If it is case insensitive, it will find BOTH "Tiki" and "tiki." Which is it? Sensitive or insensitive? And,of course, "that contain" not "than contain." | 537 | 2007-10-30 22:36:37 |
We see that this only gives us the information about the object (the comment in this case), but what if I want to have more information before visiting the comment?
One way to do this is to add a column which indicates the item being commented on. It is typically a wiki page or tracker item which is clickable and takes me there.
So let's make some changes and see what we have:
{LIST(cache="n")} {filter type="comment"} {pagination max="10"} {OUTPUT( template="table")} {column field="contributors"} {column field="title"} {column field="comment_content"} {column field="parent_object_title" mode="raw"} {column field="object_link" mode="raw"} {column field="date"} {OUTPUT} {FORMAT( name="object_link")} {display name="object_id" format="objectlink"} {FORMAT} {FORMAT( name="parent_object_title")} {display name="parent_object_type"}: {display name="wikiplugin_objectlink" format="wikiplugin" type="parent_object_type" id="parent_object_id"} {FORMAT} {sort mode="date_desc"} {LIST}
Here we have just added a new column whose label is "Parent Object".
The new FORMAT control block formats the parent_object_title field, which is the title of the comment's parent object, then with {display} tag we first display the name of the parent object, which is stored in the parent_object_type field. For example, if the parent object is a trackeritem, it will display "trackeritem:", and finally we display the link to the parent object, using the wikiplugin_objectlink plugin. This plugin allows you to create a link to a Tiki object according to its type and its identifier. Here you specify the link format as "wikiplugin", the object type as parent_object_type, and the object id as parent_object_id. For example, if the parent object is a trackeritem with id 1, this will generate a link to "tiki-view_tracker_item.php?itemId=1".
So you get a field that displays the name and link of the comment's parent object. For example, if the comment is linked to an item called "This is my first item", you display "trackeritem: This is my first item".
This gives us the following result:
Title | Comment | Parent Object | Thread Id | Date |
---|---|---|---|---|
Non-fatal errors during ugrade | Moving from 1.9.8.3 to 1.10 (3rd Dec) gives a lot of error messages - AFAICS all the ones I saw could be ignored as the changes had already been applied. It would be nice if the setup could detect this a bit more cleanly. MySQL 5.0.45, table type is MYISAM, results are based on post install checks 1) Command: ALTER IGNORE TABLE tiki_comments ADD UNIQUE parentId(parentId, userName, title, commentDate, message_id, in_reply_to) Message: Specified key was too long; max key length is 1000 bytes - Index currently exists as 'no_repeats' with this structure 2) Command: #2005-10-24 sylvieg to boost tiki_stats and tiki_orphan CREATE INDEX toPage on tiki_links (toPage) Message: Duplicate key name 'toPage' - index already exists with this structure 3) Command: #2005-10-25 sylvieg sped up refresh index CREATE INDEX locationPage on tiki_searchindex (location, page) Message: Specified key was too long; max key length is 1000 bytes - index currently exists as 'location' with this structure 4) Command: #2005-11-14 sylvieg CREATE INDEX positionType ON tiki_modules (position, type) Message: Duplicate key name 'positionType' - index currently exists with this structure 5) Command: CREATE INDEX login ON users_users (login) Message: Duplicate key name 'login' - index already exists with this structure 6) Command: # 2006-06-07 sylvieg (merge from 1.9) insert into users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_objects','Can edit object permissions', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_objects' for key 1 - row already exists 7) Command: insert into users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_polls','Can admin polls', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_polls' for key 1 - row already exists 8) Command: INSERT INTO users_permissions (permName,permDesc,level,type) values ('tiki_p_admin_rssmodules','Can admin rss modules', 'admin', 'tiki') Message: Duplicate entry 'tiki_p_admin_rssmodules' for key 1 - row already exists 9) Command: #sylvieg 2006-12-08 ALTER TABLE tiki_objects ADD KEY type (type, objectId) Message: Duplicate key name 'type' - index already exists but with structure 'type','itemId' 10) Command: ALTER TABLE tiki_comments DROP KEY parentId Message: Can't DROP 'parentId'; check that column/key exists - no such index - see 1 above 11) Command: ALTER TABLE tiki_comments DROP KEY parentId_2 Message: Can't DROP 'parentId_2'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_3 Message: Can't DROP 'parentId_3'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_4 Message: Can't DROP 'parentId_4'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_5 Message: Can't DROP 'parentId_5'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_6 Message: Can't DROP 'parentId_6'; check that column/key exists Command: ALTER TABLE tiki_comments DROP KEY parentId_8 Message: Can't DROP 'parentId_8'; check that column/key exists - keys do not exist 12) Command: ALTER TABLE tiki_comments DROP KEY no_repeats Message: Can't DROP 'no_repeats'; check that column/key exists - ? see 1 above. Was this created later? 13) Command: alter table tiki_comments change userName userName varchar(200) not null default '' Message: Specified key was too long; max key length is 1000 bytes - Error seems incongruous since 200 | wiki page: Upgrade 1.9.7 to 1.10 | 548 | 2007-12-03 15:05:14 |
Re: Not in my install | > I've just done a clean install of v1.9.8.3, and there is no WYSIWYG editor in the features, no FCKeditor dir in lib/ > > 🙁 > Note at the top of the documentation page for this feature that it says Since version 1.10, Tikiwiki includes a Wysiwyg... 1.9.8.x still uses the normal editor. You need to upgrade to 1.10 in order to use the new one. Mike. | wiki page: Wysiwyg Editor Admin | 547 | 2007-11-29 21:55:35 |
Not in my install | I've just done a clean install of v1.9.8.3, and there is no WYSIWYG editor in the features, no FCKeditor dir in lib/ 🙁 | wiki page: Wysiwyg Editor Admin | 546 | 2007-11-29 16:42:54 |
Which Version of Tiki? | Which version of Tiki do the screenshots and such apply to? | wiki page: Forum Admin | 544 | 2007-11-27 02:58:51 |
Re: 404 Error on images | > 🙁 All images on this page show this error message: > "Not Found > > The requested URL /tmp/_htaccess_subdir was not found on this server. > > Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." Thanks, maryluke for reporting: fixed. 😉 Cheers | wiki page: Apache Clean URLs | 543 | 2007-11-24 15:15:36 |
agreed | "Why? You guys do not realize how difficult it is for a newbie to get into Wiki. (You have forgotten?)" I agree. How can we get your help? | wiki page: Editorial Board Meeting 2007 09 | 542 | 2007-11-24 13:22:12 |
serious problem | Following this thread I see the details of my problem. But nothing tells me where to find the Smarty php code I need to change (fix) ??? | wiki page: Login | 541 | 2007-11-22 16:26:52 |
Executive Summary and newbie support | As a newbie, I find becoming familiar with Tiki daunting. I suggest an executive summary (for newbies). It would answer some of the following questions(with links): Where can I find a brief but comprehensive description of Tikiwiki and available features? I am an experienced professional editor but cannot figure out where or how to edit the documentation (without messing something up). The question marks (in the author documentation invitation) do not work (link?)for me. Solution: Assign a "councilor" to each newbie to answer quetions. Why? You guys do not realize how difficult it is for a newbie to get into Wiki. (You have forgotten?) By listening to newbies you will come to realizer how obscure current help documentation is (and can therefore fix it. I will help as soon as I figure out how. I also suggest a "newbie dumb question forum", where newbies can describe the difficulties that they are encountering. (I could fill many pages right now.) This would inform the documentation team. donz minor points: Why is there no edit help here in the comments section? Why is Tikiwiki underlined as misspelled? Why does it not correct? Where can I find answers to questions like these? Where can I post questions like these? | wiki page: Editorial Board Meeting 2007 09 | 539 | 2007-11-17 15:11:42 |
Who is "User?" | Is this page for Joe User, who just wants to type a word or two into the search box and find what he's looking for? If so, shouldn't this be where the Boolian search terms, etc., are found? I think Joe wants to know what to put into the search box and what he can expect out of it. I've been VERY frustrated by the results of the search module and have been looking all over tw.o sites unsuccessfully for some help. The feature needs BIG help if my experience is what others also experience. | wiki page: Search User | 538 | 2007-10-30 22:46:04 |
Case insensitive search | The search is performed in case-insensitive fashion. It means that if you look for "tiki", you will find objects than contain the word "Tiki" and not "tiki". If it is case insensitive, it will find BOTH "Tiki" and "tiki." Which is it? Sensitive or insensitive? And,of course, "that contain" not "than contain." | wiki page: Search Details | 537 | 2007-10-30 22:36:37 |
Using Font Awesome icons instead of content depending on the value of the field content
Tweaking the sample above and using font awesome (integrated in Tiki) you can display corresponding icons for a content.
In this demo case we have a tracker with a "gender" field that hold 2 values, "male" or "female". There is a "male" and a "female" icon in Font Awesome and as both use the same term we can assign it to a div type icon and class.
{LIST()} {filter field="tracker_id" content="42"} {OUTPUT(template="table")} {column label="Title" field="title" sort="title"} {column label="Gender" field="gender"} {OUTPUT} {FORMAT(name="gender")}{DIV(type=i class=fa fa-{display name="tracker_field_gender"})}{DIV}{FORMAT} {LIST}
Editable inline sample using the table template
{column label="First Name" field="firstName" mode=raw} ... {FORMAT(name="firstName")}{display name="tracker_field_firstName" format=trackerrender editable=inline}{FORMAT}
Editable inline sample in a smarty (or wiki) template
In this wikiplugin embedded in a smarty (or wiki) template the field is set to be editable inline (note: format="trackerrender" is required ad well as the Inline editing (found in admin control panels=>trackers)
{wikiplugin _name=list} {literal} {filter content="2" field="tracker_id"} {output(template="mytemplate.tpl")} {ALTERNATE()} empty {ALTERNATE} {FORMAT(name="name")}{display name="tracker_field_name" editable="inline" format="trackerrender" default=""}{FORMAT} {/literal} {/wikiplugin}
So the 2nd column uses a FORMAT plugin where the contents of the field in question, tracker_field_data, is used as the class for a div but the default (used if the data field is empty) is set to be the bootstrap class "hidden" so the contents, the check mark, only appears if there is some data.
Obviously if the data is the name of some other class weird stuff might happen, but for most usual cases, it works as expected and saves having to make a new smarty template just for this simple list.
(Tip and example taken from a message from JonnyB in the developers list - thanks!)
Using Font Awesome icons instead of content depending on the value of the field content
Tweaking the sample above and using font awesome (integrated in Tiki) you can display corresponding icons for a content.
In this demo case we have a tracker with a "gender" field that hold 2 values, "male" or "female". There is a "male" and a "female" icon in Font Awesome and as both use the same term we can assign it to a div type icon and class.
{LIST()} {filter field="tracker_id" content="42"} {OUTPUT(template="table")} {column label="Title" field="title" sort="title"} {column label="Gender" field="gender"} {OUTPUT} {FORMAT(name="gender")}{DIV(type=i class=fa fa-{display name="tracker_field_gender"})}{DIV}{FORMAT} {LIST}
It will display a if the content of the field = male and a if the content of the field = female.
Display an Item Link (tracker item) linked to another item within a template page
When you use a template to display your plugin list you want other item related or linked to the item to open using the same template (or another it doesn't matter) but not to open the trackers built-in system. For this you need to enable the Alias feature and set it to use the template to display the tracker item, "record-" for this sample.
When you use an item link to link an item to other item (related, friend of, etc.) this is a kind of a problem.
Item link has 2 option to display and item link. Value and Link.
Value display the id of the content (ie: 6).
Link display the value of the content linked to the tracker item (ie: Bernard).
Your link should be like:
[record-6|Bernard]
So it open the item "Id6" in the "record-" template showing the value "Bernard" for the link.
To achieve this you need to create and use 2 row.
{FORMAT(name="name")}{display name="tracker_field_contact" format=trackerrender}{FORMAT} {FORMAT(name="id")}{display name="tracker_field_contact"}{FORMAT}
The first one with format=trackerrender will display the content of the tracker Item Link field as it is shown in the tracker (Bernard).
The second one without the format=trackerrender will show the real value for this field (6).
The assemble your link as follow:
[record-{display name="id"}|{display name="name"}]
It will complete the trick and open the item 6 using the record- template while the link displayed will show the right value, Bernard.