|
1 | 1 | # jcr_link_custom |
2 | 2 |
|
3 | | -Adds up to five extra custom fields of up to 255 characters to the [Content › Links](http://docs.textpattern.io/administration/links-panel) panel and provides a corresponding tag to output the custom field. |
| 3 | +Adds up to five extra custom fields of up to 255 characters to the |
| 4 | +[Content › Links](http://docs.textpattern.io/administration/links-panel) |
| 5 | +panel along with corresponding tags to output the custom field and to |
| 6 | +test if it contains a value or matches a specific value. |
4 | 7 |
|
| 8 | +### Use cases |
5 | 9 |
|
6 | | -## Use cases |
| 10 | +Use whenever extra information needs to be stored with a link. For |
| 11 | +example: |
7 | 12 |
|
8 | | -Use whenever extra information needs to be stored with a link. For example: |
| 13 | +- Store a txp image ID number and use it to attach a logo to a link. |
| 14 | +- Store associated details, for example the location of a linked |
| 15 | + organisation. |
| 16 | +- ... |
9 | 17 |
|
10 | | -- Store a txp image ID number and use it to attach a logo to a link. |
11 | | -- Store associated details, for example the location of a linked organisation. |
12 | | -- … |
| 18 | +## Installation / Deinstallation / Upgrading |
13 | 19 |
|
| 20 | +### Installation |
14 | 21 |
|
15 | | -## Installation |
| 22 | +Paste the `.txt` installer code into the *Admin › Plugins* panel, or |
| 23 | +upload the plugin's `.php` file via the *Upload plugin* button, then |
| 24 | +install and enable the plugin. |
16 | 25 |
|
17 | | -Paste the code into the *Admin › Plugins* panel, install and enable the plugin. |
| 26 | +### Upgrading |
18 | 27 |
|
| 28 | +The plugin automatically migrates custom field data and the database |
| 29 | +structure from the earlier single custom field variant (v0.1) to the new |
| 30 | +format. No changes are needed to the public tags as the new default |
| 31 | +settings correspond to the old tag. Nevertheless, it is always advisable |
| 32 | +to make a database backup before upgrading. |
19 | 33 |
|
20 | | -## Tags |
| 34 | +### De-installation |
21 | 35 |
|
22 | | -### txp:jcr_link_custom |
| 36 | +The plugin cleans up after itself: deinstalling (deleting) the plugin |
| 37 | +removes the extra columns from the database as well as custom field |
| 38 | +names and labels. To stop using the plugin but keep the custom field |
| 39 | +data in the database, just disable (deactivate) the plugin but don't |
| 40 | +delete it. |
23 | 41 |
|
24 | | -Outputs the content of the link custom field. |
25 | | - |
26 | | -#### Tag attributes |
| 42 | +## Plugin tags |
27 | 43 |
|
28 | | -`name` |
29 | | -Specifies the name of the link custom field. |
30 | | -Example: Use `name="image_id"` to output the image_id custom field. Default: jcr_link_custom_1. |
| 44 | +### jcr_link_custom |
31 | 45 |
|
32 | | -`escape` |
33 | | -Escape HTML entities such as `<`, `>` and `&` prior to echoing the field contents. |
34 | | -Supports extended escape values in txp 4.8+ |
35 | | -Example: Use `escape="textile"` to convert textile in the value. Default: none. |
| 46 | +Outputs the content of the link custom field. |
36 | 47 |
|
37 | | -`default` |
38 | | -Specifies the default output if the custom field is empty |
39 | | -Example: Use `default="123"` to output "123", e.g. for use as the default image ID number. Default: empty. |
| 48 | +#### Tag attributes |
40 | 49 |
|
41 | | -`wraptag` |
42 | | -Wrap the custom field contents in an HTML tag |
43 | | -Example: Use `wraptag="h2"` to output `<h2>Custom field value</h2>`. Default: empty. |
| 50 | +`name`\ |
| 51 | +Specifies the name of the link custom field.\ |
| 52 | +Example: Use `name="image_id"` to output the image_id custom field. |
| 53 | +Default: jcr_link_custom_1. |
| 54 | + |
| 55 | +`escape`\ |
| 56 | +Escape HTML entities such as `<`, `>` and `&` prior to echoing the field |
| 57 | +contents.\ |
| 58 | +Supports extended escape values in txp 4.8+\ |
| 59 | +Example: Use `escape="textile"` to convert textile in the value. |
| 60 | +Default: none. |
| 61 | + |
| 62 | +`default`\ |
| 63 | +Specifies the default output if the custom field is empty\ |
| 64 | +Example: Use `default="123"` to output "123", e.g. for use as the |
| 65 | +default image ID number. Default: empty. |
| 66 | + |
| 67 | +`wraptag`\ |
| 68 | +Wrap the custom field contents in an HTML tag\ |
| 69 | +Example: Use `wraptag="h2"` to output `<h2>Custom field value</h2>`. |
| 70 | +Default: empty. |
44 | 71 |
|
45 | | -`class` |
46 | | -Specifies a class to be added to the `wraptag` attribure |
47 | | -Example: Use `wraptag="p" class="intro"` to output `<p class="intro">Custom field value</p>`. Default: empty |
| 72 | +`class`\ |
| 73 | +Specifies a class to be added to the `wraptag` attribute\ |
| 74 | +Example: Use `wraptag="p" class="intro"` to output |
| 75 | +`<p class="intro">Custom field value</p>`. Default: empty |
48 | 76 |
|
49 | | -### txp:jcr_if_link_custom |
| 77 | +### jcr_if_link_custom |
50 | 78 |
|
51 | | -Tests for existence of a link custom field, or whether one or several matches a value or pattern. |
| 79 | +Tests for existence of a link custom field, or whether one or several |
| 80 | +matches a value or pattern. |
52 | 81 |
|
53 | 82 | #### Tag attributes |
54 | 83 |
|
55 | | -`name` |
56 | | -Specifies the name of the link custom field. |
57 | | -Example: Use `name="image_id"` to output the image_id custom field. Default: jcr_link_custom_1. |
58 | | - |
59 | | -`value` |
60 | | -Value to test against (optional). |
61 | | -If not specified, the tag tests for the existence of any value in the specified link custom field. |
62 | | -Example: Use `value="english"` to output only those links whose “language” link custom field is english. Default: none. |
63 | | - |
64 | | -`match` |
65 | | -Match testing: exact, any, all, pattern. See the docs for [if_custom_field](https://docs.textpattern.com/tags/if_custom_field). |
| 84 | +`name`\ |
| 85 | +Specifies the name of the link custom field.\ |
| 86 | +Example: Use `name="image_id"` to output the image_id custom field. |
| 87 | +Default: jcr_link_custom_1. |
| 88 | + |
| 89 | +`value`\ |
| 90 | +Value to test against (optional).\ |
| 91 | +If not specified, the tag tests for the existence of any value in the |
| 92 | +specified link custom field.\ |
| 93 | +Example: Use `value="english"` to output only those links whose |
| 94 | +"language" link custom field is english. Default: none. |
| 95 | + |
| 96 | +`match`\ |
| 97 | +Match testing: exact, any, all, pattern. See the docs for |
| 98 | +[if_custom_field](https://docs.textpattern.com/tags/if_custom_field).\ |
66 | 99 | Default: exact. |
67 | 100 |
|
68 | | -`separator` |
69 | | -Item separator for match="any" or "all". Otherwise ignored |
| 101 | +`separator`\ |
| 102 | +Item separator for match="any" or "all". Otherwise ignored.\ |
70 | 103 | Default: empty. |
71 | 104 |
|
| 105 | +## Examples |
72 | 106 |
|
73 | | -## Example |
74 | | - |
75 | | -Produce a list of linked partner logos (from link assigned to the link category "partners"): |
76 | | - |
77 | | -``` |
78 | | -<txp:linklist wraptag="ul" break="li" category="partners"> |
79 | | - <txp:jcr_if_link_custom name="image_id" value=""> |
80 | | - <a href="<txp:link_url />" title="<txp:link_name />"><txp:link_name /></a> |
81 | | - <txp:else /> |
82 | | - <a href="<txp:link_url />" title="<txp:link_name />"><txp:image id='<txp:jcr_link_custom name="image_id" />' limit="1" /></a> |
83 | | - </txp:jcr_if_link_custom> |
84 | | -</txp:linklist> |
85 | | -``` |
86 | | - |
87 | | -when the "image_id" link custom field is used to store the Image ID# of the logo. |
| 107 | +### Example 1 |
88 | 108 |
|
| 109 | +Produce a list of linked partner logos (from link assigned to the link |
| 110 | +category "partners"): |
89 | 111 |
|
90 | | -## Changing the label of the custom field |
| 112 | + <txp:linklist wraptag="ul" break="li" category="partners"> |
| 113 | + <txp:jcr_if_link_custom name="image_id" value=""> |
| 114 | + <a href="<txp:link_url />" title="<txp:link_name />"><txp:link_name /></a> |
| 115 | + <txp:else /> |
| 116 | + <a href="<txp:link_url />" title="<txp:link_name />"><txp:image id='<txp:jcr_link_custom name="image_id" />' limit="1" /></a> |
| 117 | + </txp:jcr_if_link_custom> |
| 118 | + </txp:linklist> |
91 | 119 |
|
92 | | -The name of custom field can be changed by specifying a new label using the *Install from Textpack* field in the [Admin › Languages](http://docs.textpattern.io/administration/languages-panel) panel. Enter your own information in the following pattern and click **Upload**: |
| 120 | +where the `image_id` link custom field is used to store the Image ID\# |
| 121 | +of the logo. |
93 | 122 |
|
94 | | -``` |
95 | | -#@admin |
96 | | -#@language en-gb |
97 | | -jcr_link_custom_1 => Your label |
98 | | -jcr_link_custom_2 => Your other label |
99 | | -``` |
| 123 | +## Custom field labels |
100 | 124 |
|
101 | | -replacing `en-gb` with your own language and `Your label` with your own desired label. |
| 125 | +The label displayed alongside the custom field in the edit image panel |
| 126 | +can be changed by specifying a new label using the *Install from |
| 127 | +Textpack* field in the [Admin › |
| 128 | +Languages](http://docs.textpattern.io/administration/languages-panel.html) |
| 129 | +panel. Enter your own information in the following pattern and click |
| 130 | +**Upload**: |
102 | 131 |
|
| 132 | + #@owner jcr_link_custom |
| 133 | + #@language en, en-gb, en-us |
| 134 | + #@link |
| 135 | + jcr_link_custom_1 => Your label |
| 136 | + jcr_link_custom_2 => Your other label |
103 | 137 |
|
104 | | -## De-installation |
| 138 | +replacing `en` with your own language and `Your label` with your own |
| 139 | +desired label. |
105 | 140 |
|
106 | | -The plugin cleans up after itself: deinstalling the plugin removes the extra column from the database. To stop using the plugin but keep the database tables, just disable (deactivate) the plugin but don't delete it. |
107 | | - |
108 | | - |
109 | | -## Changelog + Credits |
| 141 | +## Changelog and credits |
110 | 142 |
|
111 | 143 | ### Changelog |
112 | 144 |
|
113 | | -- Version 0.2 – 2020/06/23 – Expand to handle multiple custom fields + migrate from v1 |
114 | | -- Version 0.1.1 – 2016/12/0518 – Remedy table not being created on install |
115 | | -- Version 0.1 – 2016/03/04 – First release |
116 | | - |
| 145 | +- Version 0.2.4 -- 2020/12/20 -- Align with other custom field plugins |
| 146 | +- Version 0.2.3 -- 2020/06/29 -- Tag registration + textpack fixes |
| 147 | +- Version 0.2.2 -- 2020/06/27 -- Handle migration from previous |
| 148 | + versions of the plugin on install |
| 149 | +- Version 0.2.1 -- 2020/06/27 -- Fix for missing custom_field name vs. |
| 150 | + missing value for cf |
| 151 | +- Version 0.2 -- 2020/06/23 -- Expand to handle multiple custom |
| 152 | + fields + migrate from v1 |
| 153 | +- Version 0.1.1 -- 2016/12/0518 -- Remedy table not being created on |
| 154 | + install |
| 155 | +- Version 0.1 -- 2016/03/04 -- First release |
117 | 156 |
|
118 | 157 | ### Credits |
119 | 158 |
|
120 | | -Robert Wetzlmayr’s [wet_profile](https://github.com/rwetzlmayr/wet_profile) plugin for the starting point, and further examples by [Stef Dawson](http://www.stefdawson.com) and [Jukka Svahn](https://github.com/gocom). |
| 159 | +Robert Wetzlmayr's |
| 160 | +[wet_profile](https://github.com/rwetzlmayr/wet_profile) plugin for the |
| 161 | +starting point, and further examples by [Stef |
| 162 | +Dawson](http://www.stefdawson.com) and [Jukka |
| 163 | +Svahn](https://github.com/gocom). |
0 commit comments