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.

#108262 Using Link/Media/File manager outside of the editor

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 qlue on Tuesday, 17 August 2021 13:56 BST

qlue
Hello,

Is it possible to trigger and use the link/media/file manager popups away from using JCE as an editor? I have created a page builder editor and would like to implement the use of JCE's insert link popup, as well as the image uploading capabilities provided by JCE. Using joomla by the way.

It's fine to require the editor somewhere on the page, but to programmatically open the popup and collect the HTML it generates would save me a lot of trouble

Thanks in advance

Ryan
I have created a page builder editor and would like to implement the use of JCE's insert link popup, as well as the image uploading capabilities provided by JCE. Using joomla by the way.
It is available in a field, which you can add to your extension, as you would other Joomla fields, eg:

<field
    name="my_media"
    type="mediajce"
    label="My Media Field"
    description=""
    mediatype="images"
/>
Alternatively, if you use the Joomla Media field, it will be converted into a JCE Media Field, eg:

<field
    name="my_media"
    type="media"
    label="My Media Field"
    description=""
/>

Ryan Demmer

Lead Developer / CEO / CTO

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

qlue
Hey Ryan,

Thanks for the reply. It's not being rendered in this way, so essentially I've created a custom field type that renders a page builder (built in JS). The page builder has an interface that is self contained and simply dumps its HTML into the article/category field in the admin screen.

Ideally I'd like to trigger the link/media popups myself. I don't know there's an API to expose its features?

As it works as a standalone field type, I'm hopeful it can be used this way too.

Thanks again


edit: ps it took me ages to submit this post. Something in my reply was setting off admin tools and blocking me from replying. There were no code examples or profanities so maybe this needs adjusting?

Ryan
I don't know there's an API to expose its features?


Not really, as it's designed to run off the Joomla Fields API, either as a Joomla Media Field, or as a MediaJCE field.

edit: ps it took me ages to submit this post. Something in my reply was setting off admin tools and blocking me from replying. There were no code examples or profanities so maybe this needs adjusting?


It looks like something triggered the SQLi Shield.

Ryan Demmer

Lead Developer / CEO / CTO

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

qlue
Thanks Ryan. So there isn't a way for me to utilise these features outside of the editor? Even if it were hidden on the page for example?

If it works as a standalone joomla field I'd have thought I can potentially initialise the field in a similar way just without the joomla interface (hidden field/call the JS/php directly)

Ryan
See this - https://github.com/widgetfactory/jce/blob/master/plugins/system/jce/fields/mediajce.php#L57-L67 So for example if you supplied a $config array with the following:

$config = array(
    'element' => 'my_custom_input',
    'mediatype' => 'images',
    'converted' => false
);

$options = WFBrowserHelper::getMediaFieldOptions($config);
then an $options array can be returned with the url value to use for the modal iframe, assuming you are going to handle opening of the modal yourself. If no url value is returned, then the user does not have access to the File Browser.

Ryan Demmer

Lead Developer / CEO / CTO

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

qlue
Hey Ryan

Thanks for your input so far. I've been working on this and unfortunately PHP implementations aren't going to work as my page builder is created entirely via JS.

I've changed the requirement slightly and now instead of hijacking the link/media popups, I want to use the editor directly within my page builder.

I note that a WFEditor.init(); function is called and passed parameters. Is it possible to effectively recall this after including the correct JS files?

Simply put I would like to, within a javascript app, initialise JCE and have it return the inputted data (getContent()) to a DIV. This way I can create and destroy the editor at will whenever I need to use it.

Is it possible to call WFEditor.init() myself and create and destroy JCE editors as I see fit? I noticed some of the data is kept in a JSON string in the <head> (like tokens and the element to turn into an editor)

Look forward to hearing back

Thank you

qlue
Hi Ryan,

In my digging I have found this thread

https://www.joomlacontenteditor.net/support/forum/98135

Which seems to answer the query. I've implemented your suggestion but get the error

"Uncaught TypeError: can't convert undefined to object"

I feel like I'm very nearly there so any help you can offer is appreciated

Kind regards

qlue
Hi Ryan

I have figured this out, but I am really struggling to make a reply that answers the query for others. Something in my post gets blocked every time. Please can you PM or email me so that I can give you my answer, so that you may post it?

Ryan
Either include more complex scripts as a zipped attachement to your post, or ideally, linked to a github gist (if you have a github account), or a jsfiddle - https://jsfiddle.net/

Ryan Demmer

Lead Developer / CEO / CTO

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

qlue
Good point, thanks Ryan.

To anyone trying to do this too, I have included my process and final solution in the below pastebin.

https://pastebin.com/7LLKT5Mc