Support Forum
Content Templater
Categories as separate editor buttons does not work in RSForm Pro textarea
I cannot get the option of displaying categories as separate editor buttons to work in an RSForms Pro form with multiple textareas. "Grouped" and "Grouped with category title" both work correctly as a single CT button in all textareas, but when I choose "separate editor buttons" for each category, clicking those buttons works only in the last loaded of the textareas. The buttons in the other textareas have no effect.
When I have a single CT button in each textarea, the snippet is inserted into the textarea corresponding to the button that I click regardless of which one the cursor is in, but with buttons for each category, the snippet is inserted wherever the cursor is, even though only one set of buttons (the last one loaded) functions.
I can get the insertion in any of the textareas by putting the cursor in the appropriate place and using the buttons in the last textarea, but obviously this is not ideal. Is there a way around this?
CT 6.2.8 Pro
J! 3.6.5
PHP 7.0.14
Yes and no. I posted this here because of they way it behaves differently with multiple CT buttons than with a single button, and thought there might be something about the way that is implemented that's messing up RSForms. I will post the same issue with them.
RSForms is probably using its own way of outputting the editor and buttons instead of simply using the Joomla core way for that.
RSJoomla responds:
Message: Hello,
I don't know of any way to display an editor other than to use the Joomla! API, which RSForm! Pro is indeed doing. Just take a look at this file:
/administrator/components/com_rsform/helpers/fields/textarea.php
And you'll see:
protected function getEditor() {
jimport('joomla.html.editor');
static $editor = null;
if (is_null($editor)) {
$conf = JFactory::getConfig();
$editor = $conf->get('editor');
}
return JEditor::getInstance($editor);
}
As well as:
return $this->getEditor()->display($name, $this->escape($value), $cols*10, $rows*10, $cols, $rows, true, $id, null, null,
array('relative_urls' => '0',
'cleanup_save' => '0',
'cleanup_startup' => '0',
'cleanup_entities' => '0')
);
Is there any other place where you can display multiple editors on the same page? I'm scratching the back of my head but I can't think of another page in Joomla! that does this. It would be interesting to see if it's an issue with RSForm! Pro (for which we'll gladly try to find a solution) or an issue with the editor buttons created by Content Templater.
Would it be possible to upgrade my account (or provide another one) to an Administrator level? It's easier for me to debug on your website since I'm not familiar with Content Templater and I'm not sure how to set it up to reproduce the issue locally.
Can you give me (super) admin and (s)ftp access so I can take a deeper look?
You can use the 'Hidden text' button in the forum editor to hide the confidential information.
This is from RSJoomla:
ContentTemplater.showList('cat-IPA', 'General')
The first parameter is the name of your category in Content Templater I believe, but what's interesting is that the second parameter is the ID of the editor. So, in RSForm! Pro you've setup a textarea field named "General" and this is the name and also the ID of this textarea. So far so good.
Content Templater is the one that generates the dropdown list through a HTML on the page. When clicking on the button, a script searches for a specific ID of that dropdown list (which is hidden on the page) and is constructed in the following manner:
#contenttemplater-list-' + editorname + '-' + id
Notice it contains the editor's name in it - so, for the "General" editor and for the "cat-IPA" category, it looks for:
#contenttemplater-list-General-cat-IPA
I've searched on the page for "contenttemplater-list-General-cat-IPA" but there's no such string in there. What I did find is this:
contenttemplater-list-general-cat-IPA
Notice the "general" editor's name is lowercase. I'm not sure how it became lowercase, but the code that does this is part of Content Templater.
As an exercise, you can type your editor names in lowercase - "general" and "specific" and you'll see the problem going away 🙂
Since it was bugging my mind, I've also found what causes this in Content Templater:
/plugins/editors-xtd/contenttemplater/helper.php
This function causes the editor name to be modified:
private function getEditorId($editor)
{
$editor = JFilterOutput::stringURLSafe($editor);
$editor = str_replace('-', '_', $editor);
return $editor;
}
Replacing it with this:
private function getEditorId($editor)
{
return $editor;
}
Will cause the editor name to remain intact.
There's another place that needs an edit though:
/plugins/system/contenttemplater/helper.php
This line:
if (!preg_match_all('#rl_ct_button-([a-z0-9-_]+)#s', $buffer, $matches))
Needs to be replaced with this one:
if (!preg_match_all('#rl_ct_button-([a-z0-9-_]+)#si', $buffer, $matches))
And will match "General" and "Specific" as well.
Actually, there's more to it - it's ironic that the developer complained that we're not using the Joomla! API to display the editor and "doing our own ways" and yet, by debugging his plugin, I've noticed that he's the one not querying the Joomla! API for the editor name - he's just assuming that the name would be lowercased and should contain only "a-z 0-9 - _".
So - would it fix things if I simply changed the names of the textareas to all lowercase?
PS: You can try the latest development version (including the fix) from:
www.regularlabs.com/development-releases
However, it contains a lot of code changes (refactoring). I do not advise you to use that on a live website yet...