Saturday, June 30, 2012

Re: Why using HTML->link instead of manually writing an anchor text ?

Hello,

1) I tend to have about 3 environments my app run on (local, dev and production). Local and dev usually run in a subfolder setup and production runs on a root domain. The reason I use the helpers for links and images is because this way I don't need to worry about the base url when linking and pointing to images. It's very easy and portable.
2) For images and links, I see at least one major advantage of using helpers : those will deal with absolute-URLs and http/https protocols (for href/src that point to your website), no matter where your application is deployed.

Tx
Chetan

On Sun, Jul 1, 2012 at 7:08 AM, Marcelo Custódio <marcelocustodio@gmail.com> wrote:
Isn't it much slower concerning development time ?

What are the advantages of of HTML->link ?

Thanks !

--
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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: $this->Post = ClassRegistry::init('Post');

Hello ,

Answer 1 ) Yes , The Post object is automatically created whithin the PostsController

Answer 2 ) http://chetan4cake.blogspot.in/2012/04/import-model-in-controller.html

Thanks
Chetan

On Sun, Jul 1, 2012 at 8:07 AM, Marcelo Custódio <marcelocustodio@gmail.com> wrote:
Suppose I have the classic Post model and I've created an Author model too.

I have some basic questions:

(1) The Post object is automatically created whithin the PostsController ?

(2) In order to create an instance of Post whithin AuthorsController, is the only way with

$this->Post = ClassRegistry::init('Post');

Please notice that by doing " $this->Post " I assume the Post variable will be created in this line. Am I right ?

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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Can someone (experienced) Migrate Cake PHP website from shared hosting to cloud hosting provider

Need to urgently transfer my website to clean Ubuntu Cloud system, Need to install Webim, LAMP, cake etc. Please quote me.
This job is urgent ... Thanks

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

$this->Post = ClassRegistry::init('Post');

Suppose I have the classic Post model and I've created an Author model too.

I have some basic questions:

(1) The Post object is automatically created whithin the PostsController ?

(2) In order to create an instance of Post whithin AuthorsController, is the only way with

$this->Post = ClassRegistry::init('Post');

Please notice that by doing " $this->Post " I assume the Post variable will be created in this line. Am I right ?

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Warning (2): Cannot modify header information - headers already sent by

Thanks man ... you saved me ... !!!

On Tuesday, October 4, 2011 6:27:46 AM UTC-3, BLABLABLA wrote:
HI..

The problem was the encoding. I have had the encoding UTF8, but needed the
encoding UTF8 without BOM.

--
View this message in context: http://cakephp.1045679.n5.nabble.com/Warning-2-Cannot-modify-header-information-headers-already-sent-by-tp4860658p4867920.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Why using HTML->link instead of manually writing an anchor text ?

Isn't it much slower concerning development time ?

What are the advantages of of HTML->link ?

Thanks !

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Query and exporting to csv

You might want to ignore some of my recommendations. It turns out that
using a UNION makes a mess of things in Cake. The reason is that PDO
won't return a table name/alias from getColumnMeta() because the
tables in the two selects might be (are likely to be) different. And
that's what Cake relies upon to create its arrays keyed on model
aliases.

I've just spent hours tracking this down because I was trying to use a
UNION also. If I come up with a solution (doubtful) I'll let you know.

