Re: Looking for something better then requestAction?
Ah, great! Thanks. On Apr 7, 6:15 pm, majna majna...@gmail.com wrote: Use cache key for each element(): echo $this-element('news/featured', array('cache'=array('time'='+1 hour', 'key'='featured_news_2'))); On Apr 6, 1:33 pm, Walther waltherl...@gmail.com wrote: I did try using the cache, but because I may be calling the same element a few times but with different inputs it won't work (It just redisplays the first item for that element). On Apr 6, 1:23 pm, majna majna...@gmail.com wrote: Use elements cache :)http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi... On Apr 6, 12:06 pm, Walther waltherl...@gmail.com wrote: I believe I've found a solution. For each possible item that can be added to the homepage I store the name of the controller that is called. By simply changing this to the model name and using App::Import in the homepage model (Where I fetch the items from the database) I have gotten rid of the requestActions. Seems to be working quite well. From those who are more experienced at Cake, is this a better way of doing it? On Apr 6, 10:51 am, Walther waltherl...@gmail.com wrote: Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item));} else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory']));} ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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: Looking for something better then requestAction?
Use cache key for each element(): echo $this-element('news/featured', array('cache'=array('time'='+1 hour', 'key'='featured_news_2'))); On Apr 6, 1:33 pm, Walther waltherl...@gmail.com wrote: I did try using the cache, but because I may be calling the same element a few times but with different inputs it won't work (It just redisplays the first item for that element). On Apr 6, 1:23 pm, majna majna...@gmail.com wrote: Use elements cache :)http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi... On Apr 6, 12:06 pm, Walther waltherl...@gmail.com wrote: I believe I've found a solution. For each possible item that can be added to the homepage I store the name of the controller that is called. By simply changing this to the model name and using App::Import in the homepage model (Where I fetch the items from the database) I have gotten rid of the requestActions. Seems to be working quite well. From those who are more experienced at Cake, is this a better way of doing it? On Apr 6, 10:51 am, Walther waltherl...@gmail.com wrote: Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item));} else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory']));} ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Looking for something better then requestAction?
Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item)); } else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory'])); } ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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: Looking for something better then requestAction?
I believe I've found a solution. For each possible item that can be added to the homepage I store the name of the controller that is called. By simply changing this to the model name and using App::Import in the homepage model (Where I fetch the items from the database) I have gotten rid of the requestActions. Seems to be working quite well. From those who are more experienced at Cake, is this a better way of doing it? On Apr 6, 10:51 am, Walther waltherl...@gmail.com wrote: Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item));} else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory']));} ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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: Looking for something better then requestAction?
Use elements cache :) http://bakery.cakephp.org/articles/view/creating-reusable-elements-with-requestaction On Apr 6, 12:06 pm, Walther waltherl...@gmail.com wrote: I believe I've found a solution. For each possible item that can be added to the homepage I store the name of the controller that is called. By simply changing this to the model name and using App::Import in the homepage model (Where I fetch the items from the database) I have gotten rid of the requestActions. Seems to be working quite well. From those who are more experienced at Cake, is this a better way of doing it? On Apr 6, 10:51 am, Walther waltherl...@gmail.com wrote: Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item));} else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory']));} ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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: Looking for something better then requestAction?
I did try using the cache, but because I may be calling the same element a few times but with different inputs it won't work (It just redisplays the first item for that element). On Apr 6, 1:23 pm, majna majna...@gmail.com wrote: Use elements cache :)http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi... On Apr 6, 12:06 pm, Walther waltherl...@gmail.com wrote: I believe I've found a solution. For each possible item that can be added to the homepage I store the name of the controller that is called. By simply changing this to the model name and using App::Import in the homepage model (Where I fetch the items from the database) I have gotten rid of the requestActions. Seems to be working quite well. From those who are more experienced at Cake, is this a better way of doing it? On Apr 6, 10:51 am, Walther waltherl...@gmail.com wrote: Hi all In an app that I am currently developing I wish to give the administrator the ability to customise the home page of the app by being able to include various other things into the home page (For example, the admin may wish to show a welcome message which uses the pages controller, and they may wish to show a calendar using the calendars controller and an unlimited number of other views). What I am currently doing is on the homepage view I do a loop through the homepages table and call the homepages.ctp element and sends it the relevant data for the view that needs to be displayed. The homepage element then calls the relevant element for whatever controller the admin has chosen, this controller may be part of a plugin. The homepages.ctp element looks as follows: ?php if ($item['MenuLink']['plugin_id'] == 0) { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item));} else { $View = ClassRegistry::getObject('view'); echo $View-element('homepages/' . $item['MenuLink']['controller'], array('item' = $item, 'plugin' = $item['MenuLink']['Plugin'] ['directory']));} ? As an example the homepages/pages.ctp element looks as follows: ?php $pageToShow = $this-requestAction('/pages/index/' . $item ['Homepage']['options']); ? ?php if (isset($pageToShow)) : ? div div id=dataInfo Created: span class=timeago title=?php echo $pageToShow['Page'] ['created']; ??php echo $date-prettyDate($pageToShow['Page'] ['created']); ?/spanbr / Modified: span class=timeago title=?php echo $pageToShow ['Page']['modified']; ??php echo $date-prettyDate($pageToShow ['Page']['modified']); ?/spanbr / Tags: ?php echo $pageToShow['Page']['tags']; ? /div h1 id=nice_name?php echo $pageToShow['Page']['title']; ?/h1 div id=content style=margin-top:10px; text-align:left; ?php echo $pageToShow['Page']['text']; ? /div /div ?php else : ? No page ?php endif; ? It is working well. However, I realise that requestAction is quite intensive as it acts like another server request, is there some other method that I can use that will achieve the same outcome but use less server resources? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---