Re: Random query question
Thank you guys. Going through your suggestions now. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Random query question
Hi everybody. I have a companies table and those companies have promotions. Each company can have up to 10 promotions but only 2 can be displayed from each company at one time. I've been trying to figure out how to generate a single query that will select only 2 promotions randomly from each company. Is that even possible? see screenshot attached -- http://screencast.com/t/dB2sqcEns so basically randomly select only 2 promotions with the same company_id... possible? how? Thank you for your time. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cache filenames messed up
It worked!!! Thanks!!! On Mar 14, 2:51 pm, Sarpidon epap...@gmail.com wrote: Thank you Jeremy. I am going to try that and see... On Mar 2, 5:08 pm, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: This has come up before, but the answer is not obvious. Here's a stolen reply from an earlier post: This is actually caused by a bug in the PCRE library on Centos / Red Hat. See thishttp://blog.echothis.com/2011/01/27/fixing-cakephp-1-3s-cache-key-err...post for how to fix it. Jeremy Burns Class Outfit jeremybu...@classoutfit.comhttp://www.classoutfit.com On 2 Mar 2011, at 15:07,Sarpidonwrote: Forgot the screenshot http://screencast.com/t/rcvkSlUs -- Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Lock a page that is being edited by another user
Hi, I tried searching for it but I cannot find anything useful. I am trying to lock a page that is being edited by another user. In our site there could be many admins editing the frontpage (choosing main articles and so on), I want to be able to restrict the page to be edited by a single user every time (and display a message to users that are trying to edit the particular page . e.g. - This page is being edited by user please try again later). Is there a preferable approach to something like this? I guess I could store a cookie when the page is open and closed but I am not sure how many things I have to take into consideration. Any help will be appreciated. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cache filenames messed up
Thank you Jeremy. I am going to try that and see... On Mar 2, 5:08 pm, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: This has come up before, but the answer is not obvious. Here's a stolen reply from an earlier post: This is actually caused by a bug in the PCRE library on Centos / Red Hat. See thishttp://blog.echothis.com/2011/01/27/fixing-cakephp-1-3s-cache-key-err...blog post for how to fix it. Jeremy Burns Class Outfit jeremybu...@classoutfit.comhttp://www.classoutfit.com On 2 Mar 2011, at 15:07,Sarpidonwrote: Forgot the screenshot http://screencast.com/t/rcvkSlUs -- Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Lock a page that is being edited by another user
Ok. I guess I am looking for Optimistic Locking, has this been implemented on CakePHP? Anyone? Thanks On Mar 14, 2:50 pm, Sarpidon epap...@gmail.com wrote: Hi, I tried searching for it but I cannot find anything useful. I am trying to lock a page that is being edited by another user. In our site there could be many admins editing the frontpage (choosing main articles and so on), I want to be able to restrict the page to be edited by a single user every time (and display a message to users that are trying to edit the particular page . e.g. - This page is being edited by user please try again later). Is there a preferable approach to something like this? I guess I could store a cookie when the page is open and closed but I am not sure how many things I have to take into consideration. Any help will be appreciated. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Lock a page that is being edited by another user
Thank you for your answers. What I did was to create a hidden input with the current timestamp (when the edit page is generated) Upon save I check if the record has a greater timestamp than the one from the hidden input and if so i redirect back with a flash message saying This post has already been updated by user XXX 3 minutes ago. I think this is a better approach as it does not lock the page rather than check whether the record has been updated while you were editing the page. The problem with this is that all the changes are lost. So I am thinking of creating custom validation function that will handle the data. And no I have another problem.I am trying to display multiple flash messages and I cannot seem to be able to make it work I tried this http://mrphp.com.au/code/multiple-flash-messages-style-cakephp but no lack (I am using 1.3.7 - I've made the changes for 1.3 but still... ) On Mar 14, 4:13 pm, mi...@brightstorm.co.uk wrote: Ok. I guess I am looking for Optimistic Locking, has this been implemented on CakePHP? Anyone? I'd add a field in your article table called editor_id and fill with the user id when you begin to edit. then remove the id when you save. obviously this will cause all sorts of locking hell if your user fails to save the article which is going to bite you on whatever way you do it. mikek Thanks On Mar 14, 2:50 pm, Sarpidon epap...@gmail.com wrote: Hi, I tried searching for it but I cannot find anything useful. I am trying to lock a page that is being edited by another user. In our site there could be many admins editing the frontpage (choosing main articles and so on), I want to be able to restrict the page to be edited by a single user every time (and display a message to users that are trying to edit the particular page . e.g. - This page is being edited by user please try again later). Is there a preferable approach to something like this? I guess I could store a cookie when the page is open and closed but I am not sure how many things I have to take into consideration. Any help will be appreciated. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Lock a page that is being edited by another user
Ok, this is what I did for the multiple messages. I created an array $allmessages = array(); and then on every action on the same function I pushed a message into the array like so: array_push($allmessages, 'my message here'); and at the end of the function I imploded the array and set the flash message like so: $allmessages = implode('br /', $allmessages); $this-Session-setFlash($allmessages,'flash_failure'); // All failure messages use same template good / bad practice? Cannot think of any other easy / fast way to do it... On Mar 14, 5:29 pm, Sarpidon epap...@gmail.com wrote: Thank you for your answers. What I did was to create a hidden input with the current timestamp (when the edit page is generated) Upon save I check if the record has a greater timestamp than the one from the hidden input and if so i redirect back with a flash message saying This post has already been updated by user XXX 3 minutes ago. I think this is a better approach as it does not lock the page rather than check whether the record has been updated while you were editing the page. The problem with this is that all the changes are lost. So I am thinking of creating custom validation function that will handle the data. And no I have another problem.I am trying to display multiple flash messages and I cannot seem to be able to make it work I tried thishttp://mrphp.com.au/code/multiple-flash-messages-style-cakephp but no lack (I am using 1.3.7 - I've made the changes for 1.3 but still... ) On Mar 14, 4:13 pm, mi...@brightstorm.co.uk wrote: Ok. I guess I am looking for Optimistic Locking, has this been implemented on CakePHP? Anyone? I'd add a field in your article table called editor_id and fill with the user id when you begin to edit. then remove the id when you save. obviously this will cause all sorts of locking hell if your user fails to save the article which is going to bite you on whatever way you do it. mikek Thanks On Mar 14, 2:50 pm, Sarpidon epap...@gmail.com wrote: Hi, I tried searching for it but I cannot find anything useful. I am trying to lock a page that is being edited by another user. In our site there could be many admins editing the frontpage (choosing main articles and so on), I want to be able to restrict the page to be edited by a single user every time (and display a message to users that are trying to edit the particular page . e.g. - This page is being edited by user please try again later). Is there a preferable approach to something like this? I guess I could store a cookie when the page is open and closed but I am not sure how many things I have to take into consideration. Any help will be appreciated. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Cache filenames messed up
Hi. I have moved one of my applications to a new server (CentOS) and I have the following problem. The cached view files (elements or whole views) are created with messed up filenames. Here is a screenshot from the folder on two servers. I am not sure what to do... has anyone else experienced something similar? Can I create cache elements with custom filenames? Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cache filenames messed up
Forgot the screenshot http://screencast.com/t/rcvkSlUs -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Model - Retrieve data
Hi. I am not sure how to do the following - what is the best practice. I have a Projectcategories table that has many Projects. A Project has many Projectimages. What I want to do is to get the Projectcategory and a random image for each Project from Projectimages. For example: Array ( [Projectcategory] = Array ( [id] = 2 [title] = Residential [alias] = residential [imagepath] = [weight] = 1 [published] = 1 ) [Project] = Array ( [0] = Array ( [id] = 1 [category_id] = 2 [title] = Project title [weight] = 1 [published] = 1 [Projectimage] = Random image from Projectimages table ) ) ) I hope I am making my self clear :) Any ideas? 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: Model - Retrieve data
Or even better this!!! Example: Array ( [Projectcategory] = Array ( [id] = 2 [title] = Residential [alias] = residential [imagepath] = [weight] = 1 [published] = 1 [RANDOM IMAGE FROM PROJECTS BELONG TO THIS CATEGORY FOUND IN PROJECTIMAGES TABLE WHICH BELONGS TO PROJECTS] ) } Thanks! On Nov 23, 5:49 pm, Sarpidon epap...@gmail.com wrote: Hi. I am not sure how to do the following - what is the best practice. I have a Projectcategories table that has many Projects. A Project has many Projectimages. What I want to do is to get the Projectcategory and a random image for each Project from Projectimages. For example: Array ( [Projectcategory] = Array ( [id] = 2 [title] = Residential [alias] = residential [imagepath] = [weight] = 1 [published] = 1 ) [Project] = Array ( [0] = Array ( [id] = 1 [category_id] = 2 [title] = Project title [weight] = 1 [published] = 1 [Projectimage] = Random image from Projectimages table ) ) ) I hope I am making my self clear :) Any ideas? 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: Console bake - modify templates
Thank you Mark! This is very helpful. Evangelos On Nov 19, 2:54 am, euromark dereurom...@googlemail.com wrote: answers and examples:http://www.dereuromark.de/2010/06/22/cake-bake-custom-templates/ feel free to point out any missing pieces :) for separating admin views from normal ones a ticket has been submitted as of now i don't know how to do that. On 19 Nov., 01:04, Sarpidon epap...@gmail.com wrote: Hi! I am trying to modify the templates files to generate custom applications (with my css, actions etc) However I am not sure how to find specific data passed to the template files... for example take console/templates/default/views/index.ctp in there I want to be able to read the type of field (eg is it datetime? is it tinyint and so on). Where can I find this information? Where can I find what the $fields array holds or the $details array holds and so on... I hope I am making sense :) The same goes for other files like controller_actions (for example how do I separate admin views (admin_index) from normal ones... 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: Console bake - modify templates
Great! Thanks! On Nov 19, 10:40 am, majna majna...@gmail.com wrote: For separating admin views from public, (like admin_index, index) remove this line: $template = str_replace($prefix . '_', '', $template); in ViewTask::getTemplate() cake/console/libs/tasks/view.php On Nov 19, 1:54 am, euromark dereurom...@googlemail.com wrote: answers and examples:http://www.dereuromark.de/2010/06/22/cake-bake-custom-templates/ feel free to point out any missing pieces :) for separating admin views from normal ones a ticket has been submitted as of now i don't know how to do that. On 19 Nov., 01:04, Sarpidon epap...@gmail.com wrote: Hi! I am trying to modify the templates files to generate custom applications (with my css, actions etc) However I am not sure how to find specific data passed to the template files... for example take console/templates/default/views/index.ctp in there I want to be able to read the type of field (eg is it datetime? is it tinyint and so on). Where can I find this information? Where can I find what the $fields array holds or the $details array holds and so on... I hope I am making sense :) The same goes for other files like controller_actions (for example how do I separate admin views (admin_index) from normal ones... 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
Console bake - modify templates
Hi! I am trying to modify the templates files to generate custom applications (with my css, actions etc) However I am not sure how to find specific data passed to the template files... for example take console/templates/default/views/index.ctp in there I want to be able to read the type of field (eg is it datetime? is it tinyint and so on). Where can I find this information? Where can I find what the $fields array holds or the $details array holds and so on... I hope I am making sense :) The same goes for other files like controller_actions (for example how do I separate admin views (admin_index) from normal ones... 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: $_POST populated, but not $this-data
Is the form created through Html helper? Also have you tried $this- Form-input ? On Oct 19, 5:59 am, tekomp btisch...@gmail.com wrote: When trying to login to my app using auth component and form helper in 1.3.4, the password value is not being populated in $this-data for some reason, even though it's set in $_POST fine. Here's debug from $_POST (first array) and $this-data: Array ( [_method] = POST [data] = Array ( [User] = Array ( [username] = myusername [password] = password ) ) ) Array ( [User] = Array ( [username] = myusername [password] = ) ) The form is very basic with just these inputs: echo $form-input('username'); echo $form-input('password'); Any ideas? Thanks. 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: Cache actions vs elements
Thank you for your replies. I am still somewhat confused. So how do I cache view.ctp ?? it is not an element, it is displayed through $content_for_layout I've tried adding cake:nocache on my elements but it does not seem to give the result I need. For example I have this element: cake:nocache if($this-params['controller'] == 'frontapage'): display image 1 else: display image 2 endif; /cake:nocache This is not working. When a user requests 'frontpage' the element is cached with display image 1 and stays like this even if the user requests another page. If the cache is deleted and the user requests a page other than the frontpage image 2 is displayed and stays like this I guess I have to use two different cached elements? Give them a different key, one for the frontpage and one for the other pages? But this is not very efficient is it? On Oct 10, 5:33 pm, euromark dereurom...@googlemail.com wrote: i would include the helper but NOT use the var $cacheAction = '1 hour' now set up your elements and cache them as you did before this way the page itself should not be cached (no cacheAction declared) but the elements should! On 10 Okt., 16:28, calzone calz...@gmail.com wrote: I believe cache action is used to cache the entire request. You would have to use nocache on the sections of your ctp file you don't want cached To cache just the elements, you would have to cache the actions associated with each element. On Oct 10, 2:42 am, Sarpidon epap...@gmail.com wrote: Hello. I have this layout body ?php echo $this-element(header, array('cache'' = true); ? ?php echo $content_for_layout; ? ?php echo $this-element(footer, array('cache'' = true); ? /body This creates two cache files in tmp/cache/views on a controller I have this: function view() { var $cacheAction = '1 hour' } for some reason caching View caches the whole page again, including header and footer. Is this how is supposed to work? Because this is causing problems when the element has dynamic content (like latest news). I thought caching an action (like view) will only store the contents of view.ctp and not the whole layout. Am I missing something? 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
Cache actions vs elements
Hello. I have this layout body ?php echo $this-element(header, array('cache'' = true); ? ?php echo $content_for_layout; ? ?php echo $this-element(footer, array('cache'' = true); ? /body This creates two cache files in tmp/cache/views on a controller I have this: function view() { var $cacheAction = '1 hour' } for some reason caching View caches the whole page again, including header and footer. Is this how is supposed to work? Because this is causing problems when the element has dynamic content (like latest news). I thought caching an action (like view) will only store the contents of view.ctp and not the whole layout. Am I missing something? 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: $this-params['named'] is empty
Can someone give me an example. I just cannot make it work. Category Controller: public function view() {} Routes: Router::connectNamed(array('alias')); url /categories/view/alias:something $this-params['named'] comes up empty ... On Sep 25, 12:19 am, Miles J mileswjohn...@gmail.com wrote: Because you are not passing them as named params, you are passing them as method arguments. public function view($category) { } On Sep 24, 7:17 am, Sarpidon epap...@gmail.com wrote: Hi. I am not sure what I am doing wrong but even though I am using named params $this-params['named'] always shows up as empty. Routes Router::connect('/news/:category', array('controller' = 'categories', 'action' = 'view'), array('pass' = array('category'))); View echo $html-link($link['name'], array('controller' = 'categories', 'action' = 'view', 'category' = $link['alias'])); pr($this-params) [category] = europe [named] = Array ( ) [pass] = Array ( [0] = greece ) I also tried Router::connectNamed(array('category')); Router::connect('/news/:category', array('controller' = 'categories', 'action' = 'view'), array('pass' = array('category'))); and Router::connectNamed(array('category')); Router::connect('/news/*, array('controller' = 'categories', 'action' = 'view')); no success any help? 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
$this-params['named'] is empty
Hi. I am not sure what I am doing wrong but even though I am using named params $this-params['named'] always shows up as empty. Routes Router::connect('/news/:category', array('controller' = 'categories', 'action' = 'view'), array('pass' = array('category'))); View echo $html-link($link['name'], array('controller' = 'categories', 'action' = 'view', 'category' = $link['alias'])); pr($this-params) [category] = europe [named] = Array ( ) [pass] = Array ( [0] = greece ) I also tried Router::connectNamed(array('category')); Router::connect('/news/:category', array('controller' = 'categories', 'action' = 'view'), array('pass' = array('category'))); and Router::connectNamed(array('category')); Router::connect('/news/*, array('controller' = 'categories', 'action' = 'view')); no success any help? 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