On Sat, Jun 30, 2012 at 3:51 PM, lowpass <zijn.digital@gmail.com> wrote:
> First step, confirm that your data is what you expect:
>
> foreach($patient_list as $patient) {
>   die(debug($patient));
>
> if that doesn't work put die(debug($patient_list)) before the foreach.
>
> Second, but maybe unrelated, setting the viewVar $alldrugs will not
> survive a redirect. That is, it wouldn't be available once processing
> has gone on to the view for generatePatientInfo. So it's pointless to
> do the find before checking to see if you should redirect. And
> consider using setAction() instead.
>
> Third, you should put as much logic as you can in the model. Fat
> models/skinny controllers. Create methods in the model to pass the
> data back to the controller.
>
> Fourth, avoid Model::query. It has its uses but those should be rare.
> Instead, create model associations. You can always use the
> 'finderQuery' param in the association array. (Coincidentally, I just
> did the very same thing with a UNION.)
>
> And in doing so, you should emulate how Cake uses model aliases. It
> will make things a lot cleaner in the long run. That goes also for the
> table naming. Instead of drug_pregnancy_links use drugs_pregnancies.
>
> Also, your query might be better using Joins.
>
> For example, in this case you could create a PatientInfo model. In
> your *Drug* model:
>
> public $hasMany => array(
>        'PatientReport' => array(
>                'className' => 'PatientReport',
>                'foreignKey' => false,
>                'finderQuery' => '
> SELECT
>        Patient.id, Patient.first_name, Patient.last_name, Call.id, Call.created
> FROM
>        (patients AS Patient)
> LEFT JOIN
>        calls AS Call
> ON
>        Call.patient_id = Patient.id
> LEFT JOIN
>        lactations AS Lactation
> ON
>        Lactation.call_id = Call.id
> LEFT JOIN
>        drugs_lactations AS DrugLactation
> ON
>        DrugLactation.lactation_id = Lactation.id
> LEFT JOIN
>        drugs AS Drug
> ON
>        DrugLactation.drug_id = Drug.id
> WHERE
>        Drug.id = {$__cakeID__$}
> UNION
> SELECT
>        Patient.id, Patient.first_name, Patient.last_name, Call.id, Call.created
> FROM
>        (patients AS Patient)
> LEFT JOIN
>        calls AS Call
> ON
>        Call.patient_id = Patient.id
> LEFT JOIN
>        pregnancies AS Pregnancy
> ON
>        Pregnancy.call_id = Call.id
> LEFT JOIN
>        drugs_pregnancies AS DrugPregnancy
> ON
>        DrugPregnancy.pregnancy_id = Pregnancy.id
> LEFT JOIN
>        drugs AS Drug
> ON
>        DrugPregnancy.drug_id = Drug.id
> WHERE
>        Drug.id = {$__cakeID__$}'
>        )
> );
>
> If you can't rename the join tables, switch drugs_pregnancies &
> drugs_lactations to your own names.
>
> controller:
>
> public function generateReport($id = null)
> {
>        if (!empty($id))
>        {
>                $this->layout = 'ajax';
>
>                // remove these 2 lines once you know it's working
>                Configure::write('debug', 2);
>                die(debug($this->Drug->fetchPatientReport($id)));
>
>                $this->set(
>                        'data',
>                        $this->Drug->fetchPatientReport($id)
>                );
>        }
> }
>
> Drug.php:
>
> public function fetchPatientReport($id)
> {
>        return $this->find(
>                'first',
>                array(
>                        'fields' => array(
>                                $this->alias.'.id',
>                                $this->alias.'.generic'
>                        ),
>                        'conditions' => array(
>                                $this->alias.'.id' => $id
>                        ),
>                        'contain' => array(
>                                'PatientReport'
>                        )
>                )
>        );
> }
>
> On Fri, Jun 29, 2012 at 10:48 AM, Shosho <shinsuio0012@gmail.com> wrote:
>> I'm trying to export certain information to a CSV file. I have a drop down
>> list to select the drug you want to generate the information for and it
>> sends the id to the function to generate the csv(That is sending the correct
>> ID selected). The query runs and gets the information I want, I use it in
>> another view, but i'm having issues getting the data to get put into the
>> csv. I'm not sure what else to try. It doesn't put anything into the csv
>> despite accessing it the same way I do in the view. Any help is appreciated.
>>
>> Functions:
>>  function report(){
>>    $this->set('alldrugs', $this->Drug->find('list', array(
>>      'cache' => 'drugList',
>>      'cacheConfig' => 'sql',
>>      'fields' => array('id', 'generic'),
>>      'order' => 'Drug.generic',
>>      'recursive' => -1,
>>    )));
>>    if (!empty($this->data['DrugCalls'])) {
>>
>> $this->redirect(array('controller'=>'drugs','action'=>'generatePatientInfo',$this->data['DrugCalls']['DrugList']['id']));
>>      }
>>  }
>>  function generatePatientInfo($id=null) {
>>    $this->layout = 'ajax';
>>    // get drug info
>>    $drug = $this->Drug->read(
>>      array(
>>        'Drug.id', 'Drug.generic'
>>      ),
>>      $id
>>    );
>>    $this->set('drug',$drug);
>>    $patients = $this->Drug->query('SELECT patients.id, calls.id call_id,
>> patients.first_name, patients.last_name, calls.created '
>>      . 'FROM drugs, drug_lactation_links, lactation, calls, patients '
>>      . 'WHERE drugs.id = ' . $id . ' AND drugs.id =
>> drug_lactation_links.drug_id AND '
>>      . 'drug_lactation_links.lactation_id = lactation.id AND
>> lactation.call_id = calls.id AND calls.patient_id = patients.id '
>>      . 'UNION '
>>      . 'SELECT patients.id, calls.id call_id, patients.first_name,
>> patients.last_name, calls.created '
>>      . 'FROM drugs, drug_pregnancy_links, pregnancies, calls, patients '
>>      . 'WHERE drugs.id = ' . $id . ' AND drugs.id =
>> drug_pregnancy_links.drug_id AND '
>>      . 'drug_pregnancy_links.pregnancy_id = pregnancies.id AND
>> pregnancies.call_id = calls.id AND calls.patient_id = patients.id '
>>      . 'ORDER BY created DESC'
>>    );
>>    $this->set(compact('patients'));
>>  }
>>
>>
>> View:
>> <?php
>> // add the header row
>> $header = array('First Name','Last Name');
>>
>> $csv->addRow(array('Enter Generic: ' . $drug['Drug']['generic']));
>> $csv->addRow($header);
>>
>> // add all the data
>> foreach($patient_list as $patient) {
>>  $csv->addRow(array(
>>    $patient[0]['first_name'],
>>    $patient[0]['last_name'],
>>  ));
>> }
>> $csv->addRow(array());
>>
>> // render the CSV file
>> echo $csv->render('Patients-list.csv');
>> ?>
>>
>>
>> --
>> View this message in context: http://cakephp.1045679.n5.nabble.com/Query-and-exporting-to-csv-tp5709159.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> --
>> 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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

mod_rewrite

I have my main site in the app folder / directory

Now I want to create a dev folder where I can work on a new site but going to site.com/dev results in Error: The requested address '/dev' was not found on this server.

How can i set the htaccess to ignore the dev folder?

Thanks

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: find() not respecting belongsTo association

'foreignKey' => 'user_id'

The broadcasters table should have a user_id column that is the
foreign key pointing to users.id. Don't point broadcasters.id to
users.id. (This isn't just a Cake rule but SQL in general.)

Having said that, I wonder if belongsTo is the association to use
here. Wouldn't HABTM be more appropriate?

On Sat, Jun 30, 2012 at 8:20 AM, kleelof <kleelof@yahoo.com> wrote:
> I am having a problem getting a model->find() call to respect a belongsTo
> association I built.
>
> Here is the association:
>
> var $belongsTo = array('User' => array('className'  =>'User',
>                                        'foreignKey' => 'id',
>                                    'fields'     => array('username')
>                                        )
>                       );
>
> And here is the find call:
>
> $this->set('broadcasters_list', $this->Broadcaster->find('all',
>
>  array('fields'=>array('id')
>                                                          )));
>
> Now for a very odd thing; I have a pagination call on the Broadcaster model
> that, when called, respects the belongsTo association and returns the
> necessary information from the User model.
>
> take care, lee
>
> Edit:
>
> I took a look at the query being built, here is what I have:
>
> For the find command:
>
> SELECT `Broadcaster`.`id` FROM `broadcasters` AS `Broadcaster` LEFT JOIN
> `users` AS `User` ON (`Broadcaster`.`id` = `User`.`id`) LEFT JOIN `images`
> AS `profile_image` ON (`profile_image`.`user_id` = `Broadcaster`.`id` AND
> image_type = 3) WHERE 1 = 1
>
> For the pagination call:
>
> SELECT `Broadcaster`.`id`, `Broadcaster`.`key_id`,
> `Broadcaster`.`session_id`, `Broadcaster`.`broadcast_mode`,
> `Broadcaster`.`next_guest_id`, `Broadcaster`.`one_to_one_credits`,
> `Broadcaster`.`one_to_many_credits`, `Broadcaster`.`avilable_for_private`,
> `Broadcaster`.`connect_type`, `Broadcaster`.`commission`,
> `Broadcaster`.`credits`, `Broadcaster`.`enabled`, `User`.`username`,
> `profile_image`.`file_id` FROM `broadcasters` AS `Broadcaster` LEFT JOIN
> `users` AS `User` ON (`Broadcaster`.`id` = `User`.`id`) LEFT JOIN `images`
> AS `profile_image` ON (`profile_image`.`user_id` = `Broadcaster`.`id` AND
> image_type = 3) WHERE `enabled` = 1 LIMIT 10
>
> With the exception of the fields being retrieved, it all looks the same. Am
> I missing something in there?
>
> --
> 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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Redirect to Different Action in If Statement

You could also use setAction() to avoid forcing the browser to make
another request.

http://api20.cakephp.org/class/controller#method-ControllersetAction

On Fri, Jun 29, 2012 at 11:08 PM, kwixson <kevinwixson@gmail.com> wrote:
> Thank you very much! I'll give that a try.
>
> Cheers,
> -Kevin
>
> On Thursday, June 28, 2012 7:45:08 AM UTC-4, MaJerle.Eu wrote:
>>
>> in your controller
>>
>> $this->redirect(array('action' => 'view'));
>> --
>> Lep pozdrav, Tilen Majerle
>> http://majerle.eu
>>
>>
>>
>> 2012/6/28 kwixson
>>>
>>> How do I redirect a user from the index action to the view action if the
>>> user has a particular role (i.e., member, as opposed to admin?
>>>
>>> Note: I do NOT want to hear about routes. That might be the right way to
>>> go generally, but in this case it's not. I just want to know how to do an IF
>>> statement in the index action that will redirect the user to the view
>>> action.
>>>
>>> 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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Query and exporting to csv

First step, confirm that your data is what you expect:

foreach($patient_list as $patient) {
die(debug($patient));

if that doesn't work put die(debug($patient_list)) before the foreach.

Second, but maybe unrelated, setting the viewVar $alldrugs will not
survive a redirect. That is, it wouldn't be available once processing
has gone on to the view for generatePatientInfo. So it's pointless to
do the find before checking to see if you should redirect. And
consider using setAction() instead.

Third, you should put as much logic as you can in the model. Fat
models/skinny controllers. Create methods in the model to pass the
data back to the controller.

Fourth, avoid Model::query. It has its uses but those should be rare.
Instead, create model associations. You can always use the
'finderQuery' param in the association array. (Coincidentally, I just
did the very same thing with a UNION.)

And in doing so, you should emulate how Cake uses model aliases. It
will make things a lot cleaner in the long run. That goes also for the
table naming. Instead of drug_pregnancy_links use drugs_pregnancies.

Also, your query might be better using Joins.

For example, in this case you could create a PatientInfo model. In
your *Drug* model:

public $hasMany => array(
'PatientReport' => array(
'className' => 'PatientReport',
'foreignKey' => false,
'finderQuery' => '
SELECT
Patient.id, Patient.first_name, Patient.last_name, Call.id, Call.created
FROM
(patients AS Patient)
LEFT JOIN
calls AS Call
ON
Call.patient_id = Patient.id
LEFT JOIN
lactations AS Lactation
ON
Lactation.call_id = Call.id
LEFT JOIN
drugs_lactations AS DrugLactation
ON
DrugLactation.lactation_id = Lactation.id
LEFT JOIN
drugs AS Drug
ON
DrugLactation.drug_id = Drug.id
WHERE
Drug.id = {$__cakeID__$}
UNION
SELECT
Patient.id, Patient.first_name, Patient.last_name, Call.id, Call.created
FROM
(patients AS Patient)
LEFT JOIN
calls AS Call
ON
Call.patient_id = Patient.id
LEFT JOIN
pregnancies AS Pregnancy
ON
Pregnancy.call_id = Call.id
LEFT JOIN
drugs_pregnancies AS DrugPregnancy
ON
DrugPregnancy.pregnancy_id = Pregnancy.id
LEFT JOIN
drugs AS Drug
ON
DrugPregnancy.drug_id = Drug.id
WHERE
Drug.id = {$__cakeID__$}'
)
);

If you can't rename the join tables, switch drugs_pregnancies &
drugs_lactations to your own names.

controller:

public function generateReport($id = null)
{
if (!empty($id))
{
$this->layout = 'ajax';

// remove these 2 lines once you know it's working
Configure::write('debug', 2);
die(debug($this->Drug->fetchPatientReport($id)));

$this->set(
'data',
$this->Drug->fetchPatientReport($id)
);
}
}

Drug.php:

public function fetchPatientReport($id)
{
return $this->find(
'first',
array(
'fields' => array(
$this->alias.'.id',
$this->alias.'.generic'
),
'conditions' => array(
$this->alias.'.id' => $id
),
'contain' => array(
'PatientReport'
)
)
);
}

On Fri, Jun 29, 2012 at 10:48 AM, Shosho <shinsuio0012@gmail.com> wrote:
> I'm trying to export certain information to a CSV file. I have a drop down
> list to select the drug you want to generate the information for and it
> sends the id to the function to generate the csv(That is sending the correct
> ID selected). The query runs and gets the information I want, I use it in
> another view, but i'm having issues getting the data to get put into the
> csv. I'm not sure what else to try. It doesn't put anything into the csv
> despite accessing it the same way I do in the view. Any help is appreciated.
>
> Functions:
>  function report(){
>    $this->set('alldrugs', $this->Drug->find('list', array(
>      'cache' => 'drugList',
>      'cacheConfig' => 'sql',
>      'fields' => array('id', 'generic'),
>      'order' => 'Drug.generic',
>      'recursive' => -1,
>    )));
>    if (!empty($this->data['DrugCalls'])) {
>
> $this->redirect(array('controller'=>'drugs','action'=>'generatePatientInfo',$this->data['DrugCalls']['DrugList']['id']));
>      }
>  }
>  function generatePatientInfo($id=null) {
>    $this->layout = 'ajax';
>    // get drug info
>    $drug = $this->Drug->read(
>      array(
>        'Drug.id', 'Drug.generic'
>      ),
>      $id
>    );
>    $this->set('drug',$drug);
>    $patients = $this->Drug->query('SELECT patients.id, calls.id call_id,
> patients.first_name, patients.last_name, calls.created '
>      . 'FROM drugs, drug_lactation_links, lactation, calls, patients '
>      . 'WHERE drugs.id = ' . $id . ' AND drugs.id =
> drug_lactation_links.drug_id AND '
>      . 'drug_lactation_links.lactation_id = lactation.id AND
> lactation.call_id = calls.id AND calls.patient_id = patients.id '
>      . 'UNION '
>      . 'SELECT patients.id, calls.id call_id, patients.first_name,
> patients.last_name, calls.created '
>      . 'FROM drugs, drug_pregnancy_links, pregnancies, calls, patients '
>      . 'WHERE drugs.id = ' . $id . ' AND drugs.id =
> drug_pregnancy_links.drug_id AND '
>      . 'drug_pregnancy_links.pregnancy_id = pregnancies.id AND
> pregnancies.call_id = calls.id AND calls.patient_id = patients.id '
>      . 'ORDER BY created DESC'
>    );
>    $this->set(compact('patients'));
>  }
>
>
> View:
> <?php
> // add the header row
> $header = array('First Name','Last Name');
>
> $csv->addRow(array('Enter Generic: ' . $drug['Drug']['generic']));
> $csv->addRow($header);
>
> // add all the data
> foreach($patient_list as $patient) {
>  $csv->addRow(array(
>    $patient[0]['first_name'],
>    $patient[0]['last_name'],
>  ));
> }
> $csv->addRow(array());
>
> // render the CSV file
> echo $csv->render('Patients-list.csv');
> ?>
>
>
> --
> View this message in context: http://cakephp.1045679.n5.nabble.com/Query-and-exporting-to-csv-tp5709159.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> 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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Completely blank screen after form submission

Unrelated, but I noticed your FrenchTranslation class. I would advise
you to go about this differently. Even if you don't plan to add other
languages, this is not a good approach.

On Fri, Jun 29, 2012 at 3:29 PM, Shosho <shinsuio0012@gmail.com> wrote:
> In my app, for certain records, after save is clicked, it shows a completely
> blank page. The url is pointing at my add view with no id passed. The number
> it does this on is a small percentage of them. It works fine and exactly as
> I expect it too on all the rest. I have no more ideas as to what it could
> be. My add function is below. It's really weird that it would work just fine
> on 95% of them but not the rest. Maybe it's something in the data coming in?
> But i'm also using the security component, could be that?
>
> function add($id = null) {
>  $drug = $this->FrenchTranslation->Drug->read(
>    array(
>
> 'Drug.id','Drug.generic','Drug.ahl','Drug.aap','Drug.rid','Drug.oral','Drug.mw','Drug.clinical_recommendations','Drug.category','Drug.lrc','Drug.lrc2','Drug.lrc3','Drug.vd','Drug.rid_range_rounded','Drug.adultdose'
>    ),
>    $id
>  );
>  //$this->set('drug',$drug);
>  $this->set(compact('drug'));
>
>  if (!empty($this->data)) {
>                $this->FrenchTranslation->create();
>                if ($this->FrenchTranslation->save($this->data)) {
>      if(isset($this->params['form']['Next']) &&
> $this->params['form']['Next']  == 'Next'){
>        $this->next($id, $this->data['FrenchTranslation']['generic']);
>      }
>      if(isset($this->params['form']['Previous']) &&
> $this->params['form']['Previous'] == 'Previous'){
>        $this->previous($id, $this->data['FrenchTranslation']['generic']);
>      }
>      if(!isset($this->params['form']['Previous']) &&
> !isset($this->params['form']['Next'])){
>        $this->Session->setFlash(__('The french translation has been saved',
> true));
>                    //$this->redirect(array('action' =>
> 'edit',$this->data['FrenchTranslation']['id']));
>                    $this->redirect(array('action' => 'edit',$id));
>      }
>                } else {
>                        $this->Session->setFlash(__('The french translation could not be saved.
> Please, try again.', true));
>                }
>        }
>        $drugs = $this->FrenchTranslation->Drug->find('list');
>        $this->set(compact('drugs'));
> }
>
> --
> View this message in context: http://cakephp.1045679.n5.nabble.com/Completely-blank-screen-after-form-submission-tp5709166.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> 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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Completely blank screen after form submission

A blank screen suggests a fatal php error. Check your server's (not
Cake's) log. If you cannot access the log, try adding these to
bootstrap:

error_reporting(E_ALL);
ini_set('display_errors', 1);

Remember to remove them once you've found the trouble.

On Fri, Jun 29, 2012 at 3:29 PM, Shosho <shinsuio0012@gmail.com> wrote:
> In my app, for certain records, after save is clicked, it shows a completely
> blank page. The url is pointing at my add view with no id passed. The number
> it does this on is a small percentage of them. It works fine and exactly as
> I expect it too on all the rest. I have no more ideas as to what it could
> be. My add function is below. It's really weird that it would work just fine
> on 95% of them but not the rest. Maybe it's something in the data coming in?
> But i'm also using the security component, could be that?
>
> function add($id = null) {
>  $drug = $this->FrenchTranslation->Drug->read(
>    array(
>
> 'Drug.id','Drug.generic','Drug.ahl','Drug.aap','Drug.rid','Drug.oral','Drug.mw','Drug.clinical_recommendations','Drug.category','Drug.lrc','Drug.lrc2','Drug.lrc3','Drug.vd','Drug.rid_range_rounded','Drug.adultdose'
>    ),
>    $id
>  );
>  //$this->set('drug',$drug);
>  $this->set(compact('drug'));
>
>  if (!empty($this->data)) {
>                $this->FrenchTranslation->create();
>                if ($this->FrenchTranslation->save($this->data)) {
>      if(isset($this->params['form']['Next']) &&
> $this->params['form']['Next']  == 'Next'){
>        $this->next($id, $this->data['FrenchTranslation']['generic']);
>      }
>      if(isset($this->params['form']['Previous']) &&
> $this->params['form']['Previous'] == 'Previous'){
>        $this->previous($id, $this->data['FrenchTranslation']['generic']);
>      }
>      if(!isset($this->params['form']['Previous']) &&
> !isset($this->params['form']['Next'])){
>        $this->Session->setFlash(__('The french translation has been saved',
> true));
>                    //$this->redirect(array('action' =>
> 'edit',$this->data['FrenchTranslation']['id']));
>                    $this->redirect(array('action' => 'edit',$id));
>      }
>                } else {
>                        $this->Session->setFlash(__('The french translation could not be saved.
> Please, try again.', true));
>                }
>        }
>        $drugs = $this->FrenchTranslation->Drug->find('list');
>        $this->set(compact('drugs'));
> }
>
> --
> View this message in context: http://cakephp.1045679.n5.nabble.com/Completely-blank-screen-after-form-submission-tp5709166.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> 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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Slightly different models, merge or separate?

I'm not 100% sure I understand the situation, but it sounds to me like you're on the way to re-inventing the Entity Attribute Value DB pattern, which is wikipedia and there's a CakePHP example here  http://bakery.cakephp.org/articles/abalonepaul/2011/10/11/eav_behavior 

As you realized, implementing your own dynamic data descriptions comes with various complications and overheads.

Also, you might want to look into the Single Table Inheritance pattern, STI, also on Wikipedia - basically you have multiple models working from the same table, and you can  tweak their callbacks to give different behavior - see  http://bakery.cakephp.org/articles/santino83/2011/02/19/behavior_for_model_inheritance_the_missing_feature 

Hopefully these  ideas will give you some inspiration on the best way forward!


On Monday, 25 June 2012 09:12:43 UTC+1, Poyan Nabati wrote:

I have a question regarding more the design of the back-end rather than specifically how to implement it. 

I'm creating a life tracker of sorts. The purpose is to have a single application to help you keep track of things that are important to you long term.

I want to be able to track a wide array of different things.

For instance;

  • What type of exercise did I do? (Fixed: Gym, Running or Other)
  • Did I meditate today? (Boolean measurement)
  • What was my weight today? (Numeric measurement)
  • What's one good thing about today? (String "measurement")

So for each goal you have a single specific type of measurements.

How should I implement this on the backend?

  • Two models. I thought of having two models, Goal and Measurement, where Measurement has a corresponding field in the database called "value" that's agnostic of it's contents (in other words, a VARCHAR that I interpret differently depending on context). I believe, however, that this approach will create a lot of special code for each of the different cases down the line. 
  • Many models. Another way to do it would be to create NumericMeasurement, BooleanMeasurement etc etc for each of the different measurement-types. In Goal I could have a field that indicates the type and create the association Goal hasMany (each of the measurement types). Do you see any problems with this approach?

Is there another, better approach that I haven't thought about?

How would you solve this?

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Undefined index after web host install.

Right I've done the info.php and file uploads are turned on and you are absolutely right, there is a max file size of 2mb for an upload. 
Thanks for helping me figure that one out :)
Much appreciated.

On Thursday, 28 June 2012 22:34:09 UTC+1, Guti Grewal wrote:
Hi I've uploaded my website on a free hosting site called 000webhost, it works fine on localhost but however when I try to upload a file to the server using a form I get thrown this error.

Notice (8): Undefined index:  Upload [APP/Controller/UploadsController.php, line 32]
Code
UploadsController::add() - APP/Controller/UploadsController.php, line 32  ReflectionMethod::invokeArgs() - [internal], line ??  Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 485  Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 103  Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 85  [main] - APP/webroot/index.php, line 96

I can't for the life of me figure out what is going wrong?
I've set the permissions for the webroot/files/uploads folder to 777, so it can't possibly be that. 
Anyone have any ideas?

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

need a sample database

i want a sample database  like sakila or northwind with cakephp conventions
is there is any  ?
thanks 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

find() not respecting belongsTo association

I am having a problem getting a model->find() call to respect a belongsTo association I built.

Here is the association:

var $belongsTo = array('User' => array('className'  =>'User',
                                       
'foreignKey' => 'id',
                                   
'fields'     => array('username')
                                       
)
                     
);

And here is the find call:

$this->set('broadcasters_list', $this->Broadcaster->find('all',  
                                                         array
('fields'=>array('id')
                                                         
)));

Now for a very odd thing; I have a pagination call on the Broadcaster model that, when called, respects the belongsTo association and returns the necessary information from the User model.

take care, lee

Edit:

I took a look at the query being built, here is what I have:

For the find command:

SELECT `Broadcaster`.`id` FROM `broadcasters` AS `Broadcaster` LEFT JOIN `users` AS `User` ON (`Broadcaster`.`id` = `User`.`id`) LEFT JOIN `images` AS `profile_image` ON (`profile_image`.`user_id` = `Broadcaster`.`id` AND image_type = 3) WHERE 1 = 1 

For the pagination call:

SELECT `Broadcaster`.`id`, `Broadcaster`.`key_id`, `Broadcaster`.`session_id`, `Broadcaster`.`broadcast_mode`, `Broadcaster`.`next_guest_id`, `Broadcaster`.`one_to_one_credits`, `Broadcaster`.`one_to_many_credits`, `Broadcaster`.`avilable_for_private`, `Broadcaster`.`connect_type`, `Broadcaster`.`commission`, `Broadcaster`.`credits`, `Broadcaster`.`enabled`, `User`.`username`, `profile_image`.`file_id` FROM `broadcasters` AS `Broadcaster` LEFT JOIN `users` AS `User` ON (`Broadcaster`.`id` = `User`.`id`) LEFT JOIN `images` AS `profile_image` ON (`profile_image`.`user_id` = `Broadcaster`.`id` AND image_type = 3) WHERE `enabled` = 1 LIMIT 10

With the exception of the fields being retrieved, it all looks the same. Am I missing something in there?

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Help Upload plugin: validation rules

Hi all,
is anybody using Jose Gonzalez's upload plugin [1]? I have a couple
of open issues regarding its integration inside my web app, but before
filing a bug I wanted to be sure I was doing things the right way.

I attached a couple of validation rules to my Model's attachment
property and they seem to work only while adding a new object to the
database. If I edit an object, all the rules are processed but they
always return true.

public $actsAs = array(
'Upload.Upload' => array(
'attachment' => array(
'mimetypes' => array(
'application/pdf',
)
)
),
);

public $validate = array(
'attachment' => array(
'valid' => array(
'rule' => array('isValidMimeType', array(), false),
'message' => 'File is of an invalid mimetype',
),
),
);

I had a look at the rule code, and on edit operations the function
always exits at its first check:

public function isValidMimeType(&$model, $check, $mimetypes =
array(), $requireUpload = true) {
$field = array_pop(array_keys($check));

if (!empty($check[$field]['remove'])) {
return true;
}

Have you got any idea about this behaviour? $check[$field]['remove']
in my case gets always initialized to 'M'. If I comment out the first
check, then the function will always return false (it looks up the
attachment type using $check[$field]['type'] which is still equal to
'M'). It is really strange both lookups return the same string value.


Thanks,
Matteo

[1] https://github.com/josegonzalez/upload

--
http://www.matteolandi.net/

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Friday, June 29, 2012

Re: looking for competant cake php program to to some programming

Hello sir,

I have vast experience in cakephp

Read my blog :
http://chetan4cake.blogspot.in/

Thanks
Chetan



On Fri, Jun 29, 2012 at 4:33 PM, DiabloGeto <abhijatyatewari@gmail.com> wrote:


you need to tell , some details about the project ,or should precisely know which portion of the project is incomplete.

--
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.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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: One model, multiple pagination in a single view with conditions?

Gah that'd be right. First time jumping into CakePHP, the project I'm working on needs pagination of HABTM model (which was difficult), and multiple pagination of one model on the same view (which is impossible). I could have sorted these problems in no time with pure PHP.

Oh well, I ended up going with a simple iframe to have multiple pagination on the same page. A cheap hack, but it works.

Cheers

On Thursday, June 28, 2012 4:00:59 AM UTC+10, Mark Wratten wrote:
You can only paginate one way at a time, so presumably you can set the associations dynamically depending on the parameters from jQuery. Though separate models might be cleaner as you can hard-code the associations.

Mark

On Monday, June 25, 2012 11:41:16 PM UTC-4, 42startups wrote:
As the title suggests, is there a simple way to do this?

Or should I create a separate model?

Here's the code:

$this->paginate = array('limit'=>30);
$this->Hashtag->Pin->bindModel(array('hasOne' => array('HashtagsPin')), false);
$this->set('hashtag', $this->paginate('Pin', array('HashtagsPin.hashtag_id' => $id)));
$this->set('thought', $this->paginate('Pin', array('HashtagsPin.hashtag_id' => $id,'Pin.url'=>null)));

So I need to paginate 'hashtag' and 'thought' separately. I'll be attaching infinite scroll jquery to both.

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Is there a lighter weight alternative to requestAction?


However, suppose the content editors want to write an article about farmers markets and they want to display a list of farmers markets in the local area, we can tell them to embed something like {/organizations/list/tag:farmers-markets/radius:10/count:5} in the content. Or somewhere else they want a list of music events, then we would tell them to embed {/events/list/tag:music/radius:75/count:10}. So by passing that URL to requestAction, it will call the appropriate controller and action and return the rendered content. It keeps the code simple and modular, in the spirit of MVC.

What I am suggesting is slightly different... instead of having one requestAction for each of the modules you need included, I suggest to have only one requestAction for all the modules on the page. This would cut the overhead of rebuilding the Cake API for every module on the page.

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

REST APIs routing issue

My "Notes" controller looks like this-  http://pastebin.com/ReppRt4t

And routes.php as- 

CakePlugin::routes();
Router::parseExtensions('json');
Router::mapResources('notes');
Router::parseExtensions();
require CAKE . 'Config' . DS . 'routes.php';

When I make GET call to http://hostname/notes.json I am able to see results as expected. Sample result- http://pastebin.com/pYY3H2Ja

But when I make GET call as http:// hostname /notes/1234.json I get error-
 {"code":"404","url":"\/notes\/1234.json","name":"Action NotesController:: 1234() could not be found."}

Why is that index function is working as expected but not view function? I suspect something is wrong with routing. What could be wrong?

Thanks,
GK





--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Redirect to Different Action in If Statement

Thank you very much! I'll give that a try.

Cheers,
-Kevin

On Thursday, June 28, 2012 7:45:08 AM UTC-4, MaJerle.Eu wrote:
in your controller

$this->redirect(array('action' => 'view'));
--
Lep pozdrav, Tilen Majerle



2012/6/28 kwixson

How do I redirect a user from the index action to the view action if the user has a particular role (i.e., member, as opposed to admin?

Note: I do NOT want to hear about routes. That might be the right way to go generally, but in this case it's not. I just want to know how to do an IF statement in the index action that will redirect the user to the view action. 

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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Undefined index after web host install.

On Fri, Jun 29, 2012 at 3:01 PM, Guti Grewal <gutigrewal@googlemail.com> wrote:
> Notice (8): Undefined index: Upload [APP/Controller/UploadsController.php,
> line 32]
>
> /app/Controller/UploadsController.php (line 32)
>
> null
>
>
> This is what I get, when I do the debug, so Im guessing theres no errors
> with the coding. Where else could the error be.

Well, no, it doesn't mean there are no errors. It means that
$this->request->data is empty. Which is not what you want. Where did
you put this line? Normally, it would be something like:

public function add()
{
if (!empty($this->request->data))
{
// do save here
debug($this->request->data);


Which version are you running, btw? If less than 2.x you need to
debug($this->data) instead.

It's odd that both the notice and the debug are on line 32. What does
your controller action look like?

> It works fine in localhost but once I uploaded it to the online web host I
> get thrown this error.

Then maybe the problem is that you're trying to upload a file that's
too large. Or you may not even be able to upload at all. Add this in
your controller:

debug($_FILES);

If there's an upload error it'll be included there and you can compare
with the examples on the PHP site.

Also, you could check the server's config. Write a script, info.php,
and stick it in your webroot dir:

<?php
phpinfo();

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

How to make the characteristics of the product

How to make the characteristics of the product? Is there such a plugin?

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Is there a lighter weight alternative to requestAction?

On Friday, June 29, 2012 12:30:39 AM UTC-4, Ilie wrote:
Hello,

Another way to do this is to have one controller requestAction to fetch (as array or objects) all the data you need to render your modules, then using Elements or View Blocks to do the actual rendering of the modules.
Yes, that's exactly what I'm doing to assemble the modules. With view blocks, we can divide the page into panels and create a view block for each panel, so by specifying a panel attribute in the module, we can render each module in the specified panel and assemble the layout in the common view. That part is working very well.

However, suppose the content editors want to write an article about farmers markets and they want to display a list of farmers markets in the local area, we can tell them to embed something like {/organizations/list/tag:farmers-markets/radius:10/count:5} in the content. Or somewhere else they want a list of music events, then we would tell them to embed {/events/list/tag:music/radius:75/count:10}. So by passing that URL to requestAction, it will call the appropriate controller and action and return the rendered content. It keeps the code simple and modular, in the spirit of MVC. We are doing a form of that in Cake 1.1 right now but the rendering time is a bit longer than I would like. I suppose we can create our own version of the dispatcher, though I'm not sure of the benefit vs. maintainability. 

As you say, caching is important and we do do that, so really it is the first time hit that counts.

Mark

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: not found error when naming views.ctp files in arabic

the problem is with encoding :(
 
 

On Friday, June 29, 2012 7:36:03 PM UTC+2, MSayyaf wrote:

I had a problem with naming views.ctp files in arabic language and calling them with CakePHP2.0.

So I've done this:
- created a view file, naming it in arabic and set it under app/views/pages/myNameInArabic.ctp
- in app/views/layouts/default.ctp file i put a link to it:
echo $this->Html->link('link', array('controller'=>'pages', 'action'=>'صفحة'));

when i clicked the link:
- url bacame: http://localhost/MySite/pages/صفحة
- and got the following error:
Error: The view for PagesController::display() was not found.
Error: Confirm you have created the file: F:\xampp\htdocs\TestLocal\app\View\Pages\صفحة.ctp
etc etc

thanks

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Completely blank screen after form submission

In my app, for certain records, after save is clicked, it shows a completely
blank page. The url is pointing at my add view with no id passed. The number
it does this on is a small percentage of them. It works fine and exactly as
I expect it too on all the rest. I have no more ideas as to what it could
be. My add function is below. It's really weird that it would work just fine
on 95% of them but not the rest. Maybe it's something in the data coming in?
But i'm also using the security component, could be that?

function add($id = null) {
$drug = $this->FrenchTranslation->Drug->read(
array(

'Drug.id','Drug.generic','Drug.ahl','Drug.aap','Drug.rid','Drug.oral','Drug.mw','Drug.clinical_recommendations','Drug.category','Drug.lrc','Drug.lrc2','Drug.lrc3','Drug.vd','Drug.rid_range_rounded','Drug.adultdose'
),
$id
);
//$this->set('drug',$drug);
$this->set(compact('drug'));

if (!empty($this->data)) {
$this->FrenchTranslation->create();
if ($this->FrenchTranslation->save($this->data)) {
if(isset($this->params['form']['Next']) &&
$this->params['form']['Next'] == 'Next'){
$this->next($id, $this->data['FrenchTranslation']['generic']);
}
if(isset($this->params['form']['Previous']) &&
$this->params['form']['Previous'] == 'Previous'){
$this->previous($id, $this->data['FrenchTranslation']['generic']);
}
if(!isset($this->params['form']['Previous']) &&
!isset($this->params['form']['Next'])){
$this->Session->setFlash(__('The french translation has been saved',
true));
//$this->redirect(array('action' =>
'edit',$this->data['FrenchTranslation']['id']));
$this->redirect(array('action' => 'edit',$id));
}
} else {
$this->Session->setFlash(__('The french translation could not be saved.
Please, try again.', true));
}
}
$drugs = $this->FrenchTranslation->Drug->find('list');
$this->set(compact('drugs'));
}

--
View this message in context: http://cakephp.1045679.n5.nabble.com/Completely-blank-screen-after-form-submission-tp5709166.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Undefined index after web host install.

Notice (8): Undefined index:  Upload [APP/Controller/UploadsController.php, line 32]
/app/Controller/UploadsController.php (line 32)
null

This is what I get, when I do the debug, so Im guessing theres no errors with the coding. Where else could the error be. 
It works fine in localhost but once I uploaded it to the online web host I get thrown this error. 

This is my form;
<?php echo $this->Form->create('Upload', array('controller'=>'uploads','action'=>'add','type' => 'file', 'class'=>'uploadfrm'));?>  	<fieldset class='registerf'>   		<legend class='registerf2'>Upload a Video</legend>  	<?php  		echo 'Upload your video content here, there is no size limit however it is <b>.mp4</b> file format only.';  		echo '<br/>';  		echo '<br/>';  		echo $this->Form->input('name', array('between'=>'<br />', 'class'=>'input'));  		echo $this->Form->input('eventname', array('between'=>'<br />', 'class'=>'input'));  		echo $this->Form->input('description', array('between'=>'<br />', 'rows'=> '7', 'cols'=> '60', 'class'=>'input'));  		echo  $this->Form->hidden('userid', array('id' => 'user_id','value' => $auth['id']));  		echo $this->Form->hidden('username', array('id' => 'username', 'value' => $auth['username']));  		echo $this->Form->input('file', array('type' => 'file'));    		echo "<br/>";  	?>  	<?php echo $this->Form->end(__('Upload Video', true));?>  	</fieldset>

Any ideas?

On Thursday, 28 June 2012 22:34:09 UTC+1, Guti Grewal wrote:
Hi I've uploaded my website on a free hosting site called 000webhost, it works fine on localhost but however when I try to upload a file to the server using a form I get thrown this error.

Notice (8): Undefined index:  Upload [APP/Controller/UploadsController.php, line 32]
Code
UploadsController::add() - APP/Controller/UploadsController.php, line 32  ReflectionMethod::invokeArgs() - [internal], line ??  Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 485  Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 103  Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 85  [main] - APP/webroot/index.php, line 96

I can't for the life of me figure out what is going wrong?
I've set the permissions for the webroot/files/uploads folder to 777, so it can't possibly be that. 
Anyone have any ideas?

--
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.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Routes with slugs, pagination problem

Router::connect(
'/:slug',
array(
'controller' => 'categories',
'action' => 'view'
),
array(
'slug' => '[-a-z0-9]+',
'pass' => array('slug')
)
);
Router::connect(
'/:slug/:page',
array(
'controller' => 'categories',
'action' => 'view'
),
array(
'slug' => '[-a-z0-9]+',
'page' => '[0-9]+',
'pass' => array('slug')
)
);

And I had to put the following in AppController::beforeFilter when I
upgraded to 2.x:

if (isset($this->request->params['page']))
{
$this->request->params['named']['page'] = $this->request->params['page'];
}

On Thu, Jun 28, 2012 at 6:10 PM, Ovidiu Marinoiu
<ovidiu.marinoiu@gmail.com> wrote:
> Hello,
>
> I have created a route which looks like this Router::connect('/:slug',
> array('controller' => 'categories', 'action' => 'view'), array('pass' =>
> array('slug')));
>
> Until here, everything works okey, visiting the
> link http://example.com/animals-and-pets, works perfect.
>
> On this page I have a pagination and this gives me e big problem, the links
> for the pages, are generating wrong, like
> this: http://example.com/categories/view/animals-and-pets/page:2.
>
> The result that I want to obtain is http://example.com/animals-and-pets/2.
>
> Thanks for your help 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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php