You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#105693 Specify profile ID on editor XML on custom module

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Ryan on Wednesday, 04 November 2020 19:57 GMT

tradingscreen
Hello. How can I add JCE to a custom module or component view while specifying the JCE profile to be loaded at that particular instance? For example, I may want only a specific custom module to use a more limited profile, or possibly only a single instance within a component view where I would have multiple editor windows. How would I go about composing the XML to load the editor?

<field name="my_text" type="editor" editor="jce" label="Text" description="here" rows="6" cols="100" filter="safehtml" required="false" message="" buttons="false" />
Can I just add a profile="6" in there? Or is there another way to force that particular editor to load with a specific profile? Meybe some PHP at the helper file? Thank you.

Ryan
Can I just add a profile="6" in there?


Unfortunately the field does not accept custom attributes.

Or is there another way to force that particular editor to load with a specific profile?


Not as yet. I have not yet been able to find a good way to implement this, bu tI will continue looking :)

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

tradingscreen
Thanks Ryan.

How would I go about, for example, adding JCE editor in a purely PHP way, straight into the view file, bypassing the <field> tag in the XML?
By adding it with pure PHP, can I set it to the desired profile?
Or is this a parameter that JCE is not ready to interpret coming from the component in the first place?

Maybe prevent the loading of the editor in the first place, then calling it again with the proper profile?
Or destroying the editor upon initialization and reinitializing it with the profile?

I am not a proper PHP dev, just a PHP-proficiently-curious integrator, so I could not make much sense of the Joomla API Editor doc page.

Cheers.

Ryan
Please try JCE Pro 2.9.2 Beta 4 - https://www.joomlacontenteditor.net/downloads/editor/pro/development
How would I go about, for example, adding JCE editor in a purely PHP way, straight into the view file, bypassing the <field> tag in the XML? By adding it with pure PHP, can I set it to the desired profile?
You can now initialize the editor on the page using the following:

$document = JFactory::getDocument();

require_once JPATH_ADMINISTRATOR . '/components/com_jce/includes/base.php';

$editor = new WFEditor(array('id' => 10));
$editor->init();

foreach ($editor->getScripts() as $script) {
	$document->addScript($script);
}

foreach ($editor->getStyleSheets() as $style) {
	$document->addStylesheet($style);
}

$document->addScriptDeclaration(implode("
", $editor->getScriptDeclaration()));
As you can see in the above code, you can add the id in the array when creating a new editor instance, eg:

$editor = new WFEditor(array('id' => 10));

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.