User tests: Successful: 2 Fedik, alikon Unsuccessful: 0
TinyMCE has a really powerful feature that almost knows about - the ability to have predefined snippets of text and html.
This is not a new feature of TinyMCE it has been present for at least 10 years. The reason no one knows about this or talks about it is that its very hard to use because of a bug in the path that Joomla uses to store the snippets.
I am only aware of a blog post by @coolcat-creations blog post explaining how to use it and you will see it is both very powerful but also a pain to setup
The folder that tinymce looks in for the stored "templates" is outside of the folder structure that can be accessed within the Joomla administrator ui. In Joomla 4 it is media/vendor/tinymce/templates
so it can only be accessed by ftp or cli.
Change the folder where the "templates" are stored to a user defined folder in the site/templates folder structure. This enables the user to use the template manager to create and edit the "templates".
No problem here as if a custom folder is not set then the default is the current media/vendor/tinymce/templates
. The one difference is that the current (and therefore default) behaviour is for the files to be *.html. Because that filetype is by default prohibited in the template manager I have changed it to additionally support .txt filetype only when using the custom folder/
A template developer can include predefined snippets of text and html with their template
Firstly familiarise yourself with this TinyMCE feature. You will find it on the Insert dropdown of the editor toolbar. TinyMCE ships with two examples you can play with.
Go to the Editor - TinyMCE plugin and there is a new field where you can select the folder to use.
Make sure you are in a configuration set that applies to your user level (it is probably Set 0) and then select a folder and save.
Go to an article and try to insert a template (as you did before)
You should get a template not found message
Go to the template manager and create two text files in the folder you previously selected
Now return to the article and you should be able to insert both these templates successfully.
## Issues to solve? - need help
The list of folders presented to the user to select from was intended to be limited to templates[template_name]\html\ and all its subfolders but despite my best efforts I was not able to get the folderFilter to includes those subfolders
This is an incredibly marketable feature. (There aren't that many in J4 that the regular user will understand)
Its uses are endless not least the which the ability to build up a complex web page without the bloat and performance issues from a pagebuilder.
As I recorded the talk at joomladay usa which mentions this feature and how to use it I have created a 3 minute video to explain it.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Front End Plugins |
Labels |
Added:
?
?
|
@dgrammatiko if that gets accepted we can look at that then.
Looks like a good idea
the if/else
block can be eliminated :
$templates_dir = $levelParams->get('content_template_path');
$templates_dir = $templates_dir ? '/templates/' . $templates_dir : '/media/vendor/tinymce/templates';
foreach (glob(JPATH_ROOT . $templates_dir . '/*.{html,txt}', GLOB_BRACE) as $filename)
{
...
}
I have changed it to the supported .txt filetype
What about .tmpl
? some editors have a code highlight for this file type. With .txt
can be hard.
but this need to test
I think with pathinfo
https://www.php.net/manual/en/function.pathinfo.php
Maybe something like:
// Use $name for Template name, and translation constant. Keep original $filename unchanged
$name = pathinfo($filename, PATHINFO_FILENAME);
// Use original $filename
'url' => Uri::root(true) . $content_template . $filename;
Hm, can stay basename()
with same logic:
// Use $name for Template name, and translation constant. Keep original $filename unchanged
$name = basename($filename);
// Use original $filename
'url' => Uri::root(true) . $content_template . $filename;
hm, I have tested a bit and I noticed that cannot select any other folder than cassiopeia/html
.
It does not looks right.
I am reluctant to make these changes
I have made PR with that changes
The list of folders presented to the user to select from was intended to be limited to templates[template_name]\html\ and all its subfolders but despite my best efforts I was not able to get the folderFilter to includes those subfolders
okay, the problem here is that folderFilter="^html"
looking for single folder name, not for full path
joomla-cms/libraries/src/Filesystem/Folder.php
Lines 622 to 624 in f2c2750
that means it will work for:
html/
html_foo/
htmlbla/
but not for:
html/foo/
html/bla/
that complicated :)
As idea, maybe instead of folderFilter="^html"
make folderFilter="^tinymce"
,
and create an empty folder in cassiopeia/html/tinymce
Can be need update description/documentation, so User know where to look.
Thanks for your suggestions they sound good (as does the patch you contributed) I will check this tomorrow as it goes a bit further than I had intended originally
Category | Administration Language & Strings Front End Plugins | ⇒ | Administration Language & Strings Front End Plugins Templates (site) |
Resolved conflicts.
Would be great to get some tests on this. It got really good feedback at joomladayusa
I wanted to test
But found that the man with name @brianteeman broke this PR with #33177
@brianteeman please check the conflict,
the options is fixed in #33464, but it made a conflict with your changes
the conflict looked fixed to me locally so I am at a loss as to why it says conflicts now. Any help appreciated
it an indentations,
try like next: copy setoptions.xml from 4.0-dev branch, and re-add "content_template_path" field.
this will be easiest way
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-07 07:27:28 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
|
yay - thank you all!
this broke stuff.
care to be more constructive and informative
@brianteeman you need the pieces for child templates from #31785 as well here