Loading...
 
Skip to main content

History: Data Channels

Source of version: 14 (current)

Copy to clipboard
            ! Data Channels

Data channels create a named pipe to run ((profiles)) from user space. One channel per line. Each line is comma delimited and contain channel name, domain, profile, allowed groups.

You use them with ((PluginDataChannel)). Starting in ((Tiki6)), a ((payment)) parameter can be added and thus, the data channel will only be run when the payment is done.


Please see:
http://profiles.tiki.org/Data+Channels

A good example is http://profiles.tiki.org/Project_Management


!!# Usage with trackerfilter/trackerlists
The idea of it is to let you set up a trackerfilter/trackerlist with checkboxes, let the user select the ones they want, and then run a datachannel (profile) on each item. 

Example:

-=Test page=-

!!!# Tracker list multi select tester
{CODE(wrap=>1)}
{trackerfilter filters="2/d:3/d:4/d" noflipflop="y" trackerId="1" fields="2:3:4:5" other_filters="1" checkbox="0/itemId" wiki="tracker checkbox test tpl"}

---

{DATACHANNEL(channel="test_channel" emptyCache="none")}
itemId,external=input[name='itemId[]']:checked
surname,external=input[name^='surname[']
forename,external=input[name^='forename[']
{DATACHANNEL}
{CODE}

-=Pretty tracker template: tracker checkbox test tpl =-

!!!# tracker checkbox test tpl

{CODE(wrap="1")}
{if $checkbox}
{$item.field_values[$checkbox.ix].value|escape}
<input type="{$checkbox.type}" name="{$checkbox.name}[]" value="{if $checkbox.ix > -1}{$item.field_values[$checkbox.ix].value|escape}{else}{$item.itemId}{/if}" />{/if} __{$f_2} {$f_3} {$f_4}:__ {$f_5}
<input type="hidden" name="surname[{$item.itemId}]" value="{$f_3}" />
<input type="hidden" name="forename[{$item.itemId}]" value="{$f_4}" />
{CODE}


-=Note=-
You need is_html enabled and HTMLPurify off at the moment (as of August 2010) for the hidden inputs to work in this example. Could be replaced by {HTML} or some other plugins probably.

!!# Example usage with hidden fields and Tracker plugin

I show this example because external fields only seem to work with tracker fields of type text, not drop-downs.
Tracker number and field numbers need to be adapted to your Tiki site.

This data channel will show how to create a tracker item and a group and a wiki page which shows the tracker item. 

!!!#Create Tracker 2

!!!!Fields
*Field 5 (Town) is of type "text" (this would also work with the ''external'' data channel field syntax)
*Field 6 (Country) is of type "Country selector", which looks like a Drop-down
*Field 7 (Continent) is of type "Drop-down"

{FADE(label="Gory details of fields extraction" icon="y")}{CODE(wrap="1")}[FIELD5]
fieldId = 5
name = Town
permName = town
position = 10
type = t
options =
isMain = y
isTblVisible = y
isSearchable = n
isPublic = y
isHidden = n
sMandatory = y
description =
descriptionIsParsed = n
[FIELD6]
fieldId = 6
name = Country
permName = country
position = 20
type = y
options =
isMain = n
isTblVisible = n
isSearchable = n
isPublic = y
isHidden = n
sMandatory = n
description =
descriptionIsParsed = n
[FIELD7]
fieldId = 7
name = Continent
permName = continent
position = 30
type = d
options = Europe,Africa,Asia,America
isMain = n
isTblVisible = n
isSearchable = n
isPublic = y
isHidden = n
sMandatory = n
description =
descriptionIsParsed = n
{CODE}{FADE}

!!!#Create data channel
Create Data channel in ''Admin'' → ''Admin Home'' → ''Profiles'' → ''Advanced''
^New_Town,tiki://local,template_Add_New_Town,Admins^
This creates a data channel which only admins can use.

!!!# The page which calls the data channel

This contains the Tracker plugin, the datachannels plugin and the JQ plugin which binds them together

{CODE(caption="Create New Town" wrap="1")}-=Create New Town=-

{tracker trackerId="2" fields="5:6:7" showtitle="n" formtag="n"}

{DATACHANNEL(channel="New_Town" buttonLabel="Create" class="channel" debug="y" )}
Town,hidden=
Country,hidden=
Continent,hidden=
{DATACHANNEL}

{JQ()}
// On reporte les changements
$("input[name='ins_5']").bind('change', function() {
  valeur=$(this).val(); // This is the syntax for text fields
  $("input[name='Town']").val(valeur);
});
$("select[name='ins_6']").bind('change', function() {
  valeur=$(this).find("option:selected").val(); // This is the syntax for drop-down fields
  $("input[name='Country']").val(valeur);
});
$("select[name='ins_7']").bind('change', function() {
  valeur=$(this).find("option:selected").val(); // This is the syntax for drop-down fields
  $("input[name='Continent']").val(valeur);
});
{JQ}{CODE}

The JQ plugin will need approval
''View details'' → ''Approve''

!!!# The page which contains the data channel code

{CODE(caption="template_Add_New_Town" wrap="1")}This is the template for the data channel


{CODE(caption="YAML" wrap="1" colors="yaml")}
mappings: #Rename variable for permissions (aka groups)
 varNameTown: $profilerequest:Town$Unnamed Town$
permissions: #Creates a group named after the Town name, with options
 varNameTown:
  autojoin: n
  description: $profilerequest:Continent$ $ - $profilerequest:Country$ $ #The group description uses other variables
  objects:
   -
    type: group
    id: varNameTown
    allow: #Permissions of group varNameTown
     - group_view
     - group_view_members
     - group_add_member
     - group_remove_member
     - group_join
objects:
 -
  type: tracker_item # Create the tracker item
  ref: town_file_id # This is how we reference the tracker item from within the wiki page
  data:
   tracker: 2
   status: open
   values:
    - [ 5,  $profilerequest:Town$Unnamed Town$ ]
    - [ 6,  $profilerequest:Country$ $ ]
    - [ 7,  $profilerequest:Continent$ $ ]
 -
  type: wiki_page # Create a page
  data:
   name: Town $profilerequest:Town$Unnamed Town$
   content: wikicontent:template_Town_Page # the content of the page is defined it this template
   mode: create
   wiki_authors_style: none
{CODE}{CODE}

!!# The page which contains the template for the wiki page which is created with the data channel
This is just to illustrate the use of references.

{CODE(caption="template_Town_Page" wrap="1")}-=Town $profilerequest:Town$Unnamed Town$=-

Blah blah
{trackerlist trackerId="2" itemId="$profileobject:town_file_id$"}

More text{CODE}


-=alias=-
(alias(data channel)) | (alias(datachannel)) |  (alias(DataChannels))