Y
Y
Yuri Yerusalimsky2016-02-28 01:00:16
CMS
Yuri Yerusalimsky, 2016-02-28 01:00:16

Is it possible to assign a visual editor in CMS Joomla for each category of materials in its own way?

Let's say I have Category_1 and Category_2. In view of the peculiarities, I need to edit Category_1 through JCE, and Category_2 through CodeMirror. Is it somehow possible to implement this idea automatically, without constant running around in the "System -> General Settings" menu to change the editor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2016-02-28
@xmoonlight

By binding the plugin (or its settings, or through general settings) or only by refining through the code.

Y
Yuri Yerusalimsky, 2016-03-20
@werber

Sharing how I ALMOST solved this problem. So, we do the following:
1. In the default admin template (most likely you have Isis), create 2 folders in the html folder - com_modules and com_content. In the com_modules folder we create the module folder, in the com_content folder we create the article folder. As a result, the following paths will be obtained: site.ru/administrator/templates/isis/html/com_modules/module and site.ru/administrator/templates/isis/html/com_content/article .
2. Go along the path site.ru/administrator/components/com_content/views/article/tmpl , find the edit.php file inside . We transfer its copy to site.ru/administrator/templates/isis/html/com_content/article . Similarly, we transfer the edit.php filefrom site.ru/administrator/components/com_modules/views/module/tmpl to site.ru/administrator/templates/isis/html/com_modules/module .
3. In the edit.php files that were copied to the template folder, after the line,
paste the code:

$editor1 = "jce"; //название редактора для категории с ID=2 (в моём случае)
$editor2 = "codemirror"; //название редактора для всех иных категорий
$catid = $this->form->getValue("catid"); //получаем номер данной категории материала
$tmp_user = JFactory::getUser(); //инициализируем временный массив tmp_user, где хранится
//класс с информацией о параметрах пользователя. Тут же хранится и текстовый редактор
//для данного пользователя.
if ($catid == "2"){ //если редактируем материал с ID статьи = 2, то...
  $tmp_user->setParam('editor',$editor1); //устанавливаем редактор под именем $editor1
} else { //если редактируем материал с ID статьи отличной от 2, то...
  $tmp_user->setParam('editor',$editor2); //устанавливаем редактор под именем $editor2
}

This code can be rewritten to suit your needs, customizing both specifically for your editors, and replacing the IF condition with SWITCH to switch editors for each of the existing categories of materials.
This code has one problem. The code works the second time if a different editor has been set before. Apparently, nevertheless, the editor needs to be set not in the editing template, but somewhere higher. I don't know where, maybe someone can be more specific. But for the code in a hurry, you can leave it like that. Anyway, it's not that hard to reload the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question