Re: Custom router question
Raisen - this looks ideal! Will try it out some time soon. Thanks for sharing. On 15 October 2010 04:28, Raisen wrote: > I created the report plugin using the cake command line: > > cake bake plugin report > > The folder structure for the plugin looks just like the main > application's one - views, controllers, models, etc. > > So I created a view/controller for each report I want. > > It's very simple. Be sure to read > http://book.cakephp.org/view/119/Plugin-Tips > > "Once a plugin has been installed in /app/plugins, you can access it > at the URL /pluginname/controllername/action. In our pizza ordering > plugin example, we'd access our PizzaOrdersController at /pizza/ > pizzaOrders." > > That's what triggered me to use plugins - the url format. > > > On Oct 13, 1:49 pm, Michael Tokar wrote: > > Interesting. Do you think you could post some sample code of your report > > plugin? > > > > On 14 October 2010 09:41, Raisen wrote: > > > > > > > > > > > > > > > > > I did find a way to make a reports section the way I want - plugins! > > > Just create a reports plugin and then you can add the sales, > > > customers, etc... controllers/views. The url will look like: > > > > >http://url.com/reports/sales/ > > > > > On Oct 13, 1:15 pm, Michael Tokar wrote: > > > > On 14 October 2010 07:17, cricket wrote: > > > > > > > But let's back up a bit--do you have Sale & Customer models? What I > > > > > was getting at in my earlier suggestion was that you could declare > > > > > options in each model for how its reporting would be conducted. > > > > > > For my situation at least, that doesn't seem like a great solution, > as I > > > > don't have a one-to-one relationship with Models and Reports. Several > of > > > my > > > > reports use multiple models, and several models have different > reports > > > > associated to them. > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help > others > > > with their CakePHP related questions. > > > > > You received this message because you are subscribed to the Google > Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com > For more options, visit this > group at > > >http://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
I created the report plugin using the cake command line: cake bake plugin report The folder structure for the plugin looks just like the main application's one - views, controllers, models, etc. So I created a view/controller for each report I want. It's very simple. Be sure to read http://book.cakephp.org/view/119/Plugin-Tips "Once a plugin has been installed in /app/plugins, you can access it at the URL /pluginname/controllername/action. In our pizza ordering plugin example, we'd access our PizzaOrdersController at /pizza/ pizzaOrders." That's what triggered me to use plugins - the url format. On Oct 13, 1:49 pm, Michael Tokar wrote: > Interesting. Do you think you could post some sample code of your report > plugin? > > On 14 October 2010 09:41, Raisen wrote: > > > > > > > > > I did find a way to make a reports section the way I want - plugins! > > Just create a reports plugin and then you can add the sales, > > customers, etc... controllers/views. The url will look like: > > >http://url.com/reports/sales/ > > > On Oct 13, 1:15 pm, Michael Tokar wrote: > > > On 14 October 2010 07:17, cricket wrote: > > > > > But let's back up a bit--do you have Sale & Customer models? What I > > > > was getting at in my earlier suggestion was that you could declare > > > > options in each model for how its reporting would be conducted. > > > > For my situation at least, that doesn't seem like a great solution, as I > > > don't have a one-to-one relationship with Models and Reports. Several of > > my > > > reports use multiple models, and several models have different reports > > > associated to them. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
Interesting. Do you think you could post some sample code of your report plugin? On 14 October 2010 09:41, Raisen wrote: > I did find a way to make a reports section the way I want - plugins! > Just create a reports plugin and then you can add the sales, > customers, etc... controllers/views. The url will look like: > > http://url.com/reports/sales/ > > On Oct 13, 1:15 pm, Michael Tokar wrote: > > On 14 October 2010 07:17, cricket wrote: > > > > > But let's back up a bit--do you have Sale & Customer models? What I > > > was getting at in my earlier suggestion was that you could declare > > > options in each model for how its reporting would be conducted. > > > > For my situation at least, that doesn't seem like a great solution, as I > > don't have a one-to-one relationship with Models and Reports. Several of > my > > reports use multiple models, and several models have different reports > > associated to them. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
I did find a way to make a reports section the way I want - plugins! Just create a reports plugin and then you can add the sales, customers, etc... controllers/views. The url will look like: http://url.com/reports/sales/ On Oct 13, 1:15 pm, Michael Tokar wrote: > On 14 October 2010 07:17, cricket wrote: > > > But let's back up a bit--do you have Sale & Customer models? What I > > was getting at in my earlier suggestion was that you could declare > > options in each model for how its reporting would be conducted. > > For my situation at least, that doesn't seem like a great solution, as I > don't have a one-to-one relationship with Models and Reports. Several of my > reports use multiple models, and several models have different reports > associated to them. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
On 14 October 2010 07:17, cricket wrote: > But let's back up a bit--do you have Sale & Customer models? What I > was getting at in my earlier suggestion was that you could declare > options in each model for how its reporting would be conducted. > > For my situation at least, that doesn't seem like a great solution, as I don't have a one-to-one relationship with Models and Reports. Several of my reports use multiple models, and several models have different reports associated to them. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
On Wed, Oct 13, 2010 at 12:44 PM, Raisen wrote: > Oh yes, another question. According to the manual: > > You can configure the Router to use multiple prefixes too: > Plain Text View > > Router::connect('/profiles/:controller/:action/*', array('prefix' => > 'profiles', 'profiles' => true)); > > 1. Router::connect('/profiles/:controller/:action/*', > array('prefix' => 'profiles', 'profiles' => true)); > > I don't understand what that boolean assignment is for. It means that this route has 'profile' set, just as you would do with a regular admin route. I'm not sure why it's necessary to have both that and the 'prefix' option. It does appear that 'prefix' should suffice. Unless it's possible to have a prefixed route where $prefix is false. Makes no sense to me, though. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
On Wed, Oct 13, 2010 at 12:43 PM, Raisen wrote: > I've looked at the profiles routing before, and the reason I didn't > like was because I couldn't use the reports name for the top folder > hierarchy. So basically I have to create a sales_controller.php > instead of reports_sales_controller.php > But it looks like it's the only viable solution so far. Thanks :) I like gremlin's idea, also. To add to that, you could put the reporting functionality in a shared component. But let's back up a bit--do you have Sale & Customer models? What I was getting at in my earlier suggestion was that you could declare options in each model for how its reporting would be conducted. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
Oh yes, another question. According to the manual: You can configure the Router to use multiple prefixes too: Plain Text View Router::connect('/profiles/:controller/:action/*', array('prefix' => 'profiles', 'profiles' => true)); 1. Router::connect('/profiles/:controller/:action/*', array('prefix' => 'profiles', 'profiles' => true)); I don't understand what that boolean assignment is for. On Oct 13, 7:23 am, gremlin wrote: > What about a custom routing prefix ( ie. admin routing ) - just add > 'reports' to the prefix array and then in the sales controller do a > reports_index function and in the customers controller define a > reports_index function and cakes default routing will give you the 2 > urls you used as an example. > > On Oct 13, 2:22 am, Michael T wrote: > > > I have to do a similar thing in my Cake app, so I'm very interested to > > hear how you go about it in the end. For the time being I've taken > > your first approach of having a report-per-action in the one > > controller. > > > I was thinking about defining each report in the Model layer however > > (similar to what cricket was saying) by parameterising each report > > into the necessary fields and then defining them in the app itself or > > in the database. Hadn't thought about the routing issues yet however. > > > On Oct 13, 12:44 pm, cricket wrote: > > > > Why not just use a single controller that $uses each of the models in > > > question? > > > > Router::connect( > > > '/reports/:type', > > > array( > > > 'controller' => 'reports', > > > 'action' => 'view' > > > ), > > > array( > > > 'type' => '[a-z]+', > > > 'pass' => array('type') > > > ) > > > ); > > > > public function view($type = null) > > > { > > > if (!$type) > > > { > > > // ... > > > } > > > > $model = Inflector::modelize($type); > > > // ... > > > > } > > > On Tue, Oct 12, 2010 at 7:27 PM, Raisen wrote: > > > > Assume that I have a reports page where there would be multiple sub- > > > > reports. I want the urls to look like: > > > > > /reports/sales/ > > > > /reports/customers/ > > > > > One way I managed to do that was to create actions inside the reports > > > > controller for each subreport, but I am trying to do something > > > > different. I want each subreport to have its own controller,view. > > > > Basically I would have a controller named: > > > > > reports_sales_controller > > > > > and views > > > > > /reports/sales/index.ctp > > > > > Is that possible? > > > > > I was trying to do something like: > > > > > Router::connect('/reports/(.*)/*', array('controller'=>'$1', > > > > 'action'=>'index')); > > > > > which probably it's way off what I want. > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers > > > > with their CakePHP related questions. > > > > > You received this message because you are subscribed to the Google > > > > Groups "CakePHP" group. > > > > To post to this group, send email to cake-php@googlegroups.com > > > > To unsubscribe from this group, send email to > > > > cake-php+unsubscr...@googlegroups.com For more options, visit this > > > > group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
I've looked at the profiles routing before, and the reason I didn't like was because I couldn't use the reports name for the top folder hierarchy. So basically I have to create a sales_controller.php instead of reports_sales_controller.php But it looks like it's the only viable solution so far. Thanks :) On Oct 13, 7:23 am, gremlin wrote: > What about a custom routing prefix ( ie. admin routing ) - just add > 'reports' to the prefix array and then in the sales controller do a > reports_index function and in the customers controller define a > reports_index function and cakes default routing will give you the 2 > urls you used as an example. > > On Oct 13, 2:22 am, Michael T wrote: > > > I have to do a similar thing in my Cake app, so I'm very interested to > > hear how you go about it in the end. For the time being I've taken > > your first approach of having a report-per-action in the one > > controller. > > > I was thinking about defining each report in the Model layer however > > (similar to what cricket was saying) by parameterising each report > > into the necessary fields and then defining them in the app itself or > > in the database. Hadn't thought about the routing issues yet however. > > > On Oct 13, 12:44 pm, cricket wrote: > > > > Why not just use a single controller that $uses each of the models in > > > question? > > > > Router::connect( > > > '/reports/:type', > > > array( > > > 'controller' => 'reports', > > > 'action' => 'view' > > > ), > > > array( > > > 'type' => '[a-z]+', > > > 'pass' => array('type') > > > ) > > > ); > > > > public function view($type = null) > > > { > > > if (!$type) > > > { > > > // ... > > > } > > > > $model = Inflector::modelize($type); > > > // ... > > > > } > > > On Tue, Oct 12, 2010 at 7:27 PM, Raisen wrote: > > > > Assume that I have a reports page where there would be multiple sub- > > > > reports. I want the urls to look like: > > > > > /reports/sales/ > > > > /reports/customers/ > > > > > One way I managed to do that was to create actions inside the reports > > > > controller for each subreport, but I am trying to do something > > > > different. I want each subreport to have its own controller,view. > > > > Basically I would have a controller named: > > > > > reports_sales_controller > > > > > and views > > > > > /reports/sales/index.ctp > > > > > Is that possible? > > > > > I was trying to do something like: > > > > > Router::connect('/reports/(.*)/*', array('controller'=>'$1', > > > > 'action'=>'index')); > > > > > which probably it's way off what I want. > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers > > > > with their CakePHP related questions. > > > > > You received this message because you are subscribed to the Google > > > > Groups "CakePHP" group. > > > > To post to this group, send email to cake-php@googlegroups.com > > > > To unsubscribe from this group, send email to > > > > cake-php+unsubscr...@googlegroups.com For more options, visit this > > > > group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
What about a custom routing prefix ( ie. admin routing ) - just add 'reports' to the prefix array and then in the sales controller do a reports_index function and in the customers controller define a reports_index function and cakes default routing will give you the 2 urls you used as an example. On Oct 13, 2:22 am, Michael T wrote: > I have to do a similar thing in my Cake app, so I'm very interested to > hear how you go about it in the end. For the time being I've taken > your first approach of having a report-per-action in the one > controller. > > I was thinking about defining each report in the Model layer however > (similar to what cricket was saying) by parameterising each report > into the necessary fields and then defining them in the app itself or > in the database. Hadn't thought about the routing issues yet however. > > On Oct 13, 12:44 pm, cricket wrote: > > > Why not just use a single controller that $uses each of the models in > > question? > > > Router::connect( > > '/reports/:type', > > array( > > 'controller' => 'reports', > > 'action' => 'view' > > ), > > array( > > 'type' => '[a-z]+', > > 'pass' => array('type') > > ) > > ); > > > public function view($type = null) > > { > > if (!$type) > > { > > // ... > > } > > > $model = Inflector::modelize($type); > > // ... > > > } > > On Tue, Oct 12, 2010 at 7:27 PM, Raisen wrote: > > > Assume that I have a reports page where there would be multiple sub- > > > reports. I want the urls to look like: > > > > /reports/sales/ > > > /reports/customers/ > > > > One way I managed to do that was to create actions inside the reports > > > controller for each subreport, but I am trying to do something > > > different. I want each subreport to have its own controller,view. > > > Basically I would have a controller named: > > > > reports_sales_controller > > > > and views > > > > /reports/sales/index.ctp > > > > Is that possible? > > > > I was trying to do something like: > > > > Router::connect('/reports/(.*)/*', array('controller'=>'$1', > > > 'action'=>'index')); > > > > which probably it's way off what I want. > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > > with their CakePHP related questions. > > > > You received this message because you are subscribed to the Google Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
I have to do a similar thing in my Cake app, so I'm very interested to hear how you go about it in the end. For the time being I've taken your first approach of having a report-per-action in the one controller. I was thinking about defining each report in the Model layer however (similar to what cricket was saying) by parameterising each report into the necessary fields and then defining them in the app itself or in the database. Hadn't thought about the routing issues yet however. On Oct 13, 12:44 pm, cricket wrote: > Why not just use a single controller that $uses each of the models in > question? > > Router::connect( > '/reports/:type', > array( > 'controller' => 'reports', > 'action' => 'view' > ), > array( > 'type' => '[a-z]+', > 'pass' => array('type') > ) > ); > > public function view($type = null) > { > if (!$type) > { > // ... > } > > $model = Inflector::modelize($type); > // ... > > } > On Tue, Oct 12, 2010 at 7:27 PM, Raisen wrote: > > Assume that I have a reports page where there would be multiple sub- > > reports. I want the urls to look like: > > > /reports/sales/ > > /reports/customers/ > > > One way I managed to do that was to create actions inside the reports > > controller for each subreport, but I am trying to do something > > different. I want each subreport to have its own controller,view. > > Basically I would have a controller named: > > > reports_sales_controller > > > and views > > > /reports/sales/index.ctp > > > Is that possible? > > > I was trying to do something like: > > > Router::connect('/reports/(.*)/*', array('controller'=>'$1', > > 'action'=>'index')); > > > which probably it's way off what I want. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Custom router question
Why not just use a single controller that $uses each of the models in question? Router::connect( '/reports/:type', array( 'controller' => 'reports', 'action' => 'view' ), array( 'type' => '[a-z]+', 'pass' => array('type') ) ); public function view($type = null) { if (!$type) { // ... } $model = Inflector::modelize($type); // ... } On Tue, Oct 12, 2010 at 7:27 PM, Raisen wrote: > Assume that I have a reports page where there would be multiple sub- > reports. I want the urls to look like: > > /reports/sales/ > /reports/customers/ > > One way I managed to do that was to create actions inside the reports > controller for each subreport, but I am trying to do something > different. I want each subreport to have its own controller,view. > Basically I would have a controller named: > > reports_sales_controller > > and views > > /reports/sales/index.ctp > > Is that possible? > > I was trying to do something like: > > Router::connect('/reports/(.*)/*', array('controller'=>'$1', > 'action'=>'index')); > > which probably it's way off what I want. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Custom router question
Assume that I have a reports page where there would be multiple sub- reports. I want the urls to look like: /reports/sales/ /reports/customers/ One way I managed to do that was to create actions inside the reports controller for each subreport, but I am trying to do something different. I want each subreport to have its own controller,view. Basically I would have a controller named: reports_sales_controller and views /reports/sales/index.ctp Is that possible? I was trying to do something like: Router::connect('/reports/(.*)/*', array('controller'=>'$1', 'action'=>'index')); which probably it's way off what I want. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en