Skip to content

Commit 38f3927

Browse files
authored
[6.0] Note Custom Field Plugin (joomla#45233)
* Note custom field first code * added sql and updated year in language files * Remvoed unnecessary descriptions and cleaned up xml * Update administrator/language/en-GB/plg_fields_note.ini * Update plugins/fields/note/services/provider.php * moved update sql to own file and undid changes to existing sql * removed unused default option * updated SQL install and update. * added plg_fields_note in right alphabetical order and updated the ordering of the plg_fields to match * hide unused fields * I hid required and default_value. Required would give an error when saving article in front-end/ And default_value is ignored. * added front-end display option & hide more unused settings * Update note.php * fix for proper display_frontend check * filter added to note content and label capitalised. * added white line between field definitions * updated label to be fully capitalised * changed filter type and set editor buttons to false. * fixed different behaviour in title text between frontend and backend * Update administrator/components/com_admin/sql/updates/postgresql/6.0.0-2025-03-27.sql * changed name of sql * Update 6.0.0-2025-08-16.sql
1 parent fe22ff2 commit 38f3927

File tree

11 files changed

+384
-16
lines changed

11 files changed

+384
-16
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
2+
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', -1, 0);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
2+
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', -1, 0);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; Joomla! Project
2+
; (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
3+
; License GNU General Public License version 2 or later; see LICENSE.txt
4+
; Note : All ini files need to be saved as UTF-8
5+
6+
PLG_FIELDS_NOTE="Fields - Note"
7+
PLG_FIELDS_NOTE_LABEL="Note (%s)"
8+
PLG_FIELDS_NOTE_PARAMS_CLASS_DESC="The class used on the div of the note."
9+
PLG_FIELDS_NOTE_PARAMS_CLASS_LABEL="Note Class"
10+
PLG_FIELDS_NOTE_PARAMS_CLOSE_DESC="This field controls the display of an \"x\" to close the note. It takes a value of 'true' (for alerts) or the value for the data-dismiss of the Bootstrap close icon."
11+
PLG_FIELDS_NOTE_PARAMS_CLOSE_LABEL="Show Close Button"
12+
PLG_FIELDS_NOTE_PARAMS_DESCRIPTION_LABEL="Note Content"
13+
PLG_FIELDS_NOTE_PARAMS_DISPLAY_FRONTEND_LABEL="Display In Frontend"
14+
PLG_FIELDS_NOTE_PARAMS_HEADING_LABEL="Heading Tag"
15+
PLG_FIELDS_NOTE_PARAMS_LABEL_LABEL="Note Heading"
16+
PLG_FIELDS_NOTE_XML_DESCRIPTION="This plugin lets you create new fields of type 'note' in any extensions where custom fields are supported."
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; Joomla! Project
2+
; (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
3+
; License GNU General Public License version 2 or later; see LICENSE.txt
4+
; Note : All ini files need to be saved as UTF-8
5+
6+
PLG_FIELDS_NOTE="Fields - Note"
7+
PLG_FIELDS_NOTE_XML_DESCRIPTION="This plugin lets you create new fields of type 'note' in any extensions where custom fields are supported."

installation/sql/mysql/base.sql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,15 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
298298
(0, 'plg_fields_integer', 'plugin', 'integer', 'fields', 0, 1, 1, 0, 1, '', '{"multiple":"0","first":"1","last":"100","step":"1"}', '', 6, 0),
299299
(0, 'plg_fields_list', 'plugin', 'list', 'fields', 0, 1, 1, 0, 1, '', '', '', 7, 0),
300300
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
301-
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 9, 0),
302-
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
303-
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
304-
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
305-
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 13, 0),
306-
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),
307-
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
308-
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
301+
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', 9, 0),
302+
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
303+
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
304+
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
305+
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
306+
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 14, 0),
307+
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
308+
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
309+
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
309310
(0, 'plg_filesystem_local', 'plugin', 'local', 'filesystem', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
310311
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, 1, '', '', '', 1, 0),
311312
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, 1, '', '', '', 2, 0),

installation/sql/postgresql/base.sql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,15 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
304304
(0, 'plg_fields_integer', 'plugin', 'integer', 'fields', 0, 1, 1, 0, 1, '', '{"multiple":"0","first":"1","last":"100","step":"1"}', '', 6, 0),
305305
(0, 'plg_fields_list', 'plugin', 'list', 'fields', 0, 1, 1, 0, 1, '', '', '', 7, 0),
306306
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
307-
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 9, 0),
308-
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
309-
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
310-
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
311-
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 13, 0),
312-
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),
313-
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
314-
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
307+
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', 9, 0),
308+
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
309+
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
310+
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
311+
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
312+
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 14, 0),
313+
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
314+
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
315+
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
315316
(0, 'plg_filesystem_local', 'plugin', 'local', 'filesystem', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
316317
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, 1, '', '', '', 1, 0),
317318
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, 1, '', '', '', 2, 0),

plugins/fields/note/note.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extension type="plugin" group="fields" method="upgrade">
3+
<name>plg_fields_note</name>
4+
<author>Joomla! Project</author>
5+
<creationDate>2025-03</creationDate>
6+
<copyright>(C) 2025 Open Source Matters, Inc.</copyright>
7+
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
8+
<authorEmail>[email protected]</authorEmail>
9+
<authorUrl>www.joomla.org</authorUrl>
10+
<version>6.0.0</version>
11+
<description>PLG_FIELDS_NOTE_XML_DESCRIPTION</description>
12+
<namespace path="src">Joomla\Plugin\Fields\Note</namespace>
13+
<files>
14+
<folder>params</folder>
15+
<folder plugin="note">services</folder>
16+
<folder>src</folder>
17+
<folder>tmpl</folder>
18+
</files>
19+
<languages>
20+
<language tag="en-GB">language/en-GB/plg_fields_note.ini</language>
21+
<language tag="en-GB">language/en-GB/plg_fields_note.sys.ini</language>
22+
</languages>
23+
<config>
24+
<fields name="params">
25+
<fieldset name="basic">
26+
<field
27+
name="label"
28+
type="text"
29+
label="PLG_FIELDS_NOTE_PARAMS_LABEL_LABEL"
30+
/>
31+
32+
<field
33+
name="description"
34+
type="editor"
35+
label="PLG_FIELDS_NOTE_PARAMS_DESCRIPTION_LABEL"
36+
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
37+
buttons="false"
38+
/>
39+
40+
<field
41+
name="class"
42+
type="text"
43+
label="PLG_FIELDS_NOTE_PARAMS_CLASS_LABEL"
44+
description="PLG_FIELDS_NOTE_PARAMS_CLASS_DESC"
45+
default="alert alert-info"
46+
/>
47+
48+
<field
49+
name="heading"
50+
type="list"
51+
label="PLG_FIELDS_NOTE_PARAMS_HEADING_LABEL"
52+
default="h4"
53+
>
54+
<option value="h1">JH1</option>
55+
<option value="h2">JH2</option>
56+
<option value="h3">JH3</option>
57+
<option value="h4">JH4</option>
58+
<option value="h5">JH5</option>
59+
<option value="h6">JH6</option>
60+
</field>
61+
62+
<field
63+
name="close"
64+
type="text"
65+
label="PLG_FIELDS_NOTE_PARAMS_CLOSE_LABEL"
66+
description="PLG_FIELDS_NOTE_PARAMS_CLOSE_DESC"
67+
/>
68+
</fieldset>
69+
</fields>
70+
</config>
71+
</extension>
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form>
3+
<field
4+
name="required"
5+
type="hidden"
6+
filter="unset"
7+
/>
8+
9+
<field
10+
name="default_value"
11+
type="hidden"
12+
filter="unset"
13+
/>
14+
<fields name="params" label="COM_FIELDS_FIELD_BASIC_LABEL">
15+
<fieldset name="basic">
16+
<field
17+
name="hint"
18+
type="hidden"
19+
filter="unset"
20+
/>
21+
22+
<field
23+
name="class"
24+
type="hidden"
25+
filter="unset"
26+
/>
27+
28+
<field
29+
name="label_class"
30+
type="hidden"
31+
filter="unset"
32+
/>
33+
34+
<field
35+
name="show_on"
36+
type="hidden"
37+
filter="unset"
38+
/>
39+
40+
<field
41+
name="showon"
42+
type="hidden"
43+
filter="unset"
44+
/>
45+
46+
<field
47+
name="showlabel"
48+
type="hidden"
49+
filter="unset"
50+
/>
51+
52+
<field
53+
name="label_render_class"
54+
type="hidden"
55+
filter="unset"
56+
/>
57+
58+
<field
59+
name="render_class"
60+
type="hidden"
61+
filter="unset"
62+
/>
63+
64+
<field
65+
name="value_render_class"
66+
type="hidden"
67+
filter="unset"
68+
/>
69+
70+
<field
71+
name="prefix"
72+
type="hidden"
73+
filter="unset"
74+
/>
75+
76+
<field
77+
name="suffix"
78+
type="hidden"
79+
filter="unset"
80+
/>
81+
82+
<field
83+
name="display_readonly"
84+
type="hidden"
85+
filter="unset"
86+
/>
87+
88+
<field
89+
name="searchindex"
90+
type="hidden"
91+
filter="unset"
92+
/>
93+
</fieldset>
94+
<fieldset name="renderoptions">
95+
<field
96+
name="display_frontend"
97+
type="radio"
98+
label="PLG_FIELDS_NOTE_PARAMS_DISPLAY_FRONTEND_LABEL"
99+
layout="joomla.form.field.radio.switcher"
100+
default="0"
101+
filter="integer"
102+
>
103+
<option value="0">JNO</option>
104+
<option value="1">JYES</option>
105+
</field>
106+
</fieldset>
107+
</fields>
108+
<fields name="fieldparams">
109+
<fieldset name="fieldparams">
110+
<field
111+
name="label"
112+
type="text"
113+
label="PLG_FIELDS_NOTE_PARAMS_LABEL_LABEL"
114+
/>
115+
116+
<field
117+
name="description"
118+
type="editor"
119+
label="PLG_FIELDS_NOTE_PARAMS_DESCRIPTION_LABEL"
120+
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
121+
buttons="false"
122+
/>
123+
124+
<field
125+
name="class"
126+
type="text"
127+
label="PLG_FIELDS_NOTE_PARAMS_CLASS_LABEL"
128+
description="PLG_FIELDS_NOTE_PARAMS_CLASS_DESC"
129+
default="alert alert-info"
130+
/>
131+
132+
<field
133+
name="heading"
134+
type="list"
135+
label="PLG_FIELDS_NOTE_PARAMS_HEADING_LABEL"
136+
default="h4"
137+
>
138+
<option value="h1">JH1</option>
139+
<option value="h2">JH2</option>
140+
<option value="h3">JH3</option>
141+
<option value="h4">JH4</option>
142+
<option value="h5">JH5</option>
143+
<option value="h6">JH6</option>
144+
</field>
145+
146+
<field
147+
name="close"
148+
type="text"
149+
label="PLG_FIELDS_NOTE_PARAMS_CLOSE_LABEL"
150+
description="PLG_FIELDS_NOTE_PARAMS_CLOSE_DESC"
151+
/>
152+
</fieldset>
153+
</fields>
154+
</form>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.Plugin
5+
* @subpackage Fields.note
6+
*
7+
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
8+
* @license GNU General Public License version 2 or later; see LICENSE.txt
9+
*/
10+
11+
\defined('_JEXEC') or die;
12+
13+
use Joomla\CMS\Extension\PluginInterface;
14+
use Joomla\CMS\Factory;
15+
use Joomla\CMS\Plugin\PluginHelper;
16+
use Joomla\DI\Container;
17+
use Joomla\DI\ServiceProviderInterface;
18+
use Joomla\Event\DispatcherInterface;
19+
use Joomla\Plugin\Fields\Note\Extension\Note;
20+
21+
return new class () implements ServiceProviderInterface {
22+
/**
23+
* Registers the service provider with a DI container.
24+
*
25+
* @param Container $container The DI container.
26+
*
27+
* @return void
28+
*
29+
* @since __DEPLOY_VERSION__
30+
*/
31+
public function register(Container $container)
32+
{
33+
$container->set(
34+
PluginInterface::class,
35+
function (Container $container) {
36+
$plugin = new Note(
37+
$container->get(DispatcherInterface::class),
38+
(array) PluginHelper::getPlugin('fields', 'note')
39+
);
40+
$plugin->setApplication(Factory::getApplication());
41+
42+
return $plugin;
43+
}
44+
);
45+
}
46+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.Plugin
5+
* @subpackage Fields.note
6+
*
7+
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
8+
* @license GNU General Public License version 2 or later; see LICENSE.txt
9+
*/
10+
11+
namespace Joomla\Plugin\Fields\Note\Extension;
12+
13+
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
14+
use Joomla\Event\SubscriberInterface;
15+
16+
// phpcs:disable PSR1.Files.SideEffects
17+
\defined('_JEXEC') or die;
18+
// phpcs:enable PSR1.Files.SideEffects
19+
20+
/**
21+
* Fields Note Plugin
22+
*
23+
* @since __DEPLOY_VERSION__
24+
*/
25+
final class Note extends FieldsPlugin implements SubscriberInterface
26+
{
27+
}

0 commit comments

Comments
 (0)