Re: serving javascript instead of html
Hi Rodrego, It doesn't look like you called render() in your controller action... B. On Oct 17, 1:05 pm, "Rodrigo Tassinari" <[EMAIL PROTECTED]> wrote: > You're right Chris, here's my code, hope you guys spot something I'm > doing wrong. > > This is the regular PHP file, which works fine: > > links.php > header("Content-type: application/x-javascript" ); > echo "document.write(\"\");\n"; > echo " document.write(\"\");\n"; > echo "document.write(\" href='http://br-linux.org/linux/usando-o-google-adsense-para-gerar-recursos...>Usando > o Google Adsense para gerar recursos para o seu projeto livre | > BR-Linux.org\");\n"; > echo "document.write(\"Mais em href='http://links.pittlandia.net'>links\");\n"; > echo " document.write(\"\");\n"; > echo "document.write(\"\");\n"; > ?> > > These are the files I use in my cake app, which is not working: > > badge.thtml (layout) > header("Content-type: text/javascript"); > echo $content_for_layout; > ?> > > recent.thtml (view) > echo "document.write(\"\");\n"; > echo " document.write(\"\");\n"; > foreach ($links as $link): > echo "document.write(\" title='".utf8_decode($link['Link']['description'])."' > href='".$link['Link']['url']."'>".utf8_decode($link['Link']['title'])."\");\n"; > endforeach; > echo "document.write(\"Mais em title='".$siteConfig['nome_sistema']."' > href='".$siteConfig['link_sistema']."'>".$siteConfig['nome_sistema']."\");\n"; > echo " document.write(\"\");\n"; > echo "document.write(\"\");\n"; > ?> > > links_controller.php (controller, only showing the recent action) > function recent($quant = 5) > { > $this->layout = 'badge'; > if (!empty($this->params['url']['q'])) > { > $quant = $this->params['url']['q']; > } > $links = $this->Link->getLinks($quant); > $this->set('links', $links); > > }And finally, this is the page that tests the inclusion of the outputed > code in both methods: > > links.html > > > Teste de Links via Javascritp > > > Testando... > http://links.pittlandia.net/links/recent?q=5"; > type="text/javascript"> > Testando de novo... > http://www.pittlandia.net/links.php"; > type="text/javascript"> > Acabou o teste > > > > You can try out for yourself by going to:http://www.pittlandia.net/links.html > > Thanks in advance, > Rodrigo. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Is Model::findCount supposed to work?!?!?!?!
Well - sounds like the CakePHP team has this under control. :) Where in the 1.2 branch can I see how you guys did this? B. On Oct 17, 12:10 pm, "nate" <[EMAIL PROTECTED]> wrote: > You *can* do pagination (almost) completely in the model, but when you > see how it is implemented in 1.2, you'll realize why that's an > astoundingly bad idea. Also, "decorating" data is a task reserved for > the View, and putting View logic in the Model violates the most basic > principles of MVC and is generally considered to be Pure Evil. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Is Model::findCount supposed to work?!?!?!?!
True, but I was just trying to do a findCount..., then modify the $limit and $page params and allow the findAll to proceed and return the bounded dataset. I've seen the component approach, but I'm just not conviced that there needs to be anything outside of the Model on this - if the Model (when told to do) simply serves the requested data back in a decorated way - it's seamless. Then a view helper can be passed the result and render the datagrid & paginate. I accomplished for Model::find already by doing the following: function query($sql){ if ($this->_datagrid){ $return_data = array(); // First Get Record count of unbounded query $query_info = parent::query('EXPLAIN ('.$sql.')'); $total_records = $query_info[0][0]['rows']; $return_data['pagination']['num_records'] = $total_records; $return_data['pagination']['num_pages'] = (int)floor($total_records / $this->num_rows); $return_data['pagination']['current_page'] = $this->current_page; // Now bound the query and get the dataset $record_offset = $this->findRecordOffset(); $sql .= ' LIMIT '.$record_offset.','.$this->num_rows; $return_data['rows'] = parent::query($sql); return $return_data; } else { return parent::query($sql); } } This can done for findAll as well if I could just get the unbounded count. I have a hacked version that grabs the whole dataset and returns only the rows for the given page - but NOT fetching the whole dataset is the reason for pagination in the first place :) If anyone has any thoughts hit me up - I'd love to get this posted to cakeforge! Best, B. On Oct 16, 11:59 am, "AD7six" <[EMAIL PROTECTED]> wrote: > If you call a method that triggers a find in your beforeFind method you > created a loop ;). > > If you goal is just pagination have you seen > this:http://bakery.cakephp.org/articles/view/65 > > Also, cake 1.2 will have native pagination support. > > HTH, > > AD7six --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Is Model::findCount supposed to work?!?!?!?!
Hi list, I'll just preface the issue I'm having with what I'm trying to do...I'm trying to extend Cake's AppModel to make it easier to return results suited for producing a DataGrid with pagination controls. The goal is to setup Models to be worked with in the controller like: $this->Model->dataGrid('true'); $data = $this->Model->findAll(..); $this->set('data', $data); The data that is returned back will look like this: Array ( 'num_pages' => 6 'rows' => Array( ) This leads to my problem which occurs in AppModel::beforeFind. To calculate num_pages, you have to know how many records are in your un-bounded dataset. So I try to do a $this->findCount() and the page goes blank. No error on the screen or in a log anywhere. Does anyone know how to return a row count from within a Model without pulling all the data? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---