Re: Cakephp 1.3 - Detect if Ajax if session expired
Thank you! This is how I have tried in the first place but it is not working. $this->RequestHandler->isAjax() is null or false, so it will never execute the conditional code. Best regards! -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Re: Cakephp 1.3 - Detect if Ajax if session expired
Thank you! The thing is that the application was written in Cakephp 1.3 and we are not planning to upgrade it any time soon. Thank you for your warning. The solution provided is very cool, but I'm looking for something that can be implemented in app_controller. This way, it will be global and I will not need to change all the controllers the way they act. Of course that I will do it your way if this is not possible, but I would be very glad to have another solution since the application is huge. Thank you! Best regards! On Fri, Aug 31, 2012 at 4:02 AM, romel javier gomez herrera < bmxquiksilver7...@gmail.com> wrote: > hi. > > RequestHandler will be discontinued > http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#requesthandlercomponent > > public function beforeFilter(){ > $this->Auth->allow('add'); > parent::beforeFilter(); > } > public function add(){ > if($this->Auth->loggedIn()){ // or if($this->Auth->User()) > $return['data'] = 'data'; > } > // if the session expired, $return is not defined > if(!isset($return)){ > $return['login'] = true; > } > $this->set('return',$return); > $this->render('ajax_view','ajax'); > } > } > ?> > > /View/Tests/ajax_view.ctp > if(isset($return)){ > echo json_encode($return); > } > ?> > > > Greetings > > 2012/8/30 Florin Trifu > >> Hi everyone! >> >> I have the following problem: in my application I have a button that >> makes an ajax request. If the session expired, the lightbox will load the >> default login page. I want to detect if the original request came from Ajax >> but I don't know exactly how to do it, because in >> app_controller::beforeFilter the request is not Ajax anymore (at least >> according to $this->RequestHandler->isAjax() ). I have tried to use >> $this->Auth->ajaxLogin to set a new view for the login if the request comes >> from an expired session. >> >> Thank you! >> >> Best regards! >> >> -- >> 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. >> Visit this group at http://groups.google.com/group/cake-php?hl=en-US. >> >> >> > > -- > 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. > Visit this group at http://groups.google.com/group/cake-php?hl=en-US. > > > -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Cakephp 1.3 - Detect if Ajax if session expired
Hi everyone! I have the following problem: in my application I have a button that makes an ajax request. If the session expired, the lightbox will load the default login page. I want to detect if the original request came from Ajax but I don't know exactly how to do it, because in app_controller::beforeFilter the request is not Ajax anymore (at least according to $this->RequestHandler->isAjax() ). I have tried to use $this->Auth->ajaxLogin to set a new view for the login if the request comes from an expired session. Thank you! Best regards! -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Best practices for AJAX forms
Hi On my page, I have a table with the information of a company and a button to edit the information. On click, through jQuery and AJAX, I want to transform that table into a form, and I can do that either by adding the form with javascript (hard coding it in javascript and requesting from the server via AJAX the information from the database) or by making a request to the controller and load the form. Which one do you think is better from the best practices point of view? Thank you in advance! -- 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
Pretty URLs
Hi In my application, if I want to access a link, the url in the browser will be something like http://application/controller/action/parameter:value. However, browsing on cakephp.org the urls are something like (and I will give you an example): http://book.cakephp.org/2.0/en/installation/advanced-installation.html. I want my urls to look the same way, with that ending in .html, and that format like browsing directories. I would also want to show different names for the controllers and for the actions, I want them in my language and not in English. How can I do that? Are those pretty urls described on this page: http://book.cakephp.org/2.0/en/installation/advanced-installation.html? Thank you in advance! Best regards! -- 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: Table 'cakehr.cake_errors' doesn't exists
Hi I'm sorry to answer so late but I had a lot of work to do. Andy, thank you for your answer. I have read the documentation to see how to do what you said, but I didn't had success yet. I have read this: http://book.cakephp.org/2.0/en/development/errors.html. I will continue reading to see how to do it. Meanwhile, the updated status is that I don't receive errors at all, although I didn't actually did anything. They are just not printed on the page anymore. So I'm kind of blind folded. If I will have any updates, I will write you as soon as possible. Best regards! From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of AD7six Sent: Monday, May 21, 2012 2:13 AM To: cake-php@googlegroups.com Subject: Re: Table 'cakehr.cake_errors' doesn't exists On Saturday, 19 May 2012 21:09:13 UTC+2, Florin Trifu wrote: Hi I have sent this problem a while ago but no one replied. I'm sending it again since it's important for me and I don't know if it was just a stupid question or no one didn't knew what to answer. I will also add the entire error maybe it will be more intuitive: Fatal Error (256): [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.cake_errors' doesn't exist #0 C:\wamp\www\test\lib\Cake\Model\Datasource\DboSource.php(436): PDOStatement->execute(Array) #1 C:\wamp\www\test\lib\Cake\Model\Datasource\Database\Mysql.php(307): DboSource->_execute('SHOW FULL COLUM...') #2 C:\wamp\www\test\lib\Cake\Model\Model.php(1209): Mysql->describe(Object(AppModel)) #3 C:\wamp\www\test\lib\Cake\View\Helper\FormHelper.php(198): Model->schema() #4 C:\wamp\www\test\lib\Cake\View\Helper\FormHelper.php(450): FormHelper->_introspectModel('CakeError', 'fields') #5 C:\wamp\www\test\app\View\Elements\menu.ctp(25): FormHelper->create(Array) Your menu element, which is included in your default layout, creates a form using the "current" model name. In the case of the CakeError controller that means it's looking for a model named CakeError too. I'd suggest creating a simple and no-dependency layout to use in the case of errors to avoid issues like this. AD -- 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 -- 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: Table 'cakehr.cake_errors' doesn't exists
Because I intentionally made a typo inside the code. Now, there is an error, I have found it, but for some unknown reason by me, is imbricated inside the HTML page. The page is re-rendered and it is putted after the search form. This means that if I want to see the error, I have to look at the source code and then navigate inside it because the error will not be printed on the page. If an error occurs, it is normal that cakePHP re-renders the page or it's just something wrong with what I've did? Thank you! From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of majna Sent: Sunday, May 20, 2012 10:07 PM To: cake-php@googlegroups.com Subject: Re: Table 'cakehr.cake_errors' doesn't exists Can you explain why there should be an err? On Sunday, May 20, 2012 8:59:10 PM UTC+2, Florin Trifu wrote: With this line of code I don't receive errors anymore, but that is not correct either, cause there should be an error. Thank you! From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of majna Sent: Sunday, May 20, 2012 2:28 PM To: cake-php@googlegroups.com Subject: Re: Table 'cakehr.cake_errors' doesn't exists Instead of: echo $this->Form->create(array('id'=>'search')); try: echo $this->Form->create(false, array('id'=>'search')); On Sunday, May 20, 2012 1:04:14 PM UTC+2, Florin Trifu wrote: Hi Majna The entire content of menu.ctp is this: Html->link('button1', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button2', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button3', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button4', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link( $this->Html->image('logout_btn.gif', array('alt'=>'logout', 'border'=>'0', 'id'=>'logout-btn')), array('controller'=>'users', 'action'=>'logout'), array('escape'=>FALSE)); ?> Form->create(array('id'=>'search')); echo $this->Form->input('search_criteria', array('label'=>false, 'id'=>'search-criteria')); echo $this->Form->submit('',array('id'=>'search-button', 'type'=>'image', 'src'=>'/img/search_btn.gif')); echo $this->Form->end(); ?> I am using cakePHP 2.0.3. Thank you! On Sun, May 20, 2012 at 11:22 AM, majna wrote: can you paste this code C:\wamp\www\test\app\View\Elements\menu.ctp(25) and cake version On Saturday, May 19, 2012 9:39:43 PM UTC+2, Florin Trifu wrote: Excuse me. I think I didn't understand what you wanted to say. You imply that the error is generated because the table test.cake_errors doesn't exists? I don't even think it should. I am not using it, and if you look carefully you will see that this is not a standard error for when a table is missing. On Sat, May 19, 2012 at 10:20 PM, Tilen Majerle wrote: Table 'test.cake_errors' doesn't exist -- Lep pozdrav, Tilen Majerle http://majerle.eu 2012/5/19 Florin Trifu Table 'test.cake_errors' doesn't exist -- 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 <mailto:cake-php%2bunsubscr...@googlegroups.com> For more options, visit this group at http://groups.google.com/group/cake-php -- Florin Trifu -- 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
RE: Table 'cakehr.cake_errors' doesn't exists
With this line of code I don't receive errors anymore, but that is not correct either, cause there should be an error. Thank you! From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of majna Sent: Sunday, May 20, 2012 2:28 PM To: cake-php@googlegroups.com Subject: Re: Table 'cakehr.cake_errors' doesn't exists Instead of: echo $this->Form->create(array('id'=>'search')); try: echo $this->Form->create(false, array('id'=>'search')); On Sunday, May 20, 2012 1:04:14 PM UTC+2, Florin Trifu wrote: Hi Majna The entire content of menu.ctp is this: Html->link('button1', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button2', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button3', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button4', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link( $this->Html->image('logout_btn.gif', array('alt'=>'logout', 'border'=>'0', 'id'=>'logout-btn')), array('controller'=>'users', 'action'=>'logout'), array('escape'=>FALSE)); ?> Form->create(array('id'=>'search')); echo $this->Form->input('search_criteria', array('label'=>false, 'id'=>'search-criteria')); echo $this->Form->submit('',array('id'=>'search-button', 'type'=>'image', 'src'=>'/img/search_btn.gif')); echo $this->Form->end(); ?> I am using cakePHP 2.0.3. Thank you! On Sun, May 20, 2012 at 11:22 AM, majna wrote: can you paste this code C:\wamp\www\test\app\View\Elements\menu.ctp(25) and cake version On Saturday, May 19, 2012 9:39:43 PM UTC+2, Florin Trifu wrote: Excuse me. I think I didn't understand what you wanted to say. You imply that the error is generated because the table test.cake_errors doesn't exists? I don't even think it should. I am not using it, and if you look carefully you will see that this is not a standard error for when a table is missing. On Sat, May 19, 2012 at 10:20 PM, Tilen Majerle wrote: Table 'test.cake_errors' doesn't exist -- Lep pozdrav, Tilen Majerle http://majerle.eu 2012/5/19 Florin Trifu Table 'test.cake_errors' doesn't exist -- 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 <mailto:cake-php%2bunsubscr...@googlegroups.com> For more options, visit this group at http://groups.google.com/group/cake-php -- Florin Trifu -- 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 <mailto:cake-php%2bunsubscr...@googlegroups.com> For more options, visit this group at http://groups.google.com/group/cake-php -- Florin Trifu Mobile: +40 728 300 750 -- 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 -- 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: Table 'cakehr.cake_errors' doesn't exists
Hi Majna The entire content of menu.ctp is this: Html->link('button1', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button2', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button3', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link('button4', array('controller'=>'companies', 'action'=>'index'), array('class'=>'menu-element-link'))?> Html->link( $this->Html->image('logout_btn.gif', array('alt'=>'logout', 'border'=>'0', 'id'=>'logout-btn')), array('controller'=>'users', 'action'=>'logout'), array('escape'=>FALSE)); ?> Form->create(array('id'=>'search')); echo $this->Form->input('search_criteria', array('label'=>false, 'id'=>'search-criteria')); echo $this->Form->submit('',array('id'=>'search-button', 'type'=>'image', 'src'=>'/img/search_btn.gif')); echo $this->Form->end(); ?> I am using cakePHP 2.0.3. Thank you! On Sun, May 20, 2012 at 11:22 AM, majna wrote: > can you paste this code C:\wamp\www\test\app\View\Elements\menu.ctp(25) > and cake version > > > On Saturday, May 19, 2012 9:39:43 PM UTC+2, Florin Trifu wrote: >> >> Excuse me. I think I didn't understand what you wanted to say. >> >> You imply that the error is generated because the table test.cake_errors >> doesn't exists? >> I don't even think it should. I am not using it, and if you look >> carefully you will see that this is not a standard error for when a table >> is missing. >> >> >> On Sat, May 19, 2012 at 10:20 PM, Tilen Majerle >> wrote: >> >>> Table 'test.cake_errors' doesn't exist >>> >>> -- >>> Lep pozdrav, Tilen Majerle >>> http://majerle.eu >>> >>> >>> >>> 2012/5/19 Florin Trifu >>> >>> > >>> >>>> Table 'test.cake_errors' doesn't exist >>> >>> >>> -- >>> 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+unsubscribe@**googlegroups.comFor >>> more options, visit this group at >>> http://groups.google.com/**group/cake-php<http://groups.google.com/group/cake-php> >>> >> >> >> >> -- >> Florin Trifu >> >> -- > 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 > -- Florin Trifu Mobile: +40 728 300 750 -- 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: Table 'cakehr.cake_errors' doesn't exists
Excuse me. I think I didn't understand what you wanted to say. You imply that the error is generated because the table test.cake_errors doesn't exists? I don't even think it should. I am not using it, and if you look carefully you will see that this is not a standard error for when a table is missing. On Sat, May 19, 2012 at 10:20 PM, Tilen Majerle wrote: > Table 'test.cake_errors' doesn't exist > > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/5/19 Florin Trifu > >> Table 'test.cake_errors' doesn't exist > > > -- > 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 > -- Florin Trifu -- 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: Table 'cakehr.cake_errors' doesn't exists
Hi I have sent this problem a while ago but no one replied. I'm sending it again since it's important for me and I don't know if it was just a stupid question or no one didn't knew what to answer. I will also add the entire error maybe it will be more intuitive: *Fatal Error* (256): [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.cake_errors' doesn't exist #0 C:\wamp\www\test\lib\Cake\Model\Datasource\DboSource.php(436): PDOStatement->execute(Array) #1 C:\wamp\www\test\lib\Cake\Model\Datasource\Database\Mysql.php(307): DboSource->_execute('SHOW FULL COLUM...') #2 C:\wamp\www\test\lib\Cake\Model\Model.php(1209): Mysql->describe(Object(AppModel)) #3 C:\wamp\www\test\lib\Cake\View\Helper\FormHelper.php(198): Model->schema() #4 C:\wamp\www\test\lib\Cake\View\Helper\FormHelper.php(450): FormHelper->_introspectModel('CakeError', 'fields') #5 C:\wamp\www\test\app\View\Elements\menu.ctp(25): FormHelper->create(Array) #6 C:\wamp\www\test\lib\Cake\View\View.php(598): include('C:\wamp\www\tes...') #7 C:\wamp\www\test\lib\Cake\View\View.php(320): View->_render('C:\wamp\www\tes...', Array) #8 C:\wamp\www\test\app\View\Layouts\default.ctp(72): View->element('menu') #9 C:\wamp\www\test\lib\Cake\View\View.php(598): include('C:\wamp\www\tes...') #10 C:\wamp\www\test\lib\Cake\View\View.php(414): View->_render('C:\wamp\www\tes...') #11 C:\wamp\www\test\lib\Cake\View\View.php(376): View->renderLayout('SQLSTATE[42...', 'default') #12 C:\wamp\www\test\lib\Cake\Controller\Controller.php(900): View->render('error500', NULL) #13 C:\wamp\www\test\lib\Cake\Error\ExceptionRenderer.php(280): Controller->render('error500') #14 C:\wamp\www\test\lib\Cake\Error\ExceptionRenderer.php(255): ExceptionRenderer->_outputMessageSafe('error500') #15 [internal function]: ExceptionRenderer->pdoError(Object(PDOException)) #16 C:\wamp\www\test\lib\Cake\Error\ExceptionRenderer.php(165): call_user_func_array(Array, Array) #17 C:\wamp\www\test\lib\Cake\Error\ErrorHandler.php(127): ExceptionRenderer->render() #18 [internal function]: ErrorHandler::handleException(Object(PDOException)) #19 {main} [*CORE\Cake\Error\ErrorHandler.php*, line *136*] Thank you in advance! On Sat, May 5, 2012 at 7:20 PM, Florin Trifu wrote: > Did anyone encountered this error: > > [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table > 'cakehr.cake_errors' doesn't exist > > ? > > I have no idea why this is happening. The problem is that I can't see the > errors because they are nested inside a div having the > id="search-form-container". > If I delete that id the error is printed but the entire page is > re-rendered. > > > Best regards! > -- Florin Trifu -- 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
Table 'cakehr.cake_errors' doesn't exists
Did anyone encountered this error: [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cakehr.cake_errors' doesn't exist ? I have no idea why this is happening. The problem is that I can't see the errors because they are nested inside a div having the id="search-form-container". If I delete that id the error is printed but the entire page is re-rendered. Best regards! -- 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: Using HABTM
Ok. Now I think I understand what you're trying to obtain. Please tell me again your problem. Best regards! On Thu, Feb 16, 2012 at 4:10 AM, Sean wrote: > Thanks for the reply, Florin. > > Auction hasMany AuctionImages is the way that it is currently set. The > problem is that it currently "uses up" any AuctionImage that is > associated with the Auction. Each image is associated with a > particular auction_id. > > What I'm looking for is a way to have a set of images that I then > associate with numerous auctions. That is multiple images with > multiple auctions (e.g. 6 images for a single item type and then > associate them with multiple auctions). > > In addition to the structure that I'm attempting in the Models, here > is the current structure of the database tables: > > auctions: > Column Type > 1 id int(11)(AUTO INCREMENT) > 2 title varchar(255) > 5 description text > 6 category_id int(11) > > 26 created datetime > 27 modifieddatetime > >Keyname Type Unique Column >PRIMARY BTREE Yes id >category_id BTREE No category_id > > auction_images: > 1 id int(8) UNSIGNED > AUTO_INCREMENT > 2 auction_id int(11) > 3 image varchar(255) > 4 order int(11) > 5 created datetime > 6 modifieddatetime > > Keyname Type Unique Column > PRIMARY BTREE Yes id > auction_id BTREE No auction_id > > > Join table - auctions_auction_images > 1 id int(11) AUTO_INCREMENT > 2 auction_id int(11) > 3 auction_image_id int(11) > 4 order int(1) > >Keyname TypeUniqueColumn >PRIMARY BTREE Yes id >auction_id BTREE No auction_id >auction_image_idBTREE Noauction_image_id > > I hope this help clear up what I am looking for. > > Thanks, > Sean > > On Feb 15, 5:33 pm, Florin Trifu > wrote: > > Hi > > > > I don't know if my understanding is correct, but Auction hasMany > > AuctionImages and not HABTM. > > You should try to change that hasAndBelongsTo from the Auction model, of > > which I've never heard by the way, into hasMany. > > > > As by the error following the pattern "model_name_X is not associated > with > > model_name_X" usually appears in this case: > > > > Let's take for example you Image model: > > > > - you use $actsAs = array('Containable') > > - then you pass an array following this pattern into a query > interrogating > > the Image model: > > > > array('contain' => array('Image' [,'model_name'])) > > > > Hope it's useful! > > > > Best regards! > > > > > > > > > > > > > > > > On Wed, Feb 15, 2012 at 10:40 PM, Sean wrote: > > > Hi all, > > > > > I am trying to do something that I think is pretty common. > > > > > I am working on an auction site and if I had say a auctions table and > > > a auction_images table. I want to be able to use multiple images with > > > multiple auctions. > > > > > In other words - auction1 be associated with auction_image 1, 2, 3 & > > > auction2 be associated with 1, 2, 3 > > > > > When I use a $belongsTo relationship from Users to Images it works > > > fine, but that limits things to haveing specific images directly > > > linked to image id's (effectively "using up" the associated images). > > > > > I thought that the HABTM direction was the way to go, but am having a > > > problem with it. But when I use HABTM, I get an error that the model > > > images is not associated with the model images. I believe that I have > > > followed the book.cakephp directions and Josh Benner's directions but > > > it's not working. > > > > > Here are the model's: > > > > > Auction Model: > > >class Auc
Re: Using HABTM
Hi I don't know if my understanding is correct, but Auction hasMany AuctionImages and not HABTM. You should try to change that hasAndBelongsTo from the Auction model, of which I've never heard by the way, into hasMany. As by the error following the pattern "model_name_X is not associated with model_name_X" usually appears in this case: Let's take for example you Image model: - you use $actsAs = array('Containable') - then you pass an array following this pattern into a query interrogating the Image model: array('contain' => array('Image' [,'model_name'])) Hope it's useful! Best regards! On Wed, Feb 15, 2012 at 10:40 PM, Sean wrote: > Hi all, > > I am trying to do something that I think is pretty common. > > I am working on an auction site and if I had say a auctions table and > a auction_images table. I want to be able to use multiple images with > multiple auctions. > > In other words - auction1 be associated with auction_image 1, 2, 3 & > auction2 be associated with 1, 2, 3 > > When I use a $belongsTo relationship from Users to Images it works > fine, but that limits things to haveing specific images directly > linked to image id's (effectively "using up" the associated images). > > I thought that the HABTM direction was the way to go, but am having a > problem with it. But when I use HABTM, I get an error that the model > images is not associated with the model images. I believe that I have > followed the book.cakephp directions and Josh Benner's directions but > it's not working. > > Here are the model's: > > Auction Model: >class Auction extends AppModel { > >var $name = 'Auction'; > >var $actsAs = array('Containable'); > >var $belongsTo = array( >'Category' => array( >'className' => 'Category', >'foreignKey' => 'category_id' >), >'Status' => array( >'className' => 'Status', >'foreignKey' => 'status_id' >), >'Winner' => array( >'className' => 'User', >'foreignKey' => 'winner_id' >) >); > >var $hasMany = array( >'Bidbutler' => array( >'className' => 'Bidbutler', >'foreignKey' => 'auction_id', >'limit' => 10, >'dependent' => true >), > >'Bid' => array( >'className' => 'Bid', >'foreignKey' => 'auction_id', >'order' => 'Bid.id DESC', >'limit' => 10, >'dependent' => true >), > >'Autobid' => array( >'className' => 'Autobid', >'foreignKey' => 'auction_id', >'limit' => 10, >'dependent' => true >) >); > >var $hasAndBelongsTo = array( >'AuctionImage' => >array( >'className' => > 'AuctionImage', >'joinTable' => > 'auctions_auction_images', >'foreignKey' => > 'auction_id', >'associationForeignKey' => > 'auction_image_id', >'unique'=> > false, >'limit' > => '6', >'order' > => array('order' => 'asc'), >), >); > > AuctionImages Model: > >class AuctionImage extends AppModel { > >var $name = 'AuctionImage'; > >var $hasAndBelongsToMany = array( >'Auction' => array( >'className' => 'Auction', >'joinTable' => > 'auctions_auction_images', >'foreignKey'=> > 'auction_image_id', >'associationForeignKey' => 'auction_id', >'unique' => false, >'limit'=> '6' > >) >); > > I'm not sure how the controller language is supposed to
Re: validates() in controller doesn't work
Hi What do you mean when you say it doesn't work? Do you have an error message? Best regards On Mon, Jan 23, 2012 at 8:26 AM, Ivo Wolgensinger wrote: > Dear all > > I have some difficulties to set up a proper validates()-function in > the Controller. Everything in the function works fine, exept the > validates() in the if construct. Here is my UserController, in which I > have to check an email entry with my EmailAddress-Model: > [code] > .. >function adduseremailsend () { // sends the email for validate the > new email. >if ($this->request->is('post')) { >$this->EmailAddress->set($this->data); // here > another model is > loaded (we are in the UserController) >if ($this->EmailAddress->validates()) { // here is > the validation, > but this don't work >$tomail = $this->data['User']['email']; >$email = new CakeEmail(); >$email->config('smtp'); // here, we call > the options in the file / > Config/email.php >$email->to($tomail); >$email->subject('Validate email'); >$email->emailFormat('both'); >$email->viewVars(array('token' => > md5($tomail.'someSalt'.AuthComponent::user('id')), 'tomail' => > $tomail, 'uid' => AuthComponent::user('id'))); >$email->template('adduseremail'); // we > call the template in app/ > View/Emails/text/ and/or app/View/Emails/html/ >if ($email->send()) { >$this->Session->setFlash('Email > with validation link sent to your > address.'); >} else { >$this->Session->setFlash('Email not > sent'); >} >} else { >$this->Session->setFlash('This was not an > emailaddress.'); >} >} >$this->redirect(array('controller' => 'users','action' => > 'profile')); >} > .. > [/code] > > And here is my EmailAddress Model: > [code] > > class EmailAddress extends AppModel { >public $name = 'EmailAddress'; > >public $validate = array( >'email' => array( >'email' => array( >'rule' => array('email', true), >'message' => 'Please make sure your email is > entered correctly.' >), >'unique' => array( >'rule' => 'isUnique', >'message' => 'An entry with that emailaddress > already exists.' >), >'required' => array( >'rule' => 'notEmpty', >'message' => 'Please enter your email.' >) >) >); > } > ?> > [/code] > As I know, the code in the EmailAddress Model works fine with other > projects. I think the error is in the UserController file. > Does anybody knows how to do that? As I said, everything works well > except the if-clause. And we are in the UserController and want to use > the EmailAddress Model. > > Thank you very much for any help. > > Ivo > > -- > 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 > -- 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: Problems with URL
Hi Thad I will answer to your question without knowing the error you receive, so it might not be the solution to your problem. The link you provided in your mail, shows that you don't use the correct name for your controller. You should name your controller with the plural of the world you use. In consequence, you should do the following changes: - rename the controller file to "PaymentsController.php" - rename the class defined in the controller to class PaymentsController As a good practice, please also send in the future the error you receive. Best regards On Wed, Jan 18, 2012 at 3:23 PM, Thad wrote: > Hey guys, > > i'm trying to workout in an app code here but i'm getting the message: > URL should be set in array format (i.e., array('controller' => > 'controller', 'action' => 'action') for other than "/". Fix your > helper usage. > > Everything seems to be ok and I don't know what to do anymore. The URL > is like: > > http://website.com/payment/express/160 where payment = controller, > express = action and 160 = params. > > Do you have any idea of what i can do? > > -- > 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 > -- 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: Lightbox form CakePHP 2.0
Thank you! On Thu, Dec 22, 2011 at 12:58 PM, stefanski wrote: > Hi Florin. > > I read through your question again. I would go for this: > - create a controller function that returns all countries as json > - when the lightbox is closed, call that controller function by ajax and > populate the country select values with the countries > > it's mostly javascript coding. > > > -- > 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 > -- Florin Trifu Mobile: +40 728 300 750 -- 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: Lightbox form CakePHP 2.0
Thank you Stefanski That's one of the things I don't know how to do it, but it's not the only one. I honestly don't know where to start, I have the code from the example Geoff gave me but I'm starring at it not knowing what to do with it. But probably Geoff is right and I need to see the documentation. I will reply again when I'll finish learning... probably one year or so... . Thank you one more time. On Mon, Dec 19, 2011 at 7:46 AM, stefanski wrote: > In case you wonder abput how to clse the lightbox, after the form is > processed successfully, this is how i implemented it: > > in any ajax-popup-controller controller action: > if ($form_processed_sucessfully) { > $this->render(null, 'ajax', '/ajax_refresh'); > } > > views/ajax_refresh.ctp: > type="text/javascript">document.location.replace(document.location.href); > > -- > 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 > -- 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: Lightbox form CakePHP 2.0
So... no one doesn't have any other tip? Nobody didn't use this kind of functionality? On Fri, Dec 16, 2011 at 8:54 PM, Geoff Douglas wrote: > Take a look at the http://jqueryui.com/demos/dialog/#modal-form > Modal Form demo. > > There is a function that fires when a user clicks the buttons. > > There is a function that fires when the modal is open, and closed. (And > many other "Events" you can tie functions to) > > A callback function is simply an event based function. So that when > something happens you can tie a function to that event. > > Study the demo. Try it out. If you have questions ask them. > > -- > 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 > -- 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: Lightbox form CakePHP 2.0
I know the example that you gave me even before I have sent the email on google groups. The reason I've asked is because I don't really know how to use it... I will try to put in place... On Fri, Dec 16, 2011 at 8:54 PM, Geoff Douglas wrote: > Take a look at the http://jqueryui.com/demos/dialog/#modal-form > Modal Form demo. > > There is a function that fires when a user clicks the buttons. > > There is a function that fires when the modal is open, and closed. (And > many other "Events" you can tie functions to) > > A callback function is simply an event based function. So that when > something happens you can tie a function to that event. > > Study the demo. Try it out. If you have questions ask them. > > -- > 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 > -- Florin Trifu Mobile: +40 728 300 750 -- 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: Lightbox form CakePHP 2.0
Thank you Geoff! Indeed, it's exactly what I want, but I hope it's also what I need. In case you've used this, could you please give a small example of how to implement it? One more thing, I don't understand exactly what a callback is and what exactly does it do. Could you please give a short practical description? Thank you in advance. Best regards! On Fri, Dec 16, 2011 at 7:21 PM, Geoff Douglas wrote: > I suggest jQuery UI dialog. If you need something out of the box, it will > work quite well for you. > It has callbacks that you can use to load/save stuff via ajax > > http://jqueryui.com/demos/dialog/ > > -- > 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 > -- 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
Lightbox form CakePHP 2.0
Hi all Environment example: - Countries controller --- add action --- add.ctp view - Cities controller --- add action --- add.ctp view Goal: - in cities controller, inside the add action, I want to put a link next to the select element containing all the countries from the database, that will open a lightbox type form that will load countries controller/add action with all its functionality. After I save the country, I want the lightbox to close and reload the page keeping the value for the city name (in case something was typed in) and I want the country just added to be selected. Limitations: - beginner with CakePHP, although I like it very much - left handed when working with javascript Other considerations: - any idea will be welcome and highly appreciated Thank you! Best regards! -- 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: Date picker for CakePHP 2.0.3
Thank you very much! Indeed it worked. Just to let the other users know in case they will have the same problem: 1. Download jquery (http://docs.jquery.com/Downloading_jQuery) and put the file in $project/app/webroot/js (e.q: *$project/app/webroot/js/jquery.js*) 2. Download jquery-ui (http://jqueryui.com/download); I, for example, downloaded a zip archive called: jquery-ui-1.8.16.custom.zip. From this archive you will have to copy the followings: a. *$archive_root/js/jquery-ui-*.js* in *$project/app/webroot/js* (give it a shorter name e.q: jquery-ui.js) b. *$archive_root/css/smothness/** to *$project/app/webroot/css* (including the images; rename the css file to something shorter) 3. Include both js files in your layout. eq: * //$project/app/views/Layouts/default.ctp - echo $this->Html->script(array('jquery', 'jquery-ui')); *4. Include the css file. Eq *//$project/app/views/Layouts/default.ctp - echo $this->Html->css('jquery-ui.css'); *5. Put this lines of code before calling the date-picker: * $(function() { $("#datepicker").datepicker(); }); * 6. Call the date picker in your form: *echo $this->Form->input('expire', array( 'id'=>'datepicker', 'type'=>'text' )* This is it! Best regards! -- 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: Date picker for CakePHP 2.0.3
I forgot to tell you but jquery is also included. In the javascript console there is no error because the date-picker is not triggered. Can you please tell me where should I put the script you told wrote me? This one: $(function() { $("#datepicker").datepicker(); }); 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: Date picker for CakePHP 2.0.3
I have tried this but it doesn't work for me. I have downloaded the jquery-ui, put the js inside /app/webroot/js, included inside my layout, and then create an input like this: $this->Form->input('expire', array('id'=>'datepicker')) Nothing happens when I click inside the text box... -- 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
Date picker for CakePHP 2.0.3
Hi I need to implement a date picker into my application. I have found this tutorial: http://bakery.cakephp.org/articles/agusti/2010/02/02/transparent-datepicker-with-jquery but unfortunately is not working with my version. Did someone succeeded to implement it or can someone guide me to another resource? Thank you! Best regards! -- 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