Monday, October 28, 2013

Re: Defining Plugin

I used basic URL parameters just as you would any other URL options array. 

$this->Paginator->options(array('url'=> array('controller' => 'users', 'action' => 'index', 'plugin' => 'user_manager')));

It gets set in the view, I just added it in with the rest of the paging options (numbers, next, prev, etc). It worked for 4/5 pages and the one it didn't work on was simply because that view is shared between two functions. I'd rather not have two views so I'll just tweak the code a bit and it should be fine. 

What I'm still a little unsure of is there are instances where you don't designate a URL at all such as working with scaffolding. If the conventions are to have the plugin underscored within a URL, in instances such as the scaffolding the plugin shows up in the URL camel-cased. My guess is that i'm still overlooking something because it's been my experience that constructing your link with something as simple as 'action' => 'index' would direct me back the index view of the current controller and if I was in  admin, it would have the same behavior resulting in something such as /admin/controller/index. I would expect Cake to display the same behavior when within a plugin for example /some_plugin/admin/controller/index when coding your link as 'action' => 'index' from the admin section of somePlugin. The times I needed to specify 'plugin' => 'some_plugin' was when linking to the plugin from a page outside of it, or 'plugin' => null or false when linking from within the plugin to a page outside of it. I'm finding that I have to define my links down the last detail from within the plugin itself and sometimes creating custom routes just to make life easier. I have little to no experience creating my own plugins so I have nothing to compare to, but the fact that this doesn't seem like normal 
cake behavior at all leads me to believe that I still have something out of wack, I just don't know what or where but I haven't stopped looking. Also, 99% of the time Cake screws up it was completely my fault, the other 1% of the time it's not my fault at all but I naturally assume that it was :) So yes, I still think I have something boogered within my app. 


On Mon, Oct 28, 2013 at 5:39 PM, Reuben Helms <reuben.helms@gmail.com> wrote:
What options did you end up using?


On Tuesday, October 29, 2013, Ed Propsner wrote:
I was able to work everything out using $this->paginator options(). I appreciate the help :)


On Mon, Oct 28, 2013 at 2:17 AM, Ed Propsner <crotchfrog@gmail.com> wrote:
You're absolutely right, I was definitely confusing the two. I suppose that I'm so used to referencing the plugin as camel-case everywhere else within the app and since functions are camel-case and they are referenced as such in the URL, it wasn't a far stretch to make the mistake of constructing my links with 'plugin' => 'SomePlugin'. I definitely learned my lesson on that one. I have everything fixed in the app except for pagination. It loads the first :page fine but still assumes on the following :pages the plugin should be loaded as camel-case instead of underscore. Is there something I missed when changing everything over, or is there some place I should let Cake know that those pages belong in some_plugin? I noticed that when the error is thrown the error log shows the plugin as null.  



On Sun, Oct 27, 2013 at 6:56 PM, euromark <dereuromark@gmail.com> wrote:
Yes, I guess you have been creating non-conventional links so far. Mainly because you are confusing framework internal naming schemes with URL naming scheme
The latter defines everything underscore_lowercased, even the plugin.
The first refers mainly to classes, which will always be named CamelCased.

You need to understand the difference in order to not write faulty code - which at some point can blow up (as it then did).


Am Samstag, 26. Oktober 2013 04:43:11 UTC+2 schrieb CrotchFrog:
I've noticed recently some strange behavior when it comes to naming conventions and Plugins.  

For example if I create a link somewhere within a plugin ie. $this->Html->link('Some Link', array('controller' => 'controller', 'action' => 'action')); 
Following the link would land you on the page app/plugin/controller/action unless a location is specified outside of the current plugin and controller. 

Links created this way and that have been working since they were created sometimes out of the blue throw an error along the lines of SomePluginController cannot be found. 
This is strange because the link has always worked in the past. When these links create an error I have to re-create the link and specify the plugin $this->Html->link('controller' => 'controller', 'action' => 'action', 'plugin' => 'some_plugin')
I have to use an underscore in the plugin name, using camel case results in the same error. 

It's possible that some, but not all, of the links were created only specifying the action and not the controller. With this being the case I could sort of understand the resulting error but not when I have specified both the controller and the action.

I created all of my custom routes with the plugin as camel case, it just seems to be links and redirects that display this behavior.  

I assumed that with sticking to naming conventions I could write it as SomePlugin or some_plugin and either one would be fine. 

Have I been creating my links incorrectly this entire time? 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/zDwuUhlVGzE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send em

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/zDwuUhlVGzE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: