Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Any chance MMP could set the default...
Any chance MMP could set the default image upload folder in the editor
Any chance MMP could set the default image upload folder in the editor
Reading about how MMP can set the folder for Random Image made me curious whether the "Image" button under a front end editor can be modified to open in a default subfolder that matches the alias of the current category. e.g. instead of $imagepath set to \images\stories
$imagepath = $imagepath . "\" . $categoryalias
to become \images\stories\current-category
Is the Image button plugin able to be modifed by MMP's universal impact if the plugin order is set correctly?
Duke
Re: Any chance MMP could set the default image upload folder in the editor
Hi Duke,
I was about to say "completely impossible", but then found a way to do it :-)
This recipe works for the standard Joomla "Image" button that sits below the article editing window. It does *not* work for the JCE image selector. That looks like a much more complex job.
It doesn't use MetaMod, but uses MetaTemplate. It doesn't even require the Pro version.
Simply install MetaTemplate and make a new rule.
In the "SUCCEED" action there's a Run PHP box. Paste in the following:
$bug = ($option == 'com_content'
and $view == 'category'
and JRequest::getVar('ret') != null
and JRequest::getVar('task') == "edit");
if ($bug) {
unset( $_SESSION['mm_category_alias'] );
return;
}
if ($core_genius->check("pagetype startswith article, category")) {
$_SESSION['mm_category_alias'] = $content_genius->info("category_alias");
return;
};
if ( !$bug and $option == "com_media" and $view == "images") {
$alias = $_SESSION['mm_category_alias'];
if ( JRequest::getVar("folder") === null) JRequest::setVar("folder", $alias);
}
It's magic!
There's only 1 gotcha that I don't have time to solve properly. If you have Joomla built-in SEF enabled, and are viewing a category list or blog page and edit the article from there (rather than editing it from an article view page), then the category alias gets messed up. This is due to a bug in Joomla. So in that case the recipe above does NOT set the folder.
Best regards,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Any chance MMP could set the default...
Board Info
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked