Datalynx Tags

From MoodleDocs


Datalynx tags are special patterns used in the view settings as a placeholder. These tags inserted in the settings will then be replaced in the view with dynamically created data.

Example 1: The tag ##author:firstname##, is placed in the view setting "entry template". The user "Micheal Mulley" creates a new entry. The owner of this entry is Micheal Mulley. Viewing the entry will now display "Micheal" in the exact place the tag ##author:firstname## was set in the "view settings". The firstname of the author is taken from the users profile field.

Example 2: The tag [[my favourite film]] is placed in the "entry template" settings of a view. Before the field "my favourite film" was created in "Manage -> Fields" (type: text). The user clicks on the button "Add new entry" in the default view. A form will open, where the user can enter his/her favourite film in a form, at the exact place where [[my favourite film]] was put in the view settings "entry template".

Datalynx tag types

There are different types of datalynx tags. They can be divided into "where they can be placed" and "what data can be manipulated".

  • Datalynx field tags: These tags will display the value of a field, in an entry. In editing mode they will show a form element, that is used for data input. Datalynx field tags can only be used in the "entry template" section in the settings of a view.
    • Patterns of a datalynx field tag: This is the pattern used in the view settings as a placeholder
      • [[fieldname]] This will display the value of a field in an entr
      • [[fieldname@]] This will display the content of the "field label", which itself includes a conditional text (that means for example a description of the field and the field value itself. If the field value is empty, the field label will not be shown at all). For a detailed explanation of the field label have a look at [[Datalynx Fields|Fields]]
      • [[fieldname:restricted]] Only users with the capability mod/datalynx:editrestrictedfields can edit or view this field. Per default only the role manager has the capability.
  • Datalynx general tags: These tags can serve as placeholder for various types of information. For example, information about the author, the entry id or a link to another view.

Datalynx tag locations

There are 2 main locations in where to put tags, and some other rare usecases. The main locations are in the settings of a view "view template" and "entry template"

  • View template: These tags have the following properties
    • They do not handle data of a single entry
    • They do not handle data of a single user
    • They handle data of general view properties: Example: ##quicksearch## provides a search field for entering keywords to search all entries.
  • Entry template
    • User data relevant for a single entry. Example: ##author:lastname## displays the last name of the author of an entry in the entry itself
    • Entry properties relevant for a single entry. Example: the id of an entry ##entryid###
    • Field tags. These tags are used to display and edit different types of data in a single entry. Example: [[duration]] will display a duration. The field has to be defined in "Manage -> Fields" prior to be used in a view. In this case the field is of the type "duration".
    • Other tags: These include action tags for approving entries, or comment tags for commenting or rating tags.
  • Other locations
    • Within tags. Example: A tag for creating a download link in order to download a PDF can include the entry id of an entry, that should be exported as PDF.

List of tags

Tag Description Example /Result Locations
##viewurl## The url of the current view http://www.example.com/mod/datalynx/view.php?d=3&view=4 View template, entry template
##viewurl:view-name## The url of a view with the name view-name in the current datalynx.view-name: The name of view that is linked.link-text: The text of the link. Could be html but ';' or any html special chars that would contain ';' if entered in editor mode, cannot be used. A special link-text pattern allows for display theme icons, e.g. _pixicon:f/pdf:Download, _pixicon:i/edit:Edit etc.url-query: Url query parameters that will be added to the view url in the link. These are arg=val pairs separated by |. The args should be expected by the target view to take effect. The vals can be entry patterns. #{{viewlink:Certificate;_pixicon:f/pdf:Download;pdfexportentry=##entryid##|dest=D|docname=[[CertID]]-[[CertYear]][[CertMonth]];}}# Entry template
#{{viewlink:view-name;link-text;url-query;cssclassname}}# View link for each of the datalynx views. #{{viewlink:List of photos;Click here to open the list of photos;;}}#


The url-query can stay undefined or use something link applaying a filter, then the url-query would like this: filter=4. This will create a link to the view „List of photos“

Entry template
#{{viewsesslink:view-name;link-text;url-query;cssclassname}}# Like the above but with session key added to the url. #{{viewsesslink:Single;_pixicon:i/edit:Edit;editentries=##entryid##;btn btn-primary}}#This pattern added to an entry template will display a linked edit icon to a view called Single and will open the entry in edit mode in that view. Link will be displayed as button using bootstrap classes. Entry template
##approve## Approve/Unapprove an entry. Requires, that „approval“ is set in the activity settings Button to approve an entry. The button shows current status, and the status is updated via AJAX (without reloading the whole page) Entry template
##edit## Displays an icon with link to edit this particular entry. Is only shown if user has right to edit the entry. Entry template
##delete## Displays an icon with link to delete this particular entry. Is only shown if user has right to delete the entry. Entry template
##select## A checkbox for multi editing purpose. Automatically added in tabular view Entry template
##export## Generates link to export this particular entry. Entry template
##duplicate## Duplicate the entry Entry template
##status## Only in edit mode: Displays a dropdown to select the status of the entry (Draft or Final submissiont). If final submission is chosen, the entry cannot be edited anymore. Entry template
##comments## Show comments added to the entry Entry template
##comments:count## Show how many comments were added to this entry Entry template
##comments:inline## Show the comments inline Entry template
##anchor## TBC Entry template
##more## Creates a link to the view defined in „Manage → Views“ as „M“ Entry template
##moreurl## Creates only the URL in form of: http://www.example.com/somelinkThis link can then be put in a custom HTML tag. Entry template
##entryid## Displays the id of the entry Entry template
##group:id## Displays group id Entry template
##group:name## Displays group name Entry template
##group:picture## Displays group picture Entry template
##group:edit## In edit mode: Allows to change/choose the group Entry template
##ratings:rate## Display a dropdown menu for choosing a grade Entry template
##ratings:view## Display the rating for the comment Entry template
##ratings:viewinline## Display the ratings inline Entry template
##ratings:avg## Calculates and displays the average rating Entry template
##ratings:count## Displays the number of ratings Entry template
##ratings:max## Displays max. rating Entry template
##ratings:min## Displays lowest rating Entry template
##ratings:sum## Displays the sum of all ratings Entry template
##author:id## Displays the id of the author/owner of the entry Entry template
##author:name## Displays the full localised name of the author depending on the settings of the moodle site. Entry template
##author:edit## In edit mode: Displays a dropdown to choose an author for the entry. Default: Current user. Entry template
##author:firstname## Displays the first name of the author Entry template
##author:lastname## Displays the last name of the author Entry template
##author:username## Displays the username of the author Entry template
##author:idnumber## Displays the id of the author Entry template
##author:picture## Displays the user profile picture of the author Entry template
##author:picturelarge## Displays the user profile picture of the author Entry template
##author:email## Displays the email of the author Entry template
##numentriestotal## Displays the number of all entries View template
##numentriesdisplayed## Displays the number of all entries of the current page View template
##viewurl## Displays the URL of the current vie View template
##viewsmenu## Displays a dropdown menu to choose a view from View template
##filtersmenu## Displays a dropdown menu to choose a filter from View template
##quicksearch## Displays an input field to enter search keywords in order to search all entries View template
##quickperpage## Displays a dropdown menu to select how many entries should be displayed per page View template
##advancedfilter## Displays an advanced filter, in order to give the user the possibility to do a precise search according to many criteria View template
##addnewentry## Display a link to add a new entry View template
##addnewentries## Display a link to add new entries View template
##selectallnone## Display a „select all“ checkbox Entry template
##multiduplicate## Displays a button with a text label „duplicate“ to duplicate multiple entries Entry template
##multiduplicate:icon## Displays a button with a duplicate symbol to duplicate multiple entries Entry template
##multiedit## Displays a button with a text label „edit“ to edit multiple entries Entry template
##multiedit:icon## Displays a button with an edit symbol to edit multiple entries Entry template
##multidelete## Displays a button with the text label „delete“ to delete multiple entries Entry template
##multidelete:icon## Displays a button with a delete symbol to delete multiple entries Entry template
##multiapprove## Displays a button with the text label „approve“ to approve multiple entries Entry template
##multiapprove:icon## Displays a button with an approve symbol to approve multiple entries Entry template
##multiexport## Displays a button with the text label „export“ to export multiple entries Entry template
##multiexport:icon## Displays a button with an export symbol to export multiple entries Entry template
##multiimport## Currently not supported Entry template
##multiimporty:icon## Currently not supported Entry template
##pagingbar## Display a navigatin bar with paging info and previous/next buttons View template
##pagebreak## Insert a page break after an entry in exported PDF

Field tags

Field tags have a simple pattern: The fieldname is enclosed in double square brackets:

[[fieldname]]. All the fieldnames are present in the dropdown menu just below the text area in the view setting „Entry template“.

Variations of the tag:

  • [[fieldname]]: Displays the value of the field in view mode, shows a form element to input data in edit mode.
  • [[*fieldname]]: If the fieldname is preceded by an asterisk, the field will be mandatory when creating/editing an entry. If the field is not filled out, the entry won't be saved and an error message will notice the user to fill out the field.
  • [[fieldname@]]: Displays the values of the field with additional text/HTML as defined in setting „field label“ of the field. This is often used to display a description of the field only when a value is set for the field. In edit mode, the form is always rendered with the as defined in the setting „field label“ of the field.
  • [[fieldname:restricted]]: Only users with the capability mod/datalynx:editrestrictedfields can edit or view this field. Per default only the role manager has the capability.

Bulk edit tags

These tags should only be used in „tabular view“, which is optimized for bulk editing entries. The tag is placed in the table header.

%%fieldname:bulkedit%%

If placed in the table header of the tabular view, a checkbox will appear for the column to enable bulk edit for the column (one column is a field, entries are displayed in rows). In edit mode, changing the first row (first entry displayed in the tabular view) all other rows marked for editing will have the same value as the value chosen for the first row.

Calculation tags

You can display calculations based on entry values. Calculations can be done with fields of type „number“ and other tags like ##numentriestotal##. The following example shows the syntax to use for calculations. This is done in the „entry template“ setting of the view.

Calculation for a single entry

Points Calculation (Conversion example)
[[mypoints_in_test01]] %%F01:=ROUND(0.03*[[!mypoints_in_test01]],2)%%
[[mypoints_in_test02]] %%F02:=ROUND(0.03*[[!mypoints_in_test01]],2)%%
Sum %%F03:=SUM(_F01_,_F02_)%%

Calculation for multiple entries

Entry ##entryid## ##author:name##
[[score01]] %%F##entryid##01:=ROUND(0.03*[[!score01]],2)%%
[[score02]] %%F##entryid##02:=ROUND(0.03*[[!score02]],2)%%
Highscore %%FF##entryid##03:=MAX(_F##entryid##01_,_F##entryid##02_)%%