Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. # Low Variables v2 Fieldtype Bridge
  2.  
  3. Instead of making a variable type, you can also choose to create or modify a custom fieldtype. In order to add Low Variables support to your fieldtype, just create it like you normally would, using Pixel & Tonic’s FieldFrame v1.4.3+ for EE1, or EE2’s Fieldtype API. Then, all you need to do is add a couple of methods to your fieldtype class. It’s a lot like adding Matrix support.
  4.  
  5. ## display_var_field _(required)_
  6.  
  7. Displays the input field on the module home page. You can access the current variable id with `$this->var_id`.
  8.  
  9. ### Arguments
  10.  
  11. - `$var_name` _(string, EE1 only)_ — The name used for the input field.
  12. - `$var_data` _(string)_ — The current variable data.
  13. - `$var_settings` _(array, EE1 only)_ — The current variable’s settings.
  14.  
  15. ### Return
  16.  
  17. A string containing the HTML to be used in the module’s home page.
  18.  
  19. ## display_var_settings
  20.  
  21. If the fieldtype has settings, use this method to display them. You can access the current variable id with `$this->var_id`.
  22.  
  23. ### Arguments
  24.  
  25. - `$var_settings` _(array)_ — The current variable’s settings.
  26.  
  27. ### Return
  28.  
  29. An array containing two elements: the name/label in the first element, the form element(s) in the second.
  30.  
  31. ## save_var_settings
  32.  
  33. Use this method to catch the settings values before saving them to the database. You can access the current variable id with `$this->var_id`.
  34.  
  35. ### Arguments
  36.  
  37. - `$var_settings` _(array)_ — The posted variable’s settings.
  38.  
  39. ### Return
  40.  
  41. An associative array containing the settings to be saved.
  42.  
  43. ## post_save_var_settings (v2.2.0+)
  44.  
  45. Use this method for additional processing when a (new) variable has been saved to the database. You can access the current variable id with `$this->var_id`.
  46.  
  47. ### Arguments
  48.  
  49. - `$var_settings` _(array)_ — The posted variable’s settings.
  50.  
  51. ### Return
  52.  
  53. `NULL`
  54.  
  55. ## save_var_field
  56.  
  57. Use this method to catch the variable value before saving it to the database. You can access the current variable id with `$this->var_id`.
  58.  
  59. ### Arguments
  60.  
  61. - `$var_data` _(string)_ — The posted variable data.
  62. - `$var_settings` _(array, EE1 only)_ — The current variable’s settings.
  63.  
  64. ### Return
  65.  
  66. A string containing the modified variable data to be saved.
  67.  
  68. ## post_save_var
  69.  
  70. Use this method to do something after the variable value has been saved to the database. You can access the current variable id with `$this->var_id` and the settings with `$this->settings`.
  71.  
  72. ### Arguments
  73.  
  74. - `$var_data` _(string)_ — The current variable data.
  75.  
  76. ## display_var_tag
  77.  
  78. Use this method for displaying the variable value in your templates, using the `{exp:low_variables:parse}`, `{exp:low_variables:single}` and `{exp:low_variables:pair}` tags. You can access the current variable id with `$this->var_id` and the variable settings with `$this->settings` (v2.2.1+). For Low Variables version 2.2.0 and _lower_, the settings will be available in the `$tagparams` argument.
  79.  
  80. ### Arguments, EE1
  81.  
  82. - `$tagparams` _(array)_ — The tag parameters.
  83. - `$tagdata` _(string)_ — The current tag data.
  84. - `$var_data` _(string)_ — The current variable’s value.
  85. - `$var_settings` _(array)_ — The current variable’s settings.
  86.  
  87. ### Arguments, EE2
  88.  
  89. - `$var_data` _(string)_ — The current variable’s value.
  90. - `$tagparams` _(array)_ — The tag parameters.
  91. - `$tagdata` _(string)_ — The current tag data.
  92.  
  93. ### Return
  94.  
  95. A string containing the modified tagdata.
  96.  
  97. ## delete_var (v2.2.0+)
  98.  
  99. Use this method for additional processing before a variable is deleted.
  100.  
  101. ### Arguments
  102.  
  103. - `$var_id` _(int)_ — The ID of the variable about to be deleted.
  104.  
  105. ### Return
  106.  
  107. `NULL`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement