Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

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

Duke
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10778
Newest User:
negina4qx
Members Online:
0
Guests Online:
202

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked