Re: Determine current action using different method than $this-name
I think something like $this-params['controller'] will just give the currently executing controller (main or plugin) and this is not what you want. I'm unclear on exactly what your goal is, but it seems there are two options: 1. make the plugin code generic, have it do its thing, return data or whatever, then process that data appropriately in the main controller action 2. if the plugin code has to be able to process conditionally based on where it was called from, I think you'll have to find a way to pass this info into the plugin code, as an extra parameter or something. maybe... in the main1 controller: requestAction(/pluginController/pluginAction/main1/); and then function pluginAction($fromControllerName) { if ($fromControllerName == 'main1') { ... } elseif ($fromControllerName == 'main2') { ... } hope this helps... On Apr 1, 5:38 pm, gerbenzomp [EMAIL PROTECTED] wrote: Sorry, I meant controller, instead of action in the above post. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
No 'standard' way how to determine action where requestAction was called from (except for $_GET['url'] which is not 'clean usage of cake' as You obviously do not need to use $_GET directly in cake). But: You can pass some parameter to requestAction like $a = $this-requestAction('/some/url', array('parent_action' = 'whatever'); and then (inside of called method) if (!empty($this-params['requested'])) look for content of $this- params['parent_action'] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
I tried both your examples, but the problem seems to be that I use the requestaction within default.thtml, and it seems there's no data available about the parent action... Is there some other way, because now I use the $_GET['url'] method, which is just very dirty and unreliable. On 2 apr, 08:23, jitka [EMAIL PROTECTED] wrote: No 'standard' way how to determine action where requestAction was called from (except for $_GET['url'] which is not 'clean usage of cake' as You obviously do not need to use $_GET directly in cake). But: You can pass some parameter to requestAction like $a = $this-requestAction('/some/url', array('parent_action' = 'whatever'); and then (inside of called method) if (!empty($this-params['requested'])) look for content of $this- params['parent_action'] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
On Apr 2, 12:19 pm, gerbenzomp [EMAIL PROTECTED] wrote: I tried both your examples, but the problem seems to be that I use the requestaction within default.thtml, and it seems there's no data available about the parent action... Is there some other way, because now I use the $_GET['url'] method, which is just very dirty and unreliable. a layout is processed by an instance of the class view (as is a 'view') and $this-name and $this-action will be available for you to use; aswell as other bits of info which you'll see with pr($this); die; in the layout. When in the layout there is no parent action, as you don't get a layout using requestAction. You may find though that using requestAction on every page (does this change at all?) will add significantly (approx 30% min.) to your page load times. You are probably better off simply using a component to get whatever this plugin is processing, and an element to display it. If the data doesn't change the component and/or element can refer to a cached source of info. HTH, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
The problem seemed to be that I cannot pass the variable $this-name through requestaction. So that's another reason (apart from loading times) to use your 'mini-controllers' approach in this case. Thnx, it's working now! Is your mini-controllers method ever going to be a standard part of Cake? Because if requestAction is so heavy this is a great workaround! On 2 apr, 12:30, AD7six [EMAIL PROTECTED] wrote: On Apr 2, 12:19 pm, gerbenzomp [EMAIL PROTECTED] wrote: I tried both your examples, but the problem seems to be that I use the requestaction within default.thtml, and it seems there's no data available about the parent action... Is there some other way, because now I use the $_GET['url'] method, which is just very dirty and unreliable. a layout is processed by an instance of the class view (as is a 'view') and $this-name and $this-action will be available for you to use; aswell as other bits of info which you'll see with pr($this); die; in the layout. When in the layout there is no parent action, as you don't get a layout using requestAction. You may find though that using requestAction on every page (does this change at all?) will add significantly (approx 30% min.) to your page load times. You are probably better off simply using a component to get whatever this plugin is processing, and an element to display it. If the data doesn't change the component and/or element can refer to a cached source of info. HTH, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
On Apr 2, 1:40 pm, gerbenzomp [EMAIL PROTECTED] wrote: The problem seemed to be that I cannot pass the variable $this-name through requestaction. It would probably get overwritten if you put it in the params as 'name', but you could have passed it either in the url echo $this-requestAction ('/url/stuff/camefrom:'.$this-name.'.'. $this-action.. or as a a differently named parameter. echo $this-requestAction ('/url/stuff', array('camefrom'='.$this- name.'.'.$this-action.. So that's another reason (apart from loading times) to use your 'mini-controllers' approach in this case. Thnx, it's working now! Cool. Is your mini-controllers method ever going to be a standard part of Cake? Because if requestAction is so heavy this is a great workaround! I wouldn't expect so, it's not really adding to cake but using it. Also I don't know if it duplicates something that is planned or already present. But who knows. One thing that might be relevant and becomes interesting in 1.2 is the ability to cache elements (which I alluded to covertly in my previous message); so instead of putting effort into the component/controller side of things, you /could/ put requestAction or other logic in your element and cache the result. it works like this echo $this-element('elementname',array('cache'='1 week',other=sfuff,if=necessary)); Anyway, glad you found a solution, cheers, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
One thing that might be relevant and becomes interesting in 1.2 is the ability to cache elements (which I alluded to covertly in my previous message); so instead of putting effort into the component/controller side of things, you /could/ put requestAction or other logic in your element and cache the result. If I understand you correctly, this means in 1.2 using requestAction within elements won't affect loading times so dramatically? That's good news! But it is probably still good practice to keep our systems light ;) One more question about the mini-contollers method in combination with plugins: I've put my component in: app/plugins/plugin_name/controllers/components/component_name.php The model I want to load from the component resides in plugins/models/ model_name.php but has a different name than the main plugin. When I use loadmodel('model_name'); Cake doesn't find the model I'm looking for, and when I use loadPluginModels('model_name'); it seems to find the plugin's app_model, not the model in the models folder (which has a different name from the plugin's app_model, because I want to be able to have several models in one plugin folder). How can I acces that model from within the component? thx for the great job you did on the mini-contollers, I really use them a lot! Gerben. On 2 apr, 14:01, AD7six [EMAIL PROTECTED] wrote: On Apr 2, 1:40 pm, gerbenzomp [EMAIL PROTECTED] wrote: The problem seemed to be that I cannot pass the variable $this-name through requestaction. It would probably get overwritten if you put it in the params as 'name', but you could have passed it either in the url echo $this-requestAction ('/url/stuff/camefrom:'.$this-name.'.'. $this-action.. or as a a differently named parameter. echo $this-requestAction ('/url/stuff', array('camefrom'='.$this- name.'.'.$this-action.. So that's another reason (apart from loading times) to use your 'mini-controllers' approach in this case. Thnx, it's working now! Cool. Is your mini-controllers method ever going to be a standard part of Cake? Because if requestAction is so heavy this is a great workaround! I wouldn't expect so, it's not really adding to cake but using it. Also I don't know if it duplicates something that is planned or already present. But who knows. One thing that might be relevant and becomes interesting in 1.2 is the ability to cache elements (which I alluded to covertly in my previous message); so instead of putting effort into the component/controller side of things, you /could/ put requestAction or other logic in your element and cache the result. it works like this echo $this-element('elementname',array('cache'='1 week',other=sfuff,if=necessary)); Anyway, glad you found a solution, cheers, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
Sorry, I meant controller, instead of action in the above post. On 2 apr, 02:29, gerbenzomp [EMAIL PROTECTED] wrote: I've made a plugin which is included in every page using requestAction, but I need to show and hide different parts of the view depending on the current main action (the action which is visible in the url). I've tried using if($this-name == 'my_action'){ //} else { // } But that method always returns the name of the plugin action, not the main action in which the plugin view is included. Is there a good way to do this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determine current action using different method than $this-name
This is probably a crappy response, but try print_r($this-params) and see what's in there. It might have what you're looking for. On Apr 1, 5:29 pm, gerbenzomp [EMAIL PROTECTED] wrote: I've made a plugin which is included in every page using requestAction, but I need to show and hide different parts of the view depending on the current main action (the action which is visible in the url). I've tried using if($this-name == 'my_action'){ //} else { // } But that method always returns the name of the plugin action, not the main action in which the plugin view is included. Is there a good way to do this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---