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
- Forum
- JCE Plugins / Addons
- Custom Filesystem with rootdir = $articleid
Support is currently Online
Official support hours:
Monday To Friday
From 09:00 To 17:00 Europe/London (BST)
From 09:00 To 17:00 Europe/London (BST)
I'm trying to implement a filesystem plugin that I'd like to use in a specific JCE profile for com_content component and Editors users.
Like the variables $id, $username, $usertype, etc. that you can use to specify dinamically the root directory, I'd like to add a variable, i.e. $articleid, that will dinamically set the root directory to a folder named with the id of the article you're currently editing (i.e. /mypath/123).
So, every article has its own folder (this is very useful in a scenario when article editing need to be moved frequently from a usergroup to another, and you don't want to migrate files).
Well, in my scenario Editors can't create articles, they can just edit an existing one. So I'm sure that JCE is called for an article that already has an id.
But I can realize this? I'm trying to override the WFFileSystem getRootDir() method but I can't figure out how to detect consistently the current article id.
I've tried this way, and it works, but I'm not sure it is reliable...
Any suggestions?
Like the variables $id, $username, $usertype, etc. that you can use to specify dinamically the root directory, I'd like to add a variable, i.e. $articleid, that will dinamically set the root directory to a folder named with the id of the article you're currently editing (i.e. /mypath/123).
So, every article has its own folder (this is very useful in a scenario when article editing need to be moved frequently from a usergroup to another, and you don't want to migrate files).
Well, in my scenario Editors can't create articles, they can just edit an existing one. So I'm sure that JCE is called for an article that already has an id.
But I can realize this? I'm trying to override the WFFileSystem getRootDir() method but I can't figure out how to detect consistently the current article id.
I've tried this way, and it works, but I'm not sure it is reliable...
if(!empty($registry->get('com_content')->edit->article->id)) {
$article_id = reset($registry->get('com_content')->edit->article->id);
if (!empty($article_id)) {
if ($article_id>0) {
$root .= '/' . $article_id;
...
Any suggestions?
An event is a available that you can use in a custom Joomla system plugin to change the root directory for each user based on your criteria.
The onWfFileSystemGetRootDir event is triggered when the root directory is requested, passing a relative url of the value set in the File Directory Path, or "images".
Here is an example system plugin with all the available events exposed - https://github.com/widgetfactory/wf_filesystem_events
To get the article id, which is only available on existing articles, you could try:
The onWfFileSystemGetRootDir event is triggered when the root directory is requested, passing a relative url of the value set in the File Directory Path, or "images".
Here is an example system plugin with all the available events exposed - https://github.com/widgetfactory/wf_filesystem_events
To get the article id, which is only available on existing articles, you could try:
$id = JFactory::getApplication()->getInt('id');
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Uhm, I've tried your suggestion but I noticed no differences between using events or overriding getRootDir().
In both cases I can set the root path but I need a way to get the article id, and getApplication() returns it only in
or in an http_referrer property.
I can't use getApplication->input because when editing an article, the FileBrowser is opened in a popup window, so with a new url different from the editing page, and there's no trace of article id, nor of the component I'm using...
Do you know how can I get these informations? For instance, how do you get the current component used to choose the right profile to apply? I guess I can found there what I'm looking for...
thank you
In both cases I can set the root path but I need a way to get the article id, and getApplication() returns it only in
$session = JFactory::getSession();
$registry = $session->get('registry');
$article_id = reset($registry->get('com_content')->edit->article->id);
or in an http_referrer property.
I can't use getApplication->input because when editing an article, the FileBrowser is opened in a popup window, so with a new url different from the editing page, and there's no trace of article id, nor of the component I'm using...
Do you know how can I get these informations? For instance, how do you get the current component used to choose the right profile to apply? I guess I can found there what I'm looking for...
thank you
The article id is only available when an article has been saved, ie: not a new article, so you would have to save the article before adding any content before you could correctly access the folder where your images are stored.
Just because you're not paranoid doesn't mean everybody isn't out to get you.
- Page :
- 1
There are no replies made for this post yet.
Be one of the first to reply to this post!
Be one of the first to reply to this post!