Wont work when used from Plugin
Opened this issue · 1 comments
Hi,
this still has this bug I issued for Grafikart's version, [https://github.com/Grafikart/CakePHP-Media/issues/38].
If you use this from the plugin, using following 'Posts.Posts' as a Model.
echo $this->Media->iframe('Posts.Posts',$post->id); MediasController.php will fail on line 60.
if (! in_array('Media', $this->$ref->Behaviors()->loaded())) {
$this->loadModel($ref) works fine, it loads Posts.Posts. but when $this->$ref->Behaviors is used, Posts.Posts wont work, you have to use now just plain model name 'Posts'. (At least it's how I managed to get over this first error).
My fix was to add after loadModel (line 58) if condition which removes "PLUGIN." from the $ref if dot is found.
58 $this->loadModel($ref);
if (($pos = strpos($ref,".")) !== FALSE) {
$ref = substr($ref,$pos+1);
}`
Hi,
can you open a pull request for this issue please ?