Re: Need help with custom validation please

2010-02-23 Thread Jeremy Burns
The data is accessible via $this->data. If you debug it you'll see the shape of 
the array so you check values within it (something like 
$this->data['Model']['field']. Your custom validation function should return 
either true or false. If it returns false, your validation error should be set 
for the field and therefore appear on the form.

Jeremy Burns
jeremybu...@me.com


On 23 Feb 2010, at 08:30, mivogt-LU wrote:

> hi there, I have some problems doing my first cake and adding some
> validation methods on my own.
> It would be great if someone in here might give me a good start and
> help me to do my first steps ...
> 
> I am using 2 models linked with each other
> lodgings : id, roomnumber, amountofbeds, ...
> bokkingpositions: id, lodging_id, amountkids amountyoungsters,
> amountadults
> 
> Now I would like to check if there are enough beds for the people
> typed in the add-view of booking-positions.
> This for I thought of doing a new validation rule in validation array
> and add me an own function to the model for the validating.
> 
> Here I have 2 problems.
> 1.) I do not know hot to access the posted data inside the model.
> I tried $data[amountadult] and  $data['amountadult'] both results with
> an unknown index error.
> 2.) if I add an error message in my validate-array, it is not shown
> below the field. Only the red bar below the field is shown without my
> message.
> 
> 
> some code snips:
> Model:
>  class BookingPosition extends AppModel {
>var $name = 'BookingPosition';
>var $displayField = 'id';
> ...
> var $validate=array
> (
> 'amountadult' => array(
> 'rule'=>array('limitPersonen'),
> 'message'=>"to many persons"
> ),
> );
> 
> 
> 
>  function limitPersonen($data)
>  {
>  // $a1 = $data['amountadult']... wont work, indes
> not found  :(
>   return false; //( simulate all amount persons>number of beds
>  }
> 
> 
> 
> Pleas give me some help to start over - TIA
> 
> CU
> 
> Michael
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Another saveAll() problem

2010-02-22 Thread Jeremy Burns
Have you checked to see if your data array is missing any required fields? If 
so, it would still pass validation but fail at the database level. Also, is 
your validation right (does it match what the database expects)?

Jeremy Burns
jeremybu...@me.com

On 22 Feb 2010, at 21:06, Lucca Mordente wrote:

> Hi there.
> 
> I'm having problems saving a model and it's related data.
> a $this->Paper->saveAll($this->data); call returns false.
> 
> and later I figured out that a simple $this->Paper->Document-
>> save($this->data) is failing too.
> 
> the data is set correctly and there are no validationErrors.
> 
> any suggestion?
> Thanks!
> Lucca
> 
> the associations follow:
> 
> Paper hasMany Chart
> Paper hasMany Table
> Paper hasMany Document
> 
> PaperAttachment belongsTo Paper
> 
> and the code:
> 
> class Paper extends AppModel {
>   var $hasOne = array(
>   'Chart' => array(
>   'className'=>'PaperAttachment'
>   ),
>   'Table' => array(
>   'className'=>'PaperAttachment'
>   ),
>   'Document' => array(
>   'className'=>'PaperAttachment'
>   ),
>   );
> }
> 
> class PaperAttachment extends AppModel {
>var $belongsTo = array(
>'Paper' => array(
>)
>);
> }
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Multi model finds

2010-02-20 Thread Jeremy Burns
I am building a search form that retrieves data from four related
models. The user can supply criteria against a number of fields from
those models. What is the best method for doing a variable cross model
search?

To put that into context; If you have an Author model that hasMany
Posts that hasMany Comments, what is the find syntax to retrieve a
list of all Authors filtered by a set of conditions on Authors and/or
a set of conditions on Posts and/or a set of conditions on Comments?
My experiments so far give various results. If I supply criteria for
Posts but none for Authors, I get all Authors but the Posts are
filtered.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Error Code

2010-02-20 Thread Jeremy Burns
It looks as if you haven't set the $books array in your controller.

Jeremy Burns
jeremybu...@me.com


On 20 Feb 2010, at 09:45, dido wrote:

> 
>  
>ISBNTitleAuthor
>  
>  
>  
>
>
>
>  
>  
>
> 
> and any line of code :
> 
> Notice (8): Undefined variable: books [APP\views\books\index.ctp, line
> 5]
> Warning (2): Invalid argument supplied for foreach() [APP\views\books
> \index.ctp, line 5]
> 
> Please help me, Thank's?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Screencasts won't play

2010-02-20 Thread Jeremy Burns
I have had similar problems (and I am all up to date) and play/pause controls 
are out of site (below the frame). I view the source go directly to the URL - 
e.g. http://www.archive.org/download/AdminRouting/admin_routing.mov and it all 
works fine.

Jeremy Burns
jeremybu...@me.com

On 20 Feb 2010, at 08:46, WebbedIT wrote:

> Sounds like you need to update your quicktime player.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to make the paginator->sort link an image?

2010-02-19 Thread Jeremy Burns
You could do it with CSS?

Jeremy Burns
jeremybu...@me.com

On 20 Feb 2010, at 02:15, MST wrote:

> How can I replace the text 'Paid' with an image at the top of my
> table?
> 
> So, instead of this:
> sort('Paid', 'payment_received');?>
> 
> I get something like this:
> sort('  IMAGE GOES HERE  ',
> 'payment_received');?>
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Multiple forms on single page

2010-02-18 Thread Jeremy Burns
You have to get $this->data into the right shape and then you can parse it in a 
controller and do separate logic/saves, or if appropriate do a saveAll, which 
can be a bit tricky to set up, but does works well.

See: http://book.cakephp.org/view/75/Saving-Your-Data  Pay special attention to 
the notes on how to shape your data array.

Jeremy Burns
jeremybu...@me.com


On 18 Feb 2010, at 21:11, McScreech wrote:

> Is it possible to define several _independent_ data entry forms on a
> single page where each one posts data back to different models? Maybe
> with a redirect back to the same multi-form page on each Submit until
> a 'Done' button is clicked?
> 
> And of course, if so, any suggestions on how to do so?
> 
> DaveT.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: ACL Question

2010-02-18 Thread Jeremy Burns
I was getting this self same error even though I had not declared any interest 
in Acl. It is not being called as a component, I am not calling any of its 
methods and the cache is completely clear.

I am posting this as I made a schoolboy error and it might help prevent others 
doing the same.

I tracked it down to the fact that in my app_controller I had:

$this->Auth->authorize = 'actions';

This is only used when you are implementing Acl as well as Auth. If you are not 
using Acl, use this:

$this->Auth->authorize = 'controller';

I made the mistake as I copied some code from the tutorial to help me set up 
Auth correctly. Of course, the tutorial also covers Acl, hence the mistake.

Jeremy Burns
jeremybu...@me.com


On 15 Jan 2010, at 16:33, Dave wrote:

> Yeah it was only in the app_controller, but I just dumped cache folder and
> seemed to clear it up. 
> 
> Thanks,
> 
> Dave
> 
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
> Of scs
> Sent: January-15-10 12:51 PM
> To: CakePHP
> Subject: Re: ACL Question
> 
> Make sure you do not have
> var $components = array('Acl');
> in you app_controller or any other controllers
> 
> On Jan 14, 8:48 pm, "Dave"  wrote:
>> I get this error as soon as i login
>> 
>> Could not find AclComponent. Please include Acl in
> Controller::$components.
>> [CORE/cake/libs/controller/components/auth.php, line 378]
>> 
>> Fatal error: Call to a member function check() on a non-object in 
>> /home4/public_html/cake/libs/controller/components/auth.php on line 
>> 480
>> 
>> But I am not using ACL, nor do I want to. Cant seem to figure out 
>> where this is coming from or why.
>> 
>> Any ideas? No idea where to start
>> 
>> Thanks
>> 
>> Dave
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.725 / Virus Database: 270.14.139/2620 - Release Date: 01/15/10
> 09:17:00
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: SSL and https

2010-02-17 Thread Jeremy Burns
Thanks John - I'll read, experiment and post back.

Jeremy Burns
jeremybu...@me.com


On 17 Feb 2010, at 08:48, John Andersen wrote:

> Hi Jeremy,
> Take a look at the issue in this thread:
> http://groups.google.com/group/cake-php/browse_thread/thread/1c6b4727066173cf/19cf7202211f930d#19cf7202211f930d
> 
> There I see the same solution as yours, but with some additional
> information. Maybe it will help you on the way .. or maybe discuss it
> with the original poster!
> Enjoy,
>   John
> 
> On Feb 17, 7:54 am, Jeremy Burns  wrote:
>> Any takers on this please?
>> 
>> Jeremy Burns
>> jeremybu...@me.com
>> 
>> On 12 Feb 2010, at 05:00, Jeremy Burns wrote:
>> 
>>> I am using the security component from app_controller. In some
>>> controllers I have this in my beforeFilter:
>> 
>>>if (in_array($this->params['action'], $action)):
>>>$this->Security->blackHoleCallback = 'forceSSL';
>>>$this->Security->requireSecure();
>>>else:
>>>$this->Security->blackHoleCallback = 'unforceSSL';
>>>endif;
>> 
>>> I have these two functions in app_controller:
>> 
>>>function forceSSL() {
>> 
>>>$this->redirect('https://' . env('SERVER_NAME') . $this->here);
>> 
>>>}
>> 
>>>function unforceSSL() {
>> 
>>>$this->redirect('http://' . env('SERVER_NAME') . $this->here);
>> 
>>>}
>> 
>>> This is working in the sense that the right actions in the right
>>> controllers are being redirected to https. But once I am in https, I
>>> stay there.
>> 
>>> My question is: how do I get the site to go back to http for those
>>> controller actions that do not require https?
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> with their CakePHP related questions.
>> 
>>> You received this message because you are subscribed to the Google Groups 
>>> "CakePHP" group.
>>> To post to this group, send email to cake-php@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
>>> athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: SSL and https

2010-02-16 Thread Jeremy Burns
Any takers on this please?

Jeremy Burns
jeremybu...@me.com


On 12 Feb 2010, at 05:00, Jeremy Burns wrote:

> I am using the security component from app_controller. In some
> controllers I have this in my beforeFilter:
> 
>   if (in_array($this->params['action'], $action)):
>   $this->Security->blackHoleCallback = 'forceSSL';
>   $this->Security->requireSecure();
>   else:
>   $this->Security->blackHoleCallback = 'unforceSSL';
>   endif;
> 
> I have these two functions in app_controller:
> 
>   function forceSSL() {
> 
>   $this->redirect('https://' . env('SERVER_NAME') . $this->here);
> 
>   }
> 
>   function unforceSSL() {
> 
>   $this->redirect('http://' . env('SERVER_NAME') . $this->here);
> 
>   }
> 
> This is working in the sense that the right actions in the right
> controllers are being redirected to https. But once I am in https, I
> stay there.
> 
> My question is: how do I get the site to go back to http for those
> controller actions that do not require https?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Creating new rows

2010-02-13 Thread Jeremy Burns
No.

Jeremy Burns
jeremybu...@me.com
On 13 Feb 2010, at 08:20, WebbedIT wrote:

> The main question is, is it supposed to be creating two rows?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Creating new rows

2010-02-12 Thread Jeremy Burns
I have this function in the items model:

function addNewItem() {

$this->save();

$itemId = $this->id;

return $itemId;

}

When called from a controller it does what it is supposed to do;
creates a new row in the table and returns the id of the new row.

Here's the odd part; it is creating two rows in the database and
returning the id of the first row. So if the returned id is 100, I'll
also find id 101 in the table. Any ideas what might be going wrong?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to include a button which links to a view?

2010-02-12 Thread Jeremy Burns
I agree, but sites must degrade nicely. With no java, the standard baked delete 
function deletes without warning. That is not nice degradation. If a site 
doesn't reorder a list without refreshing the page, that's OK.

Jeremy Burns
jeremybu...@me.com


On 12 Feb 2010, at 10:20, WebbedIT wrote:

>> I struggled with this for while as I don't like relying on java being 
>> switched on.
> 
> I think the worry as to whether javascript is turned on or not is
> becoming more and more mute.  Look at really big sites/applications,
> they heavily rely on javascript for a lot of their features yet it
> does not negatively impact on their global online dominance.
> 
> How many Web 2.0 (for want of a better term) sites do not use Ajax?
> Take Ebay's ability to alter the ordering of their listing pages, turn
> off javascript it's rendered useless.
> 
> Is this a case of coding for the minority at the detriment of the
> majority?
> 
> @ Guillermo: if you agree that the use of javascript is not an issue
> then you use the following
> 
> $html->link('Delete', array('action' => 'delete', $row['Model']
> ['id']), null, 'Are you sure?')
> 
> It's part of Cake's core automagic so the dev team obviously don't
> have a problem with relying on javascript.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


SSL and https

2010-02-11 Thread Jeremy Burns
I am using the security component from app_controller. In some
controllers I have this in my beforeFilter:

if (in_array($this->params['action'], $action)):
$this->Security->blackHoleCallback = 'forceSSL';
$this->Security->requireSecure();
else:
$this->Security->blackHoleCallback = 'unforceSSL';
endif;

I have these two functions in app_controller:

function forceSSL() {

$this->redirect('https://' . env('SERVER_NAME') . $this->here);

}

function unforceSSL() {

$this->redirect('http://' . env('SERVER_NAME') . $this->here);

}

This is working in the sense that the right actions in the right
controllers are being redirected to https. But once I am in https, I
stay there.

My question is: how do I get the site to go back to http for those
controller actions that do not require https?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to include a button which links to a view?

2010-02-11 Thread Jeremy Burns
I struggled with this for while as I don't like relying on java being switched 
on. Here's an article I put together that borrows heavily from other 
contributors here. It might help. 
http://www.jeremy-burns.co.uk/2009/12/cakephp-adding-a-delete-confirm-function/

Jeremy Burns
jeremybu...@me.com


On 11 Feb 2010, at 15:55, sebb86 wrote:

> Hello all,
> 
> thanks for all your answers. After reading all your answers, i've
> decided to use a image, which links to a page.
> Could someone help me to add a warning-message, e.g. when i delete
> something???
> 
> Here is my image/link code from the view:
> [code]
>image("delete.png", array("alt" => "delete",
> 'url' => array('controller' => 'hardware_units', 'action' => 'delete',
> 'id' => $hardware_unit['HardwareUnit']['id'])));?>
> [\code]
> 
> And my delete function in the controller:
> [code]
> function delete($id)
>   {
>   $this->HardwareUnit->del($id);
>   $this->Session->setFlash('hardware unit with id: '.$id.' has 
> been
> deleted');
>   $this->redirect(array ('action' => 'index'));
>   }
> [\code]
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to include a button which links to a view?

2010-02-11 Thread Jeremy Burns
Something like this:

echo $html->link(
$html->image("recipes/6.jpg", array("alt" => "Brownies")),
"recipes/view/6",
array('escape'=>false)
);

or

echo $html->image("recipes/6.jpg", array(
"alt" => "Brownies",
'url' => array('controller' => 'recipes', 'action' => 'view', 6)
));

See: 
http://book.cakephp.org/view/836/link and
http://book.cakephp.org/view/835/image

Jeremy Burns
jeremybu...@me.com

On 11 Feb 2010, at 09:36, sebb86 wrote:

> Hello,
> 
> how can i create a button in a view, which links to another view? This
> is my code with a simple text link, but how can i this as a button?
> 
> [code]
> 
>  link('add a hardware unit', array('controller'
> => 'hardware_units', 'action' => 'add')) ?>
> [\code]
> 
> Thanks a lot if someone can help!!! :)
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Caching Elements

2010-02-10 Thread Jeremy
OK... I have a follow-up question.

How do I prevent caching in certain cases?  In the element that I am
working on, it is possible for the external service to fail.  If that
happens, I trap the error and create some HTML to notify the user that
the service is unavailable.  The problem is that I don't really want
to cache the error message.  I'd rather that it retry and only cache
if the result was successful.

I tried ecapsulating the error HTML in , but that does
not seem to work.  Reloading the page will not cause the page to re-
attempt to render the external service results.

I have pasted the full code to my element here:
http://bin.cakephp.org/view/11698566


On Feb 10, 8:35 am, Jeremy  wrote:
> Yes, correct.  My bad.
>
> On Feb 10, 2:51 am, majna  wrote:
>
>
>
> > I think it's /tmp/cache/views, not  /tmp/cache/element
>
> > On Feb 10, 1:53 am, Jeremy  wrote:
>
> > > With some help... I figured out the problem.  I was using the file
> > > cache option and although the /tmp/cache directory was writable I was
> > > missing a necessary directory.  Since I was trying to cache an element
> > > the /tmp/cache/element directory needs to exist and it must be
> > > writeable.  My problem was that the element directory was missing.
> > > Once I added it... everything started working as expected.
>
> > > On Feb 9, 10:13 am, Jeremy  wrote:
>
> > > > Hi all.  I have created an element that will interact with an external
> > > > webservice.  The webservice presents weather forecast data in XML and
> > > > I am using my element code to parse the XML and render it on my site.
> > > > The weather forecast service never updates their data more frequently
> > > > than 1 hour, so I would like to cache the rendered element HTML for 1
> > > > hour globally for all users.  Right now, each refresh of the page than
> > > > contains this weather element code will cause a hit to the weather
> > > > forecast webservice and the XML will get reparsed even if it hasn't
> > > > changed.
>
> > > > I have tried to follow the instructions on how to turn on caching, but
> > > > it does not seem to be working.
>
> > > > Here's what I have done so far:
> > > > 1) Turned this on in the config Configure::write('Cache.check',
> > > > true);
> > > > 2) I am calling the element with this code: 
> > > > >element('weather', array('cache'=>array('time'=>'+1 hour'))); ?>- Hide 
> > > > >quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Caching Elements

2010-02-10 Thread Jeremy
Yes, correct.  My bad.

On Feb 10, 2:51 am, majna  wrote:
> I think it's /tmp/cache/views, not  /tmp/cache/element
>
> On Feb 10, 1:53 am, Jeremy  wrote:
>
>
>
> > With some help... I figured out the problem.  I was using the file
> > cache option and although the /tmp/cache directory was writable I was
> > missing a necessary directory.  Since I was trying to cache an element
> > the /tmp/cache/element directory needs to exist and it must be
> > writeable.  My problem was that the element directory was missing.
> > Once I added it... everything started working as expected.
>
> > On Feb 9, 10:13 am, Jeremy  wrote:
>
> > > Hi all.  I have created an element that will interact with an external
> > > webservice.  The webservice presents weather forecast data in XML and
> > > I am using my element code to parse the XML and render it on my site.
> > > The weather forecast service never updates their data more frequently
> > > than 1 hour, so I would like to cache the rendered element HTML for 1
> > > hour globally for all users.  Right now, each refresh of the page than
> > > contains this weather element code will cause a hit to the weather
> > > forecast webservice and the XML will get reparsed even if it hasn't
> > > changed.
>
> > > I have tried to follow the instructions on how to turn on caching, but
> > > it does not seem to be working.
>
> > > Here's what I have done so far:
> > > 1) Turned this on in the config Configure::write('Cache.check',
> > > true);
> > > 2) I am calling the element with this code: 
> > > >element('weather', array('cache'=>array('time'=>'+1 hour'))); ?>- Hide 
> > > >quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Caching Elements

2010-02-09 Thread Jeremy
With some help... I figured out the problem.  I was using the file
cache option and although the /tmp/cache directory was writable I was
missing a necessary directory.  Since I was trying to cache an element
the /tmp/cache/element directory needs to exist and it must be
writeable.  My problem was that the element directory was missing.
Once I added it... everything started working as expected.

On Feb 9, 10:13 am, Jeremy  wrote:
> Hi all.  I have created an element that will interact with an external
> webservice.  The webservice presents weather forecast data in XML and
> I am using my element code to parse the XML and render it on my site.
> The weather forecast service never updates their data more frequently
> than 1 hour, so I would like to cache the rendered element HTML for 1
> hour globally for all users.  Right now, each refresh of the page than
> contains this weather element code will cause a hit to the weather
> forecast webservice and the XML will get reparsed even if it hasn't
> changed.
>
> I have tried to follow the instructions on how to turn on caching, but
> it does not seem to be working.
>
> Here's what I have done so far:
> 1) Turned this on in the config Configure::write('Cache.check',
> true);
> 2) I am calling the element with this code: 
>
>
> >element('weather', array('cache'=>array('time'=>'+1 hour'))); ?>- Hide 
> >quoted text -
>
> - Show quoted text -

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Caching Elements

2010-02-09 Thread Jeremy
Hi all.  I have created an element that will interact with an external
webservice.  The webservice presents weather forecast data in XML and
I am using my element code to parse the XML and render it on my site.
The weather forecast service never updates their data more frequently
than 1 hour, so I would like to cache the rendered element HTML for 1
hour globally for all users.  Right now, each refresh of the page than
contains this weather element code will cause a hit to the weather
forecast webservice and the XML will get reparsed even if it hasn't
changed.

I have tried to follow the instructions on how to turn on caching, but
it does not seem to be working.

Here's what I have done so far:
1) Turned this on in the config Configure::write('Cache.check',
true);
2) I am calling the element with this code: element('weather', array('cache'=>array('time'=>'+1 hour'))); ?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Auth flash message LAYOUT ???

2010-02-09 Thread Jeremy Burns
Try something along these lines:

$this->Session->setFlash
(__
('Message.', true),
true,
array('class' => 'flashError')
);

Jeremy Burns
jeremybu...@me.com


On 9 Feb 2010, at 14:32, toka...@gmail.com wrote:

> Hi, I am trying to set a custom layout for Auth flash message.
> setFlast() support that but it seems to be hardcoded in the core for
> case of auth messages.
> 
> 
> any idea how to set my own layout wrapper around this message ...
> 
> "Login failed. Invalid username or password."???
> 
> thanks
> help appreciated.
> Tomas
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: validation strangeness

2010-02-03 Thread Jeremy Burns
This might not be the answer you are looking for, but when I have had similar 
issues before I have always debugged $this->data at various points to see what 
is actually being validated and saved. Then I double check the shape of the 
data against the save (and if necessary, saveAll) functions in 
http://book.cakephp.org/view/75/Saving-Your-Data here. Sometimes I have found 
that the shape of the array is not what is expected.

Jeremy Burns


On 4 Feb 2010, at 04:25, cricket wrote:

> Oops. I messed up the call to validate(). But, when I do ...
> 
> if ($this->User->create($this->data) && $this->User->validates())
> {
>   if ($this->User->save($this->data, true))
>   {
> 
> ... validation passes! It should fail. WTF?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Find help for $this->set(compact())

2010-02-03 Thread Jeremy Burns
It's actually a php function: http://php.net/manual/en/function.compact.php

Jeremy Burns
jeremybu...@me.com

On 3 Feb 2010, at 16:16, McScreech wrote:

> Hello,
> 
> Where do I find the definition or explanation of '$this->set(compact
> ())' in the Cookbook or API?
> 
> Thanx, DaveT.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: save default values when $this->data['field'] is empty

2010-02-03 Thread Jeremy Burns
You could either add a hidden text field to the form or set 
$this->data['model']['field'] to the value in the controller before you do a 
save.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 3 Feb 2010, at 10:16, matzeh...@googlemail.com wrote:

> Hi,
> 
> what would you do if you want to save a default value and don´t want
> to predefine a input field?
> I tried with a custom validation rule but the return of it is true/
> false not the corrected value.
> Is the best way to do this in an function in the controller?
> 
> Greetings
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Pagination: URL for last page

2010-02-02 Thread Jeremy Burns
echo $paginator->last('>>');

Jeremy Burns


On 2 Feb 2010, at 17:11, Ragnis wrote:

> How can i go to the last page, if i don't know the count of items?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Jeremy Burns
Could you use  in the right places? See 
http://book.cakephp.org/view/347/Marking-Non-Cached-Content-in-Views

Jeremy Burns


On 1 Feb 2010, at 12:36, Lorenzo Bettini wrote:

> the real problem is that beforeRender is not called if the page is present in 
> the cache...  any idea of where to put such control?
> 
> thanks in advance
>   Lorenzo
> 
> djogo wrote:
>> Euromark, I think that __construct is the first thing that runs in Any
>> class, so sessions are avaliable in all methods.
>> I thought of using it at bootstrap, but there the session is
>> unavailable...
>> On 31 jan, 20:29, euromark  wrote:
>>> this will never work
>>> the session is initialized in __construct() of the app controller
>>> therefore not available until beforeFilter() in any controller
>>> 
>>> the session will not be present at that time yet
>>> or am i mistaken?
>>> 
>>> On 31 Jan., 22:09, majna  wrote:> dirty way (not tested)
>>>> in app/config/bootstrap.php
>>>> check if user is logged in, like:
>>>> if (isset($_SESSION['User']['id])) {
>>>>   Configure::write('Cache.check', false);
>>>> }
>>>> On Jan 31, 11:32 am, Lorenzo Bettini  wrote:
>>>>> Hi
>>>>> in my AppController I've enabled cache for view and index actions and
>>>>> they work fine.
>>>>> Now, I'd like to disable cache when a user is logged, since in that case
>>>>> additional information are shown that must not be cached.
>>>>> Thus I added the method
>>>>>function beforeRender() {
>>>>>if ($this->is_logged_user()) {
>>>>>// disable cache when the user is logged, since 
>>>>> some information
>>>>>// must NOT be cached, e.g., private papers
>>>>>$this->cacheAction = array();
>>>>>}
>>>>>}
>>>>> where is_logged_user is a function that checks whether a user is logged.
>>>>> This works in the sense that no cache is used when a user is browsing
>>>>> the site.  However, if the user visits an action page which has already
>>>>> been cached then he will get the cached page, which I want to avoid as
>>>>> well...  is there a way to avoid this?
>>>>> I've also tried with $this->disableCache() but that does not work.
>>>>> The only solution I see is to clear the cache, but I'd want to avoid 
>>>>> that...
>>>>> thanks in advance
>>>>>Lorenzo
>>>>> --
> 
> 
> 
> -- 
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
> BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: need some help with a select

2010-02-01 Thread Jeremy Burns
try:

$form->input('**fieldname**', array('empty' => true));

...where **fieldname** is the field you want to display. This will give you a 
populated drop down but the first entry will be an empty row. Is this what you 
wanted?

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 1 Feb 2010, at 09:42, Ernesto wrote:

> Hello.
> 
> i need a select box, wrapped in his "" div
> and with blank first entry
> 
> $form->input() ---> the select didn't have the empty field
> $form->select() ---> the select wasn't wrapped in his DIV
> 
> any suggestion?
> 
> ps: i'm using Cake 1.3Beta
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Random question

2010-01-28 Thread Jeremy Burns
This might seem a bit random/basic but I thought I'd ask it anyway. I
love using the html helper, but is there a performance hit (even teeny
tiny marginal because that can compound up) when calling up the helper
to echo $html->tag('p', 'Hello world') compared a vanilla with
Hello world?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: HtmlHelper does not like multiple URL parameters?

2010-01-28 Thread Jeremy Burns
Aren't those two outputs the same?

Jeremy Burns

On 28 Jan 2010, at 07:59, Johnny Cupcake wrote:

> My code (Cake 1.2.5):
> echo $html->url( array(
>   'controller' => 'users',
>   'action' => 'activate',
>   '?' => array('e' => 'EMAIL', 'c' => 'CODE')), TRUE );
> 
> The output:
> http://localhost/index.php/users/activate?e=EMAIL&c=CODE
> 
> This output is wrong, right?  Should be:
> http://localhost/index.php/users/activate?e=EMAIL&c=CODE
> 
> Workarounds?  Must I use slashes as argument delimiters, or just build
> the URL myself?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Best approach for Pages

2010-01-27 Thread Jeremy Burns
I built an 'about' controller with a function for each page, then used routing 
to remove the 'about' part from the url.

Jeremy Burns

On 28 Jan 2010, at 06:10, Dave wrote:

> I have to build a simple site, 5 pages but the tricky part seems to be the 
> pages are index, about us, info, history and contact us so the urls need to 
> be reflected by that (site/about_us site/contact) and the only thing on 
> these pages will be text. Admin logs in and using wysiwyg editor can update 
> the content for these pages. I do not want to build 5 controllers since 
> everything can be done with 1 "pages" controller. So my question is how can 
> this be done and if using 1 controller what would you name this controller 
> since "pages" is the obvious choice but that's set aside for stoic pages and 
> can you set routes for the text urls using 1 controller?
>  
> Any ideas / suggestions would be great.
>  
> Thanks,
>  
> Dave
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>  
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Dynamic Navigations

2010-01-27 Thread Jeremy Burns
I got this working (although I have amended the model since but not updated 
this article - perhaps I should!). This might help as  a starting place.

http://www.jeremy-burns.co.uk/2009/11/cakephp-dynamic-navigation-bars/

Jeremy Burns

On 27 Jan 2010, at 16:06, Dave wrote:

> I m trying to figure out the best way to create dynamic navigation but not 
> sure where to start.
>  
> The idea is have a "manager" for main nav, left side, right side, footer so 
> the admin can create or edit each nav from the manager. They most likely will 
> not change from page to page so all the navs will be the same when used. I 
> was thinking
>  
> tables
> sections:
> id
> navigation_id
> title => about Us
> controller => information
> action => index
>  
> navigations:
> id
> name => main, left, right, footer
>  
> Ideas?
>  
> Thanks,
>  
> Dave
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>  
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: bindModel

2010-01-27 Thread Jeremy Burns
You can set recursion and containment restrictively in app_model:

var $actsAs = array('Containable');
var $recursive = -1;

...then undo it as you need. Take a look at the section on the contain 
behaviour in the online book - http://book.cakephp.org/view/474/Containable - 
I'd recommend adopting it wholeheartedly. Once you get to grips with it you'll 
love it.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 27 Jan 2010, at 15:31, yazan suleiman wrote:

> Thats a very good question.  In fact, I am still exploring CakePHP and trying 
> to find out more about the ins and outs.  Anyway.  I did that and it worked.  
> However, my reasoning for not using associations in the model was the 
> following:
> 
> If I do use association the model, then any select on Users table (model) 
> will fetch the rest of the associated tables.  I know about recursive and I 
> can specify its value.  But I am using Auth and the login function fetch 
> everything associated to users eventhough it only needs username and 
> password.  In addition  What if I only want a user and his/her profile, can I 
> exclude Resume.  So these are the questions I had and didnot know the answer 
> to.  So I thought my best route is to bind/unbind these associations.  Please 
> let me know whether my reasoning is not valid.  And thank you for your reply.
> 
> On Wed, Jan 27, 2010 at 9:24 AM, Jeremy Burns  wrote:
> Can I pose the question "Why are you not defining associations in your 
> models?"  They are incredibly powerful.
> 
> Jeremy Burns
> jeremybu...@me.com
> (Skype) +44 208 123 3822 (jeremy_burns)
> (m) +44 7973 481949
> (h) +44 208 530 7573
> 
> On 27 Jan 2010, at 04:36, YS wrote:
> 
> > I am very new to cakephp and having problems understanding bindModel.
> > I have read the documentation several times but bindModel is not
> > behaving as I expect.  This is my issue:
> >
> > I have user who has one profile and one resume.  I am storing resume
> > in a separate table and I am not defining association in my models and
> > only using binding 'bindModel'.  In my controller I do the following:
> >
> > $this->User->bindModel(array('hasOne' => array('Profile', 'Resume')));
> > if ($this->User->saveAll($this->data, array('validate'=>'first'))){
> >  
> > }
> >
> > So I get the following error (the error is referring to Resume):
> >
> > Warning (512): SQL Error: 1364: Field 'user_id' doesn't have a default
> > value.  I know I am doing something wrong because this behavior does
> > not match the one in the documentation (examples).  I cannot figure
> > out where the problem is however.
> >
> > I was not sure what other information you may need to look into this
> > and thought the above is sufficient for now.  (let me know if you need
> > more information).
> >
> > Any help is really appreciated.
> >
> > Check out the new CakePHP Questions site http://cakeqs.org and help others 
> > with their CakePHP related questions.
> >
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> > http://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>  
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Blog tutorial trouble...

2010-01-27 Thread Jeremy Burns
It might not be this, but I've done it in the past. Check that when you 
installed Cake you also copied over the .htacces files. They exist in the root, 
in /app and in /app/webroot. If these files are hidden it is easy to overlook 
them, especially the one in the root.

Jeremy Burns
On 27 Jan 2010, at 15:24, Andrew Poquette wrote:

> So, I installed cake, set everything up, and have the welcome page
> saying that Cake can connect to the database, and I'm good to go.
> 
> I created a model, a controller, and a view via the tutorial, but when
> I go to http://localhost/posts/index I get a 404 error.  I've searched
> the group here and I couldn't find a solution.
> 
> Totally new to cake, so I may have screwed something up but I'm
> developing in Ubuntu and apache, php, and mysql are all installed and
> working.
> 
> Does anyone have any ideas on why I wouldn't be able to see the view?
> Everything is 100% copied from the tutorial!
> 
> Thanks for your help!
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: bindModel

2010-01-27 Thread Jeremy Burns
Can I pose the question "Why are you not defining associations in your models?" 
 They are incredibly powerful.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 27 Jan 2010, at 04:36, YS wrote:

> I am very new to cakephp and having problems understanding bindModel.
> I have read the documentation several times but bindModel is not
> behaving as I expect.  This is my issue:
> 
> I have user who has one profile and one resume.  I am storing resume
> in a separate table and I am not defining association in my models and
> only using binding 'bindModel'.  In my controller I do the following:
> 
> $this->User->bindModel(array('hasOne' => array('Profile', 'Resume')));
> if ($this->User->saveAll($this->data, array('validate'=>'first'))){
>  
> }
> 
> So I get the following error (the error is referring to Resume):
> 
> Warning (512): SQL Error: 1364: Field 'user_id' doesn't have a default
> value.  I know I am doing something wrong because this behavior does
> not match the one in the documentation (examples).  I cannot figure
> out where the problem is however.
> 
> I was not sure what other information you may need to look into this
> and thought the above is sufficient for now.  (let me know if you need
> more information).
> 
> Any help is really appreciated.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Subdomains

2010-01-27 Thread Jeremy Burns
I resolved this, and it was quite easy.

I created a folder within app/webroot (let's call it appfolder), installed the 
program there and pointed my subdomain at the folder. Now I can access the 
application either by going to www.domain.com/appfolder or appfolder.domain.com

Hope this helps some others.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 7 Jan 2010, at 18:11, Juan Luis Baptiste wrote:

> On Thu, Jan 7, 2010 at 12:22 PM, Jeremy Burns  wrote:
>> My hosting company do allow me to create subdomains and point them to 
>> different directories. I have created both, but when I go to 
>> subdomain.[mydomain].com I get:
>> 
>> Error 500 - Internal server error
>> 
>> An internal server error has occured!
>> Please try again later.
>> 
>> I figured this might have something to with .htaccess or something - an area 
>> I am hideously bad at.
> 
> Try first checking out the virtual hosts are working fine. Put a
> simple html page on the virtual host directory and see if it shows up
> when you enter to your subdomain. For the error you sohuld check the
> error logs for that virtual host.
> 
> 
> Juancho
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Table Joins

2010-01-26 Thread Jeremy Burns
Table joins take place in the model using the $belongsTo, $hasMany and 
$hasAndBelongsToMany variables. See 
http://book.cakephp.org/view/78/Associations-Linking-Models-Together.

Jeremy Burns


On 27 Jan 2010, at 06:31, Uresh wrote:

> 
> Hi...I am Uresh Patel from india.
> I am cakephp beginner.
> I took reference from your "Table Rename Join Error" topic.
> I am trying to use inner join between only two tables.
> 
> Tables : 
> 1.user_profiles
>   fields :-> userid (PK)
> 
> 2. Memberships
>   fields :->membid , userid (reference to users profile )
> 
> Can you help me over this issue.?
> 
> Thank You
> 
> Regards,
> Uresh Patel
> [ uresh.pa...@ifuturz.com ]
> http://old.nabble.com/file/p27334701/controllers.rar controllers.rar 
> http://old.nabble.com/file/p27334701/models.rar models.rar 
> -- 
> View this message in context: 
> http://old.nabble.com/Table-Joins-tp27334701p27334701.html
> Sent from the CakePHP mailing list archive at Nabble.com.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: scaffold isn't working

2010-01-26 Thread Jeremy Burns
If it isn't already there, try turning debug to 2 as this clears the model 
cache.

You can find the setting, which looks like this:

Configure::write('debug', 2);

...in app/config/core.php

Jeremy Burns

On 26 Jan 2010, at 14:47, andrei.b wrote:

> Hello,
> I have 2 tables: authors(id, name, email) and books(id, title,
> author_id).
> I've created models for authors and books:
> 
> class Author extends AppModel {
>var $name = 'Author';
>var $hasMany = 'Book';
> }
> 
> class Book extends AppModel {
>var $name = 'Book';
>var $belongsTo = 'Author';
> }
> 
> And the 2 controllers:
> 
> class AuthorsController extends AppController{
>var $name = 'Authors';
>var $scaffold;
> }
> 
> class BooksController extends AppController {
>  var $name = 'Books';
>  var $scaffold;
> }
> 
> When I run http://localhost/relationship/books/ instead of showing at
> author the name of the autor it shows me the id of the author.
> Can somebody help me?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Deep nested data in forms

2010-01-25 Thread Jeremy Burns
I have some connected models: e.g. (made up example):

Post->Comment->Author->Address

My controller's index action creates an array using a model find
function using the containable behaviour - let's call the output
$postSummary.

I have a form that displays data from across the $postSummary array:
e.g.;

Stuff about the Post
The comments belonging the Post
Some info about the Author of the Post
The Address of the Author.

I want to create a form on this page that allows me to edit the
Author's Address details on this page. I can see the data in the
array:

$postSummary[0][Comment][0][Author][Address][..fields...]

...and I can display using them a simple echo statement.

My question is:

How can I create a form and display that same information ready for
edit?

I have tried all sorts of variations of form options and input names,
with no luck:

Is it because I don't have an array called $this->data? If so, how do
I access the stuff and goodness inside it and post it back to my
controller function?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: create a link with conditions to filter index action

2010-01-14 Thread Jeremy Burns
If you are only ever going to filter for category_id, you could do this:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 3));

Then change you index function to:

function index($category_id = null)

...and then check for a non null value later in your code when you do your data 
extraction.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 14 Jan 2010, at 10:47, nyahoo wrote:

> Hi All,
> 
> I hope someone can help me with what I think is a simple question that
> I just haven't wrapped my head round yet. (I'm new to CakePHP).
> 
> I want to create a link that requests the index action of my blog
> (which is paginated), but at the same time passes it a condition, like
> category_id=2 or something like that, so that I can have a list of
> categories to the right of my blog index that reloads the page with
> just that categories blogs. This seems like a straightforward idea to
> me, but I don't seem to be able to get the syntax right. I can do
> limits and orders but not conditions. Can anyone help me please?
> 
> Some examples:
> 
> This works:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 'limit'=>2));
> 
> This doesn't work:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 'conditions'=>'Blog.category_id=3'));
> 
> My controller code:
> function index() {
>   $this->Blog->recursive = 0;
>   $this->set('blogs', $this->paginate());
> }
> 
> Thanks for any advice in advance!
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Pagination with 2nd order recursive conditions filter

2010-01-10 Thread Jeremy Burns
I have had the very same annoying problem and couldn't solve it. I wanted to do 
(effectively - using the good old blog as an example):

SELECT author.id, author.name, COUNT(articles.id) AS article_count FROM authors 
left join articles on articles.author_id = authors.id;

I wanted this for an index view to show how many articles an author had 
written. I then wanted to paginate the results. This ought to be very simple, 
but Cake just folds up as you describe. You can do it with a find (although 
even that was not as easy as I'd hoped), but I could not find a way to paginate 
the results.

One solution I have dipped into but not yet fully implemented is to create a 
view in the database, add a model in Cake and use that as a source. It has one 
additional advantage and that is that as a view, the database will produce the 
results faster than it can by running SQL constructed by Cake.

Of course, you can also add id fields into the results to allow the filtering 
you need.

Has anyone got any views on this?

Jeremy Burns
On 10 Jan 2010, at 17:54, loke wrote:

> I am facing the exact same problem. I want to filter the results on
> the basis of a one-to-many relationship. But it would not accept any
> form of model filter, Parent.Child.fieldName or Child.fieldName even
> though the model relations are well defined. It tries to search the
> parent table for the field name.
> 
> Could you figure it out yet?
> 
> Thanks
> Loke
> On Dec 27 2009, 4:55 am, thomaus  wrote:
>> Hi John,
>> 
>> Thanks for helping but still no luck. I get this (expected) error :
>> 
>> Warning (512): SQL Error: 1054: Unknown column 'User.parent_id' in
>> 'where clause' [/Users/thomas/Sites/Cake/1.2.5/cake/libs/model/
>> datasources/dbo_source.php, line 525]
>> 
>> Query: SELECT COUNT(*) AS `count` FROM `campaigns` AS `Campaign` LEFT
>> JOIN `user_campaigns` AS `UserCampaign` ON (`Campaign`.`id` =
>> `UserCampaign`.`id`) WHERE `User`.`parent_id` = 204
>> 
>> Query: SELECT `Campaign`.`id`, `Campaign`.`name`,
>> `Campaign`.`description`, `Campaign`.`active` FROM `campaigns` AS
>> `Campaign` LEFT JOIN `user_campaigns` AS `UserCampaign` ON
>> (`Campaign`.`id` = `UserCampaign`.`id`) WHERE `User`.`parent_id` = 204
>> ORDER BY `Campaign`.`id` asc LIMIT 20
>> 
>> The real problem is : is it possible with Cake to filter a model with
>> a condition under a related model, and how to do that?
>> 
>> On Dec 26, 5:15 pm, John Andersen  wrote:
>> 
>>> Try to just specify:
>> 
>>> $this->Campaign->recursive = 3;
>>> $filter = array('User.parent_id = ' => 204); /* Changed this */
>>> $campaigns = $this->paginate(null, $filter);
>> 
>>> Enjoy,
>>>John
>> 
>>> On Dec 19, 3:43 am,thomaus wrote:
>> 
>>>> Hi,
>> 
>>>> I have to do a 2nd order filter por pagination.
>> 
>>>> My pagination var:
>> 
>>>> var $paginate = array(
>>>> 'limit' => 10,
>>>> 'fields' => array('Campaign.id', 'Campaign.name',
>>>> 'Campaign.description'),
>>>> 'order' => array(
>>>> 'Campaign.id' => 'asc'),
>>>> );
>> 
>>>> My controller function:
>> 
>>>> $this->Campaign->recursive = 2;
>>>> $filter = array('UserCampaign.id = ' => 2);
>>>> $campaigns = $this->paginate(null, $filter);
>>>> pr($campaigns);
>> 
>>>> This works great and outputs this:
>> 
>>>> Array
>>>> (
>>>> [0] => Array
>>>> (
>>>> [Campaign] => Array
>>>> (
>>>> [id] => 2
>>>> [name] => Newsletter
>>>> [description] => Newsletter campaign
>>>> )
>> 
>>>> [UserCampaign] => Array
>>>> (
>>>> [id] => 2
>>>> [user_id] => 204
>>>> [campaign_id] => 2
>>>> [User] => Array
>>>> (
>>>> [id] => 204
>>>> [parent_id] => 0
>>>> [username] => barça
>>>> [fname] => Thomas
>>>&

Re: cakephp foreach

2010-01-08 Thread Jeremy Burns
It works just as in straightforward php:

foreach ($array as $key):
echo $key;
endforeach;

On 8 Jan 2010, at 08:01, Mann da wrote:

> i want help about foreach in cakephp,
> 
> thanxs
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Subdomains

2010-01-07 Thread Jeremy Burns
My hosting company do allow me to create subdomains and point them to different 
directories. I have created both, but when I go to subdomain.[mydomain].com I 
get:

Error 500 - Internal server error

An internal server error has occured!
Please try again later.

I figured this might have something to with .htaccess or something - an area I 
am hideously bad at.

On 7 Jan 2010, at 17:18, Juan Luis Baptiste wrote:

> On Thu, Jan 7, 2010 at 9:44 AM, Jeremy Burns  wrote:
>> So if its running on a shared hosting package that doesn't allow
>> virtual hosts I can't do this?
>> 
> 
> If your hosting company doesn't allow you to create different
> subdomains and point them to different directories then probably not.
> You could also put the mantis site in another machine and point the
> subdomain in your DNS servers to that machine.
> 
> 
> Juancho
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Subdomains

2010-01-07 Thread Jeremy Burns
So if its running on a shared hosting package that doesn't allow
virtual hosts I can't do this?

On Jan 7, 2:35 pm, Juan Luis Baptiste  wrote:
> On Thu, Jan 7, 2010 at 9:31 AM, Jeremy Burns  wrote:
> > I have a site that runs CakePHP (accessed viawww.[domain].com). I now
> > want to install Mantis bug tracker on a subdomain on the same site. So
> > if I type mantisbt.[domain].com it takes me to Mantis rather than to
> > the normal web root - and therefore does not fire up the Cake site.
> > What settings do I need to change to make this happen - if it is
> > possible? Or is there a better way of doing this?.
>
> You need to configure virtual hosts in your web server for this.
>
> Juancho
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Subdomains

2010-01-07 Thread Jeremy Burns
I have a site that runs CakePHP (accessed via www.[domain].com). I now
want to install Mantis bug tracker on a subdomain on the same site. So
if I type mantisbt.[domain].com it takes me to Mantis rather than to
the normal web root - and therefore does not fire up the Cake site.
What settings do I need to change to make this happen - if it is
possible? Or is there a better way of doing this?.
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: setFlash() appending a "1"

2010-01-06 Thread Jeremy Burns
How are you setting and displaying the flash value? Consider both an
instruction, so if you do something like if($this->Session->flash());
you'll get both the message and a 1 to indicate success. To set the
value, use $this->Session->setFlash();. To display it, use $this-
>Session->flash();.

On Jan 7, 5:40 am, Kerr  wrote:
> Hi all, I'm experiencing a really weird issue where the $session->setFlash() 
> method appends a single "1" character directly after the
>
> generated  tag.  I'm using an unmolested copy of CakePHP 1.2.5.
> I've looked all through the source in SessionComponent, CakeSession
> and SessionHelper and don't see anywhere where this could be
> happening. Has anyone else experienced a similar issue?
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2010-01-05 Thread Jeremy Burns
One more issue that has deflated my initial euphoria...

The results don't paginate. How can I rectify that?

On Jan 2, 4:53 am, Jeremy Burns  wrote:
> A success! Using your self created join code I arrived at this:
>
>       $results = $this->LocationType->find(
>          'all',
>          array(
>             'contain' => false,
>             'joins' => array(
>                array(
>                   'table' => 'locations',
>                   'type' => 'left',
>                   'alias' => 'Location',
>                   'foreignKey' => false,
>                   'conditions' => array('LocationType.id =
> Location.location_type_id')
>                )
>             ),
>             'fields' => array('LocationType.id', 'LocationType.name',
> 'COUNT(Location.id) as location_count'),
>             'group' => array('LocationType.id', 'LocationType.name'),
>          )
>       );
>
> ...which works. Still seams long handed to me though.
>
> On Jan 2, 4:49 am, Jeremy Burns  wrote:
>
>
>
> > I have changed my code slightly from:
>
> > $results = $this->LocationType->Location->find(
> > to
> > $results = $this->LocationType->find(
>
> > This does not error, but only produces the location_types that have
> > locations. Therefore the results are still incomplete.
>
> > On Jan 2, 4:45 am, Jeremy Burns  wrote:
>
> > > Hi John
>
> > > Thanks for this, but I still cannot get this to return the results I
> > > need. I note that in your example the 'parent' is the author and the
> > > child is the article. In my example the parent is the location_type
> > > and the child is the location. Your code would exist (and work) within
> > > the child (i.e. article or location) controller, whereas I need it to
> > > run in the parent (i.e author or location_type) controller. When I try
> > > to switch the code around I run into all sorts of errors. For example,
> > > if I use your unbinding and then binding method...
>
> > > $this->LocationType->unbindModel( array('hasMany' => array
> > > ('Location')));
> > > $this->LocationType->bindModel( array('hasOne' => array('Location')));
> > > $results = $this->LocationType->Location->find(
> > >         'all',
> > >         array(
> > >                 'contain' => array('Location'),
> > >                 'fields' => array('LocationType.id', 'LocationType.name', 
> > > 'COUNT
> > > (Location.id) as location_count'),
> > >                 'conditions' => array('Location.id' => array(1,2,3,4)),
> > >                 'group' => array('LocationType.id', 'LocationType.name'),
> > >         )
> > > );
>
> > > ...it triggers the error:
>
> > > Model "Location" is not associated with model "Location"
> > > ...which (by process of elimination) is triggered by the line:
>
> > > 'contain' => array('Location')
>
> > > Bizzarre.
>
> > > I also fiddled around with the self created join method with no
> > > success.
>
> > > It strikes me that you and I have put a lot of effort into delivering
> > > something extremely simple that appears to be a bug in the core code.
> > > Would you agree? If so (and there are no other suggestions
> > > forthcoming!) then i propose I raise a ticket.
>
> > > On Dec 30 2009, 10:15 am, John Andersen 
> > > wrote:
>
> > > > With the hasOne relationship, the query looks like:
> > > > [code]
> > > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > > > article_count FROM `authors` AS `Author` LEFT JOIN `articles` AS
> > > > `Article` ON (`Article`.`author_id` = `Author`.`id`) WHERE
> > > > `Author`.`id` IN (1, 2, 13) GROUP BY `Author`.`id`, `Author`.`name`
> > > > [/code]
>
> > > > With the hasMany relationship, the query looks like:
> > > > [code]
> > > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > > > article_count FROM `authors` AS `Author` WHERE `Author`.`id` IN (1, 2,
> > > > 13) GROUP BY `Autho

Re: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key).

2010-01-05 Thread Jeremy Burns
What you have here looks correct, except that your $belongsTo
definition in your State model looks wrong. Shouldn't that be a
$hasMany definition? That means that an Employee belongs to a State,
and a State has many Employees.

The drop down is displayed in a view and the contents of the drop down
are populated in the controller action that calls the view.

In the function (probably edit or add, I would guess) add these lines:

$states = $this->Employee->State->find('list');
$this->set(compact('states'));

compact can take more than one variable. So if you end up with more
than one drop down repeat the first line and add the new variable
(minus the $ sign) to the compact array, e.g. $this->set(compact
('states', 'countries'));

In your view, your drop down is created like this:
echo $form->input('state_id', array('empty' => true));

Cake will use the contents of the $state array to populate the drop
down, displaying the name of the state. The empty option means that
nothing is selected by default. Without it, your form will display the
first entry and assume that the user wants to select that one.

Hope that helps.


On Jan 4, 10:36 pm, Guran  wrote:
> I am a new baker and I am stuck in the dough. I am trying to insert a
> option/select drop down but cannot get the field I need to show in the
> drop down
> I have the following tables:
>
> CREATE TABLE IF NOT EXISTS `employees` (
>   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
>   `state_id` int(11) unsigned NOT NULL,
>   `name` varchar(50) NOT NULL,
>   `email` varchar(30) DEFAULT NULL,
>   PRIMARY KEY (`id`),
>   UNIQUE KEY `employees.state_id` (`state_id`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
>
> CREATE TABLE IF NOT EXISTS `states` (
>   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
>   `state` varchar(2) NOT NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ;
>
> INSERT INTO `states` (`id`, `state`) VALUES
> (1, 'AL'),
> (2, 'AR'),
> (3, 'AZ'),
> (4, 'CA'),
> (5, 'CO'),
> (6, 'CT'),
> (7, 'DC'),
> (8, 'DE');
>
> The following two models are generated through console tool cake bake
> model using the default options provided.
>
> class State extends AppModel {
>         var $name = 'State';
>         var $belongsTo = array(
>                 'Employee' => array(
>                         'className' => 'Employee',
>                         'foreignKey' => 'state_id',
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => ''
>                 )
>         );
>
> }
>
> class Employee extends AppModel {
>         var $name = 'Employee';
>         var $belongsTo = array(
>                 'State' => array(
>                         'className' => 'State',
>                         'foreignKey' => 'state_id',
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => ''
>                 )
>         );
>
> }
>
> I would like to show the "states.state" field but all I get is the
> "states.id" field in the dropdown. Where have I gone wrong?
>
> Any help is appreciated!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I use the email component?

2010-01-05 Thread Jeremy Burns
Here you go - this covers the basics. Using the component is actually
quite simple: 
http://www.jeremy-burns.co.uk/2009/12/cakephp-sending-email-using-the-email-component/


On Jan 5, 1:47 am, otisjs01  wrote:
> Hello,
>
> I am new to CakePHP and trying desperately to learn!
>
> My most recent struggle is with the Email Component.
>
> I have a contract. When I create the contract, I add a user. When I
> save the new contract...for the first time, I want to send an email to
> the user in that contract that allows them to click on a link back to
> the contract, and then accept or reject the contract.
>
> How do I send this email?
>
> The more details I can get, answer-wise, the better. Everything I have
> read out there is surprisingly confusing. Do I need to configure smtp
> settings? How do I grab the user in the contract after it has been
> saved and pass it and the link to the contract on to the email? How do
> I know if the email has been sent, without going and checking my email
> every single time?
>
> Here is the code I have in my contracts_controller.php for the email
> sending function: (A Contract belongsTo a User, and a User hasMany
> Contracts.)
>
> function _sendContractEmail($id) {
>         $this->Email->smtpOptions = array(
>         'port'=>'465',
>         'timeout'=>'30',
>         'host'=>'ssl://smtp.gmail.com',
>         'username'=>'username',
>         'password'=>'password'
>         );
>         $this->Email->delivery = 'smtp';
>         $User = $this->Contract->User->read(null,$id);
>         $this->Email->to = 'jerem...@jeremiahotis.com';
>         $this->Email->subject = '';
>         $this->Email->replyTo = 'no-re...@goodvaluation.com';
>         $this->Email->from = 'Jeremiah Oits
> ';
>         $this->Email->template = 'simple_message';
>         $this->Email->sendAs = 'html';
>         $this->set('User', $User);
>         $this->Email->_debug = true;
>         $this->Email->send('Test Email');
>         $this->redirect(array('controller'=>'contracts',
> 'action'=>'index'));
>     }
>
> Here is the code I have in my contracts_controller.php add() function:
>
> function add() {
>         if (!empty($this->data)) {
>             $this->Contract->create();
>             if ($this->Contract->save($this->data)) {
>                 $this->Session->setFlash(__('The Contract has been
> saved', true));
>                 $this->_sendContractEmail($this->Contract->User->id);
>             } else {
>                 $this->Session->setFlash(__('The Contract could not be
> saved. Please, try again.', true));
>             }
>
> And, this is at the top of my contracts_controller.php file after the
> $name and $helpers:
>
> var $components = array('Email');
>
> I guess I should point out that I was having trouble with the
> template, so to test it, I included the body of the email directly in
> the send(), and I specified the to email address rather than using a
> variable. Still...nothing! No error, no email.
>
> Any help would be greatly appreciated! I really have no idea what I am
> doing wrong!
>
> Thanks,
>
> Jeremiah

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to add a column to the table after it is baked.

2010-01-02 Thread Jeremy Burns
The first place to start is by setting the debug level. In app/config/
core.php find the line that looks like this:

Configure::write('debug', 2);

...and ensure the number is 1 or higher (2 is good). Then visit your
view again. When the debug level is 1 or higher, Cake refreshes its
model cache. It will read all of your tables again so it knows what
columns exist. This ought to then pull in your new column. When the
debug level is 2 you'll see a table at the foot of the page that shows
all of the queries that Cake runs. This is very useful stuff while
developing, but obviously unfriendly win production. In production
mode, set debug to 0.

You might also need to change your validation in the model related to
your new table, and perhaps the associations in $hasMany/$belongsTo,
if appropriate.

On Jan 2, 7:21 am, Robin Thomas  wrote:
> I created  a table and baked it. Everything was working fine.
>
>  After that I added one more column to the table. and modified
> the .ctp file(for add)  to include the new column.
>
> But when I save a new entry , the new column is not getting saved.
>
> How can I add a column to the table after it is baked without baking
> it again.?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2010-01-01 Thread Jeremy Burns
A success! Using your self created join code I arrived at this:

  $results = $this->LocationType->find(
 'all',
 array(
'contain' => false,
'joins' => array(
   array(
  'table' => 'locations',
  'type' => 'left',
  'alias' => 'Location',
  'foreignKey' => false,
  'conditions' => array('LocationType.id =
Location.location_type_id')
   )
),
'fields' => array('LocationType.id', 'LocationType.name',
'COUNT(Location.id) as location_count'),
'group' => array('LocationType.id', 'LocationType.name'),
 )
  );

...which works. Still seams long handed to me though.

On Jan 2, 4:49 am, Jeremy Burns  wrote:
> I have changed my code slightly from:
>
> $results = $this->LocationType->Location->find(
> to
> $results = $this->LocationType->find(
>
> This does not error, but only produces the location_types that have
> locations. Therefore the results are still incomplete.
>
> On Jan 2, 4:45 am, Jeremy Burns  wrote:
>
>
>
> > Hi John
>
> > Thanks for this, but I still cannot get this to return the results I
> > need. I note that in your example the 'parent' is the author and the
> > child is the article. In my example the parent is the location_type
> > and the child is the location. Your code would exist (and work) within
> > the child (i.e. article or location) controller, whereas I need it to
> > run in the parent (i.e author or location_type) controller. When I try
> > to switch the code around I run into all sorts of errors. For example,
> > if I use your unbinding and then binding method...
>
> > $this->LocationType->unbindModel( array('hasMany' => array
> > ('Location')));
> > $this->LocationType->bindModel( array('hasOne' => array('Location')));
> > $results = $this->LocationType->Location->find(
> >         'all',
> >         array(
> >                 'contain' => array('Location'),
> >                 'fields' => array('LocationType.id', 'LocationType.name', 
> > 'COUNT
> > (Location.id) as location_count'),
> >                 'conditions' => array('Location.id' => array(1,2,3,4)),
> >                 'group' => array('LocationType.id', 'LocationType.name'),
> >         )
> > );
>
> > ...it triggers the error:
>
> > Model "Location" is not associated with model "Location"
> > ...which (by process of elimination) is triggered by the line:
>
> > 'contain' => array('Location')
>
> > Bizzarre.
>
> > I also fiddled around with the self created join method with no
> > success.
>
> > It strikes me that you and I have put a lot of effort into delivering
> > something extremely simple that appears to be a bug in the core code.
> > Would you agree? If so (and there are no other suggestions
> > forthcoming!) then i propose I raise a ticket.
>
> > On Dec 30 2009, 10:15 am, John Andersen 
> > wrote:
>
> > > With the hasOne relationship, the query looks like:
> > > [code]
> > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > > article_count FROM `authors` AS `Author` LEFT JOIN `articles` AS
> > > `Article` ON (`Article`.`author_id` = `Author`.`id`) WHERE
> > > `Author`.`id` IN (1, 2, 13) GROUP BY `Author`.`id`, `Author`.`name`
> > > [/code]
>
> > > With the hasMany relationship, the query looks like:
> > > [code]
> > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > > article_count FROM `authors` AS `Author` WHERE `Author`.`id` IN (1, 2,
> > > 13) GROUP BY `Author`.`id`, `Author`.`name`
> > > [/code]
> > > Contain does not assist in creating a LEFT JOIN, which is why
> > > Article.id is an unknown column!
>
> > > As far as I remember, the issue is probably not in the Containable
> > > behaviour, but somewhere in DboSource, but I may be wrong here :)
>
> > > There is another way:
> > > 1) Set contain equal false.
> > > 2) Define the joins yourself, as in the example below:
> > > [code]
> > >       $results = $this->Ar

Re: Count column in index view

2010-01-01 Thread Jeremy Burns
I have changed my code slightly from:

$results = $this->LocationType->Location->find(
to
$results = $this->LocationType->find(

This does not error, but only produces the location_types that have
locations. Therefore the results are still incomplete.

On Jan 2, 4:45 am, Jeremy Burns  wrote:
> Hi John
>
> Thanks for this, but I still cannot get this to return the results I
> need. I note that in your example the 'parent' is the author and the
> child is the article. In my example the parent is the location_type
> and the child is the location. Your code would exist (and work) within
> the child (i.e. article or location) controller, whereas I need it to
> run in the parent (i.e author or location_type) controller. When I try
> to switch the code around I run into all sorts of errors. For example,
> if I use your unbinding and then binding method...
>
> $this->LocationType->unbindModel( array('hasMany' => array
> ('Location')));
> $this->LocationType->bindModel( array('hasOne' => array('Location')));
> $results = $this->LocationType->Location->find(
>         'all',
>         array(
>                 'contain' => array('Location'),
>                 'fields' => array('LocationType.id', 'LocationType.name', 
> 'COUNT
> (Location.id) as location_count'),
>                 'conditions' => array('Location.id' => array(1,2,3,4)),
>                 'group' => array('LocationType.id', 'LocationType.name'),
>         )
> );
>
> ...it triggers the error:
>
> Model "Location" is not associated with model "Location"
> ...which (by process of elimination) is triggered by the line:
>
> 'contain' => array('Location')
>
> Bizzarre.
>
> I also fiddled around with the self created join method with no
> success.
>
> It strikes me that you and I have put a lot of effort into delivering
> something extremely simple that appears to be a bug in the core code.
> Would you agree? If so (and there are no other suggestions
> forthcoming!) then i propose I raise a ticket.
>
> On Dec 30 2009, 10:15 am, John Andersen 
> wrote:
>
>
>
> > With the hasOne relationship, the query looks like:
> > [code]
> > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > article_count FROM `authors` AS `Author` LEFT JOIN `articles` AS
> > `Article` ON (`Article`.`author_id` = `Author`.`id`) WHERE
> > `Author`.`id` IN (1, 2, 13) GROUP BY `Author`.`id`, `Author`.`name`
> > [/code]
>
> > With the hasMany relationship, the query looks like:
> > [code]
> > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> > article_count FROM `authors` AS `Author` WHERE `Author`.`id` IN (1, 2,
> > 13) GROUP BY `Author`.`id`, `Author`.`name`
> > [/code]
> > Contain does not assist in creating a LEFT JOIN, which is why
> > Article.id is an unknown column!
>
> > As far as I remember, the issue is probably not in the Containable
> > behaviour, but somewhere in DboSource, but I may be wrong here :)
>
> > There is another way:
> > 1) Set contain equal false.
> > 2) Define the joins yourself, as in the example below:
> > [code]
> >       $results = $this->Article->Author->find(
> >          'all',
> >          array(
> >             'contain' => false,
> >             'joins' => array(
> >                array(
> >                   'table' => 'articles',
> >                   'type' => 'left',
> >                   'alias' => 'Article',
> >                   'foreignKey' => false,
> >                   'conditions' => array('Article.author_id =
> > Author.id')
> >                )
> >             ),
> >             'fields' => array('Author.id', 'Author.name', 'COUNT
> > (Article.id) as article_count'),
> >             'group' => array('Author.id', 'Author.name'),
> >          )
> >       );
> > [/code]
>
> > But that is also not very simple!
>
> > Will keep you updated, should I find a better solution! Enjoy,
> >    John
>
> > On Dec 30, 12:07 pm, Jeremy Burns  wrote:
>
> > > Thank you John - I will try this out. Strikes me as very odd that this
> > > is not much much simpler!
>
> > > On Dec 30, 10:0

Re: Count column in index view

2010-01-01 Thread Jeremy Burns
Hi John

Thanks for this, but I still cannot get this to return the results I
need. I note that in your example the 'parent' is the author and the
child is the article. In my example the parent is the location_type
and the child is the location. Your code would exist (and work) within
the child (i.e. article or location) controller, whereas I need it to
run in the parent (i.e author or location_type) controller. When I try
to switch the code around I run into all sorts of errors. For example,
if I use your unbinding and then binding method...

$this->LocationType->unbindModel( array('hasMany' => array
('Location')));
$this->LocationType->bindModel( array('hasOne' => array('Location')));
$results = $this->LocationType->Location->find(
'all',
array(
'contain' => array('Location'),
'fields' => array('LocationType.id', 'LocationType.name', 'COUNT
(Location.id) as location_count'),
'conditions' => array('Location.id' => array(1,2,3,4)),
'group' => array('LocationType.id', 'LocationType.name'),
)
);

...it triggers the error:

Model "Location" is not associated with model "Location"
...which (by process of elimination) is triggered by the line:

'contain' => array('Location')

Bizzarre.

I also fiddled around with the self created join method with no
success.

It strikes me that you and I have put a lot of effort into delivering
something extremely simple that appears to be a bug in the core code.
Would you agree? If so (and there are no other suggestions
forthcoming!) then i propose I raise a ticket.


On Dec 30 2009, 10:15 am, John Andersen 
wrote:
> With the hasOne relationship, the query looks like:
> [code]
> SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> article_count FROM `authors` AS `Author` LEFT JOIN `articles` AS
> `Article` ON (`Article`.`author_id` = `Author`.`id`) WHERE
> `Author`.`id` IN (1, 2, 13) GROUP BY `Author`.`id`, `Author`.`name`
> [/code]
>
> With the hasMany relationship, the query looks like:
> [code]
> SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as
> article_count FROM `authors` AS `Author` WHERE `Author`.`id` IN (1, 2,
> 13) GROUP BY `Author`.`id`, `Author`.`name`
> [/code]
> Contain does not assist in creating a LEFT JOIN, which is why
> Article.id is an unknown column!
>
> As far as I remember, the issue is probably not in the Containable
> behaviour, but somewhere in DboSource, but I may be wrong here :)
>
> There is another way:
> 1) Set contain equal false.
> 2) Define the joins yourself, as in the example below:
> [code]
>       $results = $this->Article->Author->find(
>          'all',
>          array(
>             'contain' => false,
>             'joins' => array(
>                array(
>                   'table' => 'articles',
>                   'type' => 'left',
>                   'alias' => 'Article',
>                   'foreignKey' => false,
>                   'conditions' => array('Article.author_id =
> Author.id')
>                )
>             ),
>             'fields' => array('Author.id', 'Author.name', 'COUNT
> (Article.id) as article_count'),
>             'group' => array('Author.id', 'Author.name'),
>          )
>       );
> [/code]
>
> But that is also not very simple!
>
> Will keep you updated, should I find a better solution! Enjoy,
>    John
>
> On Dec 30, 12:07 pm, Jeremy Burns  wrote:
>
>
>
> > Thank you John - I will try this out. Strikes me as very odd that this
> > is not much much simpler!
>
> > On Dec 30, 10:05 am, John Andersen  wrote:
>
> > > Hi Jeremy,
>
> > > Seems like Contain can't find out to make a join when there is a
> > > hasMany relationship between the Author and the Article models. I made
> > > changes to Example A, so that Contain makes a LEFT JOIN, which
> > > includes Authors with no Articles :)
>
> > > 1) Unbind the hasMany relationship.
> > > 2) Bind a hasOne relationship.
> > > 3) Make the find on the Author model - I have include two author ids
> > > with articles and one (13) without articles.
> > > [code]
> > >       $this->Article->Author->unbindModel( array('hasMany' => array
> > > ('Article&

Re: $this->Session->setFlash();

2010-01-01 Thread Jeremy Burns
Hi Dave

Here's how you can do it:

$this->Session->setFlash(__('Your message.', true), true, array
('class' => 'yourClass'));

On Jan 2, 2:35 am, "Dave"  wrote:
> I was wondering is there a way to add a class to the session from the
> controller?
>
> The setflash as far as i can see is used for alerting user after a save
> attempt so
>
> $this->Session->setFlash(__('Information Updated.', true));
>
> or
>
> $this->Session->setFlash(__('Error! Please try again.', true));
>
> So the idea would be for the success message add a class so the message text
> is green if failed text is red.
>
> Any way this can be done?
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-30 Thread Jeremy Burns
Thank you John - I will try this out. Strikes me as very odd that this
is not much much simpler!

On Dec 30, 10:05 am, John Andersen  wrote:
> Hi Jeremy,
>
> Seems like Contain can't find out to make a join when there is a
> hasMany relationship between the Author and the Article models. I made
> changes to Example A, so that Contain makes a LEFT JOIN, which
> includes Authors with no Articles :)
>
> 1) Unbind the hasMany relationship.
> 2) Bind a hasOne relationship.
> 3) Make the find on the Author model - I have include two author ids
> with articles and one (13) without articles.
> [code]
>       $this->Article->Author->unbindModel( array('hasMany' => array
> ('Article')));
>       $this->Article->Author->bindModel( array('hasOne' => array
> ('Article')));
>       $results = $this->Article->Author->find(
>          'all',
>          array(
>             'contain' => array('Article'),
>             'fields' => array('Author.id', 'Author.name', 'COUNT
> (Article.id) as article_count'),
>             'conditions' => array('Author.id' => array(1,2,13)),
>             'group' => array('Author.id', 'Author.name'),
>          )
>       );
>       debug($results);
> [/code]
>
> The result is:
> [result]
> 28871\controllers\articles_controller.php (line 48)
> Array
> (
>     [0] => Array
>         (
>             [Author] => Array
>                 (
>                     [id] => 1
>                     [name] => Hans Christian Andersen
>                 )
>             [0] => Array
>                 (
>                     [article_count] => 19
>                 )
>         )
>     [1] => Array
>         (
>             [Author] => Array
>                 (
>                     [id] => 2
>                     [name] => Terry Prattchet
>                 )
>             [0] => Array
>                 (
>                     [article_count] => 19
>                 )
>         )
>     [2] => Array
>         (
>             [Author] => Array
>                 (
>                     [id] => 13
>                     [name] => Test
>                 )
>             [0] => Array
>                 (
>                     [article_count] => 0
>                 )
>         )
> )
> [/result]
>
> Hope this helps you on the way,
>    John
>
> On Dec 30, 6:52 am, Jeremy Burns  wrote:
>
>
>
> > Thanks John. Option B does indeed work - sort of! It returns a list of
> > location types with a count of their locations, but only where there
> > is a location. In other words, it does not give me the location types
> > that do not have have any locations.
>
> > Any more ideas - anyone?
>
> > On Dec 29, 12:35 pm, John Andersen  wrote:
>
> > > A correction, example A gives the author with all the articles, but
> > > the article count is 1 (one) - so no luck using that!
> > > Enjoy,
> > >    John
> > > [snip]

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-29 Thread Jeremy Burns
Thanks John. Option B does indeed work - sort of! It returns a list of
location types with a count of their locations, but only where there
is a location. In other words, it does not give me the location types
that do not have have any locations.

Any more ideas - anyone?

On Dec 29, 12:35 pm, John Andersen  wrote:
> A correction, example A gives the author with all the articles, but
> the article count is 1 (one) - so no luck using that!
> Enjoy,
>    John
> [snip]

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-29 Thread Jeremy Burns
Hi John - thanks for the reply. No luck, I'm afraid - I get the same
result.

I have simplified my example so I can focus in on what's not right:

$results = $this->LocationType->find(
'all',
array(
'recursive' => 2,
'contain' => array(
'Location' => array(
'fields' => array(
'id'
)
)
),
'fields' => array(
'LocationType.id',
'LocationType.name',
'COUNT(Location.id) as location_count'
),
'group' => array(
'LocationType.id',
'LocationType.name'
),
'order' => 'LocationType.lft'
)
);

If I omit the COUNT field, I get an array that includes Locations
where necessary. When I include the COUNT field I get an error:
Unknown column 'Location.id' in 'field list'. The SQL that is being
run is:

SELECT `LocationType`.`id`, `LocationType`.`name`, COUNT
(`Location`.`id`) as location_count FROM `location_types` AS
`LocationType`   WHERE 1 = 1  GROUP BY `LocationType`.`id`,
`LocationType`.`name`  ORDER BY `LocationType`.`lft` ASC

As you can see, the locations table is not in the SQL even though they
are connected in the database, in the model and on the contain
statement.

I have torn almost all of the hair I had left trying to crack what
should be a no brainer. Any more help please?

On Dec 29, 9:43 am, John Andersen  wrote:
> Ok, I will give it a try :)
>
> The first thing I observe is that the group statement does not include
> all the non-grouped columns, which it should, like:
> 'group' => array(
>    'LocationType.id',
>    'LocationType.name',
>    'LocationType.parent_id',
>    'ParentLocationType.id',
>    'ParentLocationType.name'
> ),
>
> Please try it out, enjoy,
>    John
>
> On Dec 23, 8:01 am, Jeremy Burns  wrote:
>
>
>
> > I have progressed a little with this, but am still struggling. I seem
> > to get hung up on the simplest of things with CakePHP, which is so
> > frustrating. I am prepared to be humiliated with an equally simple
> > answer to my problem.
>
> > I have a table called location_types with acts as a tree (with a self
> > join on id => parent_id). I have a $belongsTo table called locations,
> > which is joined to location_types on locations.location_type_id.
>
> > I want my location types index view to have a column that shows the
> > number of locations within the location type for that row.
>
> > Here is some sample code (that doesn't work):
>
> >         $this->paginate['LocationType'] = array(
> >                 'contain' => array(
> >                         'ParentLocationType' => array(
> >                                 'fields' => array(
> >                                         'id',
> >                                         'name'
> >                                 )
> >                         ),
> >                         'Location' => array(
> >                                 'fields' => array(
> >                                         'id',
> >                                         'location_type_id'
> >                                 )
> >                         )
> >                 ),
> >                 'fields' => array(
> >                         'LocationType.id',
> >                         'LocationType.name',
> >                         'LocationType.parent_id',
> >                         'ParentLocationType.id',
> >                         'ParentLocationType.name',
> >                         'COUNT(LocationType.id) AS countLocation'
> >                 ),
> >                 'group' => array(
> >                         'LocationType.id'
> >                 ),
> >                 'order' => array ('LocationType.lft' => 'asc')
> >         );
>
> >         $locationTypes = $this->paginate('LocationType');
>
> >         $this->set('locationTypes', $locationTypes);
>
> > Al

Re: Count column in index view

2009-12-29 Thread Jeremy Burns
Any takers for this please?

On Dec 23, 6:01 am, Jeremy Burns  wrote:
> I have progressed a little with this, but am still struggling. I seem
> to get hung up on the simplest of things with CakePHP, which is so
> frustrating. I am prepared to be humiliated with an equally simple
> answer to my problem.
>
> I have a table called location_types with acts as a tree (with a self
> join on id => parent_id). I have a $belongsTo table called locations,
> which is joined to location_types on locations.location_type_id.
>
> I want my location types index view to have a column that shows the
> number of locations within the location type for that row.
>
> Here is some sample code (that doesn't work):
>
>         $this->paginate['LocationType'] = array(
>                 'contain' => array(
>                         'ParentLocationType' => array(
>                                 'fields' => array(
>                                         'id',
>                                         'name'
>                                 )
>                         ),
>                         'Location' => array(
>                                 'fields' => array(
>                                         'id',
>                                         'location_type_id'
>                                 )
>                         )
>                 ),
>                 'fields' => array(
>                         'LocationType.id',
>                         'LocationType.name',
>                         'LocationType.parent_id',
>                         'ParentLocationType.id',
>                         'ParentLocationType.name',
>                         'COUNT(LocationType.id) AS countLocation'
>                 ),
>                 'group' => array(
>                         'LocationType.id'
>                 ),
>                 'order' => array ('LocationType.lft' => 'asc')
>         );
>
>         $locationTypes = $this->paginate('LocationType');
>
>         $this->set('locationTypes', $locationTypes);
>
> Although I am including the Location model in my contain statement it
> won't recognise COUNT(Location.id).  I notice that the SQL that Cake
> outputs does not include the locations table, which is clearly why
> COUNT(Location.id) is not recognised. I have experimented with various
> permutations by changing the group array and the field inside the COUNT
> () function, but I cannot get the result I am looking for.
>
> What am I doing wrong, please?
>
> On Dec 22, 11:04 am, Jeremy Burns  wrote:
>
>
>
> > Jamal - I really appreciate your reply - thank you.
>
> > This approach might well work, but I am sure there must be a simpler
> > way. I want to make the database do as little work as possible. In
> > plain old SQL I can do this:
>
> > SELECT a.id, a.name
> > count(b.id) as subCount
> > from tablea a
> > left join tableb b
> > on (b.type_id = a.id)
> > group by (a.id)
>
> > ...which returns me all of the rows in tablea with an extra column
> > that shows me the count of rows in tableb that have the type_id in the
> > row. One query and bosh I have my results with the count.
>
> > How do I do this in Cake?
>
> > On Dec 22, 9:13 am, Jamal Aziz  wrote:
>
> > > Hi Jeremy,
>
> > > I think you can do that in your model with afterFind callback. For
> > > example:
>
> > > class MyModel extends AppModel{
> > >         var $actsAs = array('Tree');
>
> > >         function afterFind($results, $primary){
> > >                 // for multiple result
> > >                 if(is_array($results)){
> > >                         if(is_array($results[0])){
> > >                                 foreach($results as $key => $val){
> > >                                         
> > > $results[$key][$this->alias]['childCount'] = $this->childCount
> > > ($results[$key][$this->alias][$this->primaryKey]);
> > >                                 }
> > >                         } else { // for single result
> > >                                 $results[$this->alias]['childCount'] = 
> > > $this->childCount($results
> > > [$key][$this->alias][$this->primaryKey]);
> > >                         }
> > >                 }
> > >     }
>
> > > }
>
> > > Note: I am not test this code myself.
>
> > > Hope this help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Adaptive pagination

2009-12-23 Thread Jeremy Burns
This isn't a full answer but will hopefully help your thinking.

You could build a custom element that includes some logic around the
current page, which is reached via $paginator->current(). You could
then build links to the previous (say) five pages and the next five
pages, with some logic to make sure you don't go past the first or
last page. Then you can prefix this with links to pages 1 and 2, and
suffixed by the penultimate and last page.

The $paginator->numbers() function can take a 'modulus' option that
determines how many pages to show either side of the current page,
which will sort that part out for you;

echo $paginator->numbers(array('modulus' => 4, 'separator' => '|'));

I notice that although the document says modulus determines how many
pages to show either side of the current page it is actually the total
number of pages.

Here's a rough attempt for you. This doesn't include any logic around
$paginator->current(), but I am sure you can weave that in. Place this
in a file called pagination.ctp in views/elements and drop it into a
view

options(array('update' => 'content', 'indicator' =>
'working'));

echo '';

echo $paginator->first('<<');
echo ' ';
echo $paginator->prev('<');
echo ' ';

echo $paginator->numbers(array('modulus' => 4, 'separator' => ' 
'));

echo ' ';
echo $paginator->next('>');
echo ' ';
echo $paginator->last('>>');

echo  '';

?>

I hope that helps a bit.

On Dec 23, 6:37 pm, NeoWebTech  wrote:
> Hello!
>
> I want to create a pagination for a huge/large number of items. But,
> the default pagination component is not good when the number of pages
> increases. So, I want to display like the following
>
> « Previous 1 2 … 5 6 7 8 9 10 11 12 13 … 2789 2790 Next »
>
> Please, let me know if there is any plug-in/code available.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-22 Thread Jeremy Burns
I have progressed a little with this, but am still struggling. I seem
to get hung up on the simplest of things with CakePHP, which is so
frustrating. I am prepared to be humiliated with an equally simple
answer to my problem.

I have a table called location_types with acts as a tree (with a self
join on id => parent_id). I have a $belongsTo table called locations,
which is joined to location_types on locations.location_type_id.

I want my location types index view to have a column that shows the
number of locations within the location type for that row.

Here is some sample code (that doesn't work):

$this->paginate['LocationType'] = array(
'contain' => array(
'ParentLocationType' => array(
'fields' => array(
'id',
'name'
)
),
'Location' => array(
'fields' => array(
'id',
'location_type_id'
)
)
),
'fields' => array(
'LocationType.id',
'LocationType.name',
'LocationType.parent_id',
'ParentLocationType.id',
'ParentLocationType.name',
'COUNT(LocationType.id) AS countLocation'
),
'group' => array(
'LocationType.id'
),
'order' => array ('LocationType.lft' => 'asc')
);

$locationTypes = $this->paginate('LocationType');

$this->set('locationTypes', $locationTypes);

Although I am including the Location model in my contain statement it
won't recognise COUNT(Location.id).  I notice that the SQL that Cake
outputs does not include the locations table, which is clearly why
COUNT(Location.id) is not recognised. I have experimented with various
permutations by changing the group array and the field inside the COUNT
() function, but I cannot get the result I am looking for.

What am I doing wrong, please?


On Dec 22, 11:04 am, Jeremy Burns  wrote:
> Jamal - I really appreciate your reply - thank you.
>
> This approach might well work, but I am sure there must be a simpler
> way. I want to make the database do as little work as possible. In
> plain old SQL I can do this:
>
> SELECT a.id, a.name
> count(b.id) as subCount
> from tablea a
> left join tableb b
> on (b.type_id = a.id)
> group by (a.id)
>
> ...which returns me all of the rows in tablea with an extra column
> that shows me the count of rows in tableb that have the type_id in the
> row. One query and bosh I have my results with the count.
>
> How do I do this in Cake?
>
> On Dec 22, 9:13 am, Jamal Aziz  wrote:
>
>
>
> > Hi Jeremy,
>
> > I think you can do that in your model with afterFind callback. For
> > example:
>
> > class MyModel extends AppModel{
> >         var $actsAs = array('Tree');
>
> >         function afterFind($results, $primary){
> >                 // for multiple result
> >                 if(is_array($results)){
> >                         if(is_array($results[0])){
> >                                 foreach($results as $key => $val){
> >                                         
> > $results[$key][$this->alias]['childCount'] = $this->childCount
> > ($results[$key][$this->alias][$this->primaryKey]);
> >                                 }
> >                         } else { // for single result
> >                                 $results[$this->alias]['childCount'] = 
> > $this->childCount($results
> > [$key][$this->alias][$this->primaryKey]);
> >                         }
> >                 }
> >     }
>
> > }
>
> > Note: I am not test this code myself.
>
> > Hope this help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-22 Thread Jeremy Burns
Jamal - I really appreciate your reply - thank you.

This approach might well work, but I am sure there must be a simpler
way. I want to make the database do as little work as possible. In
plain old SQL I can do this:

SELECT a.id, a.name
count(b.id) as subCount
from tablea a
left join tableb b
on (b.type_id = a.id)
group by (a.id)

...which returns me all of the rows in tablea with an extra column
that shows me the count of rows in tableb that have the type_id in the
row. One query and bosh I have my results with the count.

How do I do this in Cake?

On Dec 22, 9:13 am, Jamal Aziz  wrote:
> Hi Jeremy,
>
> I think you can do that in your model with afterFind callback. For
> example:
>
> class MyModel extends AppModel{
>         var $actsAs = array('Tree');
>
>         function afterFind($results, $primary){
>                 // for multiple result
>                 if(is_array($results)){
>                         if(is_array($results[0])){
>                                 foreach($results as $key => $val){
>                                         
> $results[$key][$this->alias]['childCount'] = $this->childCount
> ($results[$key][$this->alias][$this->primaryKey]);
>                                 }
>                         } else { // for single result
>                                 $results[$this->alias]['childCount'] = 
> $this->childCount($results
> [$key][$this->alias][$this->primaryKey]);
>                         }
>                 }
>     }
>
> }
>
> Note: I am not test this code myself.
>
> Hope this help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Count column in index view

2009-12-21 Thread Jeremy Burns
Ooh. Slightly apprehensive about pinging this group for any response,
but here goes.

I have started using counterCache, which solves the 'count' issue for
me. But I am still unclear on the best policy for adding aggregate
columns to paginated index views. I'd really appreciate some advice
please.

Happy Christmas.

On Dec 18, 10:33 am, Jeremy Burns  wrote:
> I have a model that uses the Tree behaviour, so it has a self join in
> the database (parent_id to id). In my index view I'd like to add a
> column that shows the count of direct children for 'this' row. I know
> I can get that number on a row by row basis using childCount, but how
> do I use that as part of my contain and pagination?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Count column in index view

2009-12-18 Thread Jeremy Burns
I have a model that uses the Tree behaviour, so it has a self join in
the database (parent_id to id). In my index view I'd like to add a
column that shows the count of direct children for 'this' row. I know
I can get that number on a row by row basis using childCount, but how
do I use that as part of my contain and pagination?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Not showing timestamp field

2009-12-17 Thread Jeremy Burns
Cake can handle this quite nicely (and invisibly too). Add a datetime
field called 'created' to your users table - and that's about it
really. Don't include it in the add form. Cake will detect it (make
sure you turn debugging to 2 at least once to make sure the model
cache is refreshed to include the new field) and timestamp it on
insert. The same applies for any table, not just users. You can also
add a datetime field called 'modified', which will be updated whenever
a record is changed.

See this page for more details: 
http://book.cakephp.org/view/330/Creating-the-Blog-Database

You can also pick up the id of the user creating or modifying a
record. For more details download this book (http://
www.pseudocoder.com/free-cakephp-book) from Matt Curry (which is a
good read anyway) and refer to page 20.


On Dec 17, 8:00 pm, Foroct  wrote:
> I am working on my first cakePHP site and came across an issue I cant
> quite figure out.  I have a registration form that a user fills out to
> become a member.  I want to capture the time they fill out the form so
> I added a date_added field in my database.  In the form the field
> would normally be called as so echo $form->input('date_added'); but I
> wanted it hidden so I did this echo $form->hidden('date_added'); which
> for some reason returns all 0's in the timestamp.  Then I was thinking
> that even if I did get it to pass the current time a user could just
> edit that to change their date added.
>
> So the question is, how do I pass a timestamp without the user seeing
> it and without the user being able to edit it?
>
> Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Routing with named parameters

2009-12-16 Thread Jeremy Burns
I was lazy (deep apologies!) and should have researched first. I have
solved it:

Router::connect('/controller/index/:parameter/*', array('controller'
=> 'controller', 'action' => 'index'), array('pass' => array
('parameter')));

...and then change my index function:

function index($parameter=null) {

..and then I can refer to $parameter

On Dec 17, 5:50 am, Jeremy Burns  wrote:
> In routes.php file, I have this entry:
>
> Router::connect('/:controller/add', array('action' => 'edit',
> 'origAction' => 'add'));
>
> ...which works great. It sends all add requests to the edit functions
> and sets a variable called origAction to add where appropriate (this
> is taken from Matt Curry's excellent book 
> -http://www.pseudocoder.com/free-cakephp-book/).
>
> However, this does not work if I pass in a named parameter. For
> example:
>
> /controller/add/parameter:4
>
> ...does not redirect to the edit function. Instead it tells me I need
> to create the add function in my controller.
>
> I haven't done much routing and this is probably quite
> straightforward. Can someone advise me how to adjust the routing so
> that this is directed to the edit function and  allows me to collect
> the named parameters there, please?
>
> I'd like to be able to do this:
>
> if (! empty($this->params['named']['parameter'])):
>
> ...in my edit function.
>
> Thank you.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Routing with named parameters

2009-12-16 Thread Jeremy Burns
In routes.php file, I have this entry:

Router::connect('/:controller/add', array('action' => 'edit',
'origAction' => 'add'));

...which works great. It sends all add requests to the edit functions
and sets a variable called origAction to add where appropriate (this
is taken from Matt Curry's excellent book - 
http://www.pseudocoder.com/free-cakephp-book/).

However, this does not work if I pass in a named parameter. For
example:

/controller/add/parameter:4

...does not redirect to the edit function. Instead it tells me I need
to create the add function in my controller.

I haven't done much routing and this is probably quite
straightforward. Can someone advise me how to adjust the routing so
that this is directed to the edit function and  allows me to collect
the named parameters there, please?

I'd like to be able to do this:

if (! empty($this->params['named']['parameter'])):

...in my edit function.

Thank you.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Blog Video

2009-12-16 Thread Jeremy Burns
I always had problems getting to these. By poking around in the page
source you'll  find where they are stored, for example:

http://www.archive.org/download/SettingUpTheCakephpConsoleOnnix/

They run quite well from there.

On Dec 16, 4:17 pm, Sam Sherlock  wrote:
> The screencasts can be problematic - embeding quicktime causes issues for
> me, they should be flv and downloadable mov - IMHO
>
> cakephp.org/*screencasts*
>
> - S
>
> 2009/12/16 crisuwork 
>
>
>
> > What Blog video?
>
> > On 13 Dez., 03:41, Dave Porter  wrote:
> > > Hi Everyone,
>
> > > The Blog video appears to be broken !
> > > Does anyone know if it can be downloaded from somewhere ?
>
> > > regards, Dave
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Migration Guide 1.2 to 1.3

2009-12-15 Thread Jeremy Burns
Thanks for that. What I was really aiming at is: when a production
version of 1.3 is released, is it a case of putting my app folder into
a fresh copy, or is it more complicated than that?

On Dec 16, 1:15 am, Miles J  wrote:
> Most of the 1.3 conventions are in place and migrated. There wont be a
> big difference between beta and final besides internal code.
>
> On Dec 15, 1:56 am, Jeremy Burns  wrote:
>
>
>
> > I have only worked with 1.2.5, so haven't done a migration yet. It
> > seems sensible to develop in 1.3 beta. If I migrate current
> > development work onto 1.3 beta, what will the migration to 1.3 final
> > be like? Is it worth it, or should I wait in order to avoid
> > duplication of effort?
>
> > On Dec 14, 5:55 pm, Miles J  wrote:
>
> > > Here you go.
>
> > >http://cakephp.lighthouseapp.com/projects/42648/13-migration-guide
>
> > > On Dec 14, 7:18 am, web  wrote:
>
> > > > Hey,
>
> > > > does anyone know where i can find the migraton guide?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Ajax form submit issue

2009-12-15 Thread Jeremy Burns
I have solved this issue (phew!).

In my edit function I redirect after a successful save. The redirect
command is as generated by Bake:

$this->redirect(array('action' => 'view', $this->Xxxx->id));

You'll notice that the controller is not set. Changing it to:

$this->redirect(array('controller' => '', 'action' => 'view',
$this->Xxxx->id));

...solves the issue.

I am surprised that more people don't run into this issue.

On Dec 14, 2:07 pm, Jeremy Burns  wrote:
> I have a problem that is driving me mad! I have a form that submits
> data to an edit action. It works fine when using $form->submit. I want
> to submit the form via Ajax. If I change the form submit button to the
> following:
>
> $ajax->submit (
>         'Save',
>         array(
>                 'div' => false,
>                 'url' => array(
>                         'controller' => 'xxx',
>                         'action' => 'edit',
>                         $id
>                 ),
>         'update' => 'divForm'
>         )
> );
>
> ...I get a stream of errors inside the div 'divForm' along these
> lines:
>
> Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
> line 411]
>
> Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
> line 133]
>
> Error:  Controller could not be found.
>
> Error:  Create the class Controller below in file: app/controllers/
> controller.php
>
>  class Controller extends AppController {
>
>         var $name = '';}
>
> ?>
>
> The errors are being thrown by dispatcher.php when it tries to find
> $this->params['controller']. That index is not in the params array.
>
> Does anyone have any idea what might be going astray here? I have seen
> some references to this issue elsewhere, but I have not located a
> resolution as yet.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Migration Guide 1.2 to 1.3

2009-12-15 Thread Jeremy Burns
I have only worked with 1.2.5, so haven't done a migration yet. It
seems sensible to develop in 1.3 beta. If I migrate current
development work onto 1.3 beta, what will the migration to 1.3 final
be like? Is it worth it, or should I wait in order to avoid
duplication of effort?

On Dec 14, 5:55 pm, Miles J  wrote:
> Here you go.
>
> http://cakephp.lighthouseapp.com/projects/42648/13-migration-guide
>
> On Dec 14, 7:18 am, web  wrote:
>
>
>
> > Hey,
>
> > does anyone know where i can find the migraton guide?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Ajax form submit issue

2009-12-14 Thread Jeremy Burns
I have a problem that is driving me mad! I have a form that submits
data to an edit action. It works fine when using $form->submit. I want
to submit the form via Ajax. If I change the form submit button to the
following:

$ajax->submit (
'Save',
array(
'div' => false,
'url' => array(
'controller' => 'xxx',
'action' => 'edit',
$id
),
'update' => 'divForm'
)
);

...I get a stream of errors inside the div 'divForm' along these
lines:

Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
line 411]

Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
line 133]

Error:  Controller could not be found.

Error:  Create the class Controller below in file: app/controllers/
controller.php



The errors are being thrown by dispatcher.php when it tries to find
$this->params['controller']. That index is not in the params array.

Does anyone have any idea what might be going astray here? I have seen
some references to this issue elsewhere, but I have not located a
resolution as yet.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Create .ctp file

2009-12-13 Thread Jeremy Burns
Start of the second paragraph:

http://book.cakephp.org/view/95/View-Templates

On Dec 13, 3:11 pm, 00Cake  wrote:
> Altight,
>
> Thank you guys...
>
> As I was telling if you don't know zhat is a .ctp extension file, you
> are not suppose to know that it is a html/php file but with .ctp
> extension.
>
> There is nothing logical in that and nothing explained...
>
> Thank you!
>
> On 11 déc, 02:05, Marcelo Andrade  wrote:
>
>
>
> > On Wed, Dec 9, 2009 at 7:19 PM, 00Cake  wrote:
> > > Hi All,
>
> > > I am starting discovering CakePHP and have try to do the blog tutorial
>
> > > Here is a trivial question:
>
> > > How to create a view ? How to create a .ctp file ??
>
> > There is "nothing" special about that.  Just open
> > notepad, gedit, kate or other plain text editor,
> > create html content and save the file with .ctp
> > extension.
>
> > > I have not find nothing about that!!
>
> > Ahn... have you tryied the CakePHP cookbook?
>
> >http://book.cakephp.org/view/26/View-Conventions
>
> > Best regards.
>
> > --
> > MARCELO DE F. ANDRADE
> > Belem, PA, Amazonia, Brazil
> > Linux User #221105

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Testing for Ajax

2009-12-10 Thread Jeremy Burns
Thank you - I don't suppose you have a simple example do you?

On Dec 11, 4:12 am, "Dr. Loboto"  wrote:
> Pass one URL to AJAX link as link url and other to it's options as
> AJAX action param.
>
> On Dec 10, 11:37 pm, Jeremy Burns  wrote:
>
>
>
> > Thank you, but that isn't working for me. I have a link that retrieves
> > some data and populates a div with an element. With Javascript
> > disabled I just get the contents of the element in an otherwise blank
> > screen. What I want to do is something like this:
>
> > If (javascript is enabled):
> > show this link
> > else
> > show another link
> > end if
>
> > So what I am looking for is a nifty little piece of code to do the "if
> > javascript is enabled" bit.
>
> > On Dec 10, 5:27 pm, "Dr. Loboto"  wrote:
>
> > > AJAX links and forms in Cake AJAX helper has fallback. If JS is not
> > > enabled links/forms will work as normal ones.
>
> > > On Dec 10, 6:58 pm, Jeremy Burns  wrote:
>
> > > > I want to use the Ajax helper when Javascript is enabled, but revert
> > > > to the plain old ordinary html helper when it is not. How can I do a
> > > > simple test to see if Javascript is enabled?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Testing for Ajax

2009-12-10 Thread Jeremy Burns
Thank you, but that isn't working for me. I have a link that retrieves
some data and populates a div with an element. With Javascript
disabled I just get the contents of the element in an otherwise blank
screen. What I want to do is something like this:

If (javascript is enabled):
show this link
else
show another link
end if

So what I am looking for is a nifty little piece of code to do the "if
javascript is enabled" bit.

On Dec 10, 5:27 pm, "Dr. Loboto"  wrote:
> AJAX links and forms in Cake AJAX helper has fallback. If JS is not
> enabled links/forms will work as normal ones.
>
> On Dec 10, 6:58 pm, Jeremy Burns  wrote:
>
>
>
> > I want to use the Ajax helper when Javascript is enabled, but revert
> > to the plain old ordinary html helper when it is not. How can I do a
> > simple test to see if Javascript is enabled?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Database field not reading or writing

2009-12-10 Thread Jeremy Burns
This might not be the answer, but the first I do when I get a db
related issue is set debug to 2 and try again. Sometimes cleaning the
caches like this resolves it, other times not.

On Dec 10, 2:42 pm, WhyNotSmile 
wrote:
> I've come across a really strange problem - or else I'm doing
> something really stupid.
>
> Basically, there is a field in one of my db tables which Cake just
> seems to be ignoring.  The field is in a table called 'Users', and is
> called 'recommendations'.
>
> When I do
>
> $this->User->findById($userid);
>
> it works fine, gets the user and all the information, apart from that
> one field, which it reads in as null.  It is definitely populated in
> the database.  Also, when I try to save to it, it just ignores me -
> doesn't reset it or anything, and no error messages, it just doesn't
> seem to do anything.
>
> This is driving me crazy!
>
> Has anyone come across something similar?  Is there maybe a setting or
> something in the database?
>
> Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Testing for Ajax

2009-12-10 Thread Jeremy Burns
I want to use the Ajax helper when Javascript is enabled, but revert
to the plain old ordinary html helper when it is not. How can I do a
simple test to see if Javascript is enabled?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Function exists

2009-12-09 Thread Jeremy Burns
Perfect - thank you John. My code is now:

function relations($id = null) {
if (method_exists ($this->modelClass,'relations')):
return $this->{$this->modelClass}->relations($id);
else:
return array();
endif;
}

On Dec 9, 11:26 am, John Andersen  wrote:
> Hi Jeremy
>
> Try to use the class/object method "method_exists" instead!
> Definition:
>
> method_exists -- Checks if the class method exists
>
> Description
> bool method_exists ( object object, string method_name)
> This function returns TRUE if the method given by method_name has been
> defined for the given object, FALSE otherwise.
>
> Enjoy,
>    John
>
> On Dec 9, 10:24 am, Jeremy Burns  wrote:
>
>
>
> > I want to call a function in a controller from my app_controller, but
> > want to check it exists first. I've fiddled around with
> > function_exists but can't get the syntax right.  This is the current
> > version of the code (which doesn't work):
>
> > function getRelations($id = null) {
> >         if (function_exists($this->{$this->modelClass}->relations())):
> >                 return $this->{$this->modelClass}->relations($id);
> >         else:
> >                 return array();
> >         endif;
>
> > }
>
> > Any ideas?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Function exists

2009-12-09 Thread Jeremy Burns
I want to call a function in a controller from my app_controller, but
want to check it exists first. I've fiddled around with
function_exists but can't get the syntax right.  This is the current
version of the code (which doesn't work):

function getRelations($id = null) {
if (function_exists($this->{$this->modelClass}->relations())):
return $this->{$this->modelClass}->relations($id);
else:
return array();
endif;
}

Any ideas?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Calling function within a controller

2009-12-08 Thread Jeremy Burns
Try:

$this->accept($id);

On Dec 8, 4:54 pm, WhyNotSmile  wrote:
> This may be really dumb, but I'm having trouble calling a function
> from within a controller.  Here's my set up:
>
> function accept_this($id = null) {
>    ... some bits of code ...
>    $result = accept($id);
>    ... processing of result ...
>
> }
>
> function accept($id = null) {
>    ... some code ...
>   return $result;    ($result has been set in the code part of this
> function)
>
> }
>
> When I try to run this, I get:
>
> Call to undefined function accept() in users_controller.php on line
> 356
>
> I don't know a whole lot about PHP functions - what am I doing wrong?
> I've checked obvious things like spelling.  I'd really like to be able
> to do this, because it allows me to reuse the bit of code in 'accept
> ()'.
>
> Thanks!
> Sharon

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Get natural SQL built by Model methods like find, save

2009-12-08 Thread Jeremy Burns
Do you have the following:

Configure::write('debug', 2);

in your /app/config/core.php file? If so, you ought to be seeing a
complete list of all SQL run at the foot of the page.

On Dec 8, 10:46 am, Manish Pithwa  wrote:
> Hi All,
>
> Sometimes we want to see what query CakePHP has built and executed for
> find and save methods if query fails or we don't get desired result.
> In find method we pass array for conditions, order and grouping etc.
> but how they were interpreted to build SQL is checked if we can see
> the SQL (select * from..., update table set field='value'... etc.) .
>
> So Please reply if anybody has to solution to get SQL for find and
> save method against array parameters passed to these.
>
> Thanks in advance!
>
> Manish Pithwa

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Permission denied page instead of login page

2009-12-07 Thread Jeremy Burns
I don't for a minute think I have the answer but would hate you to
feel too lonely! This is just a wild suggestion and I apologise if
it's totally wrong. Have you thought about changing your $this->Auth-
>loginAction to point to your "Permission denied" page? Then if
someone does something that needs a login, they'll be directed there.
Then you can have your true login links pointing to the login page.
Would that work?


On Dec 7, 3:08 pm, Jesse  wrote:
> Anyone have an idea for this? I really need to get this feature
> implemented.
>
> -Jesse
>
> On Dec 3, 2:04 pm, Jesse  wrote:
>
>
>
> > I have a pretty complex site setup with an administration section that
> > uses the Auth Component.
>
> > What I'm wondering is if it is possible to show a "Page Denied" page
> > instead of the Login page when a user tries to access a restricted
> > page.
>
> > I have my authorization set up by component. At the top of each
> > controller I have a beforeFilter function, and a $this->Auth->allow
> > for those actions that are available.
>
> > We have been tightening up the site and I'm sure this will cause some
> > bad links and I don't really want it to be any easier to find the
> > login screen for out website. As the site works now if someone tries
> > to access an action that's protected it redirects them to a "Login"
> > screen (I'm sure this is pretty standard for how most CakePHP sites
> > are set up).
>
> > Is there a way that I can have these redirected to a "access deneid"
> > page (/pages/access_denied) page instead of the login screen? I only
> > want the login screen to be displayed is someone types 
> > inhttp://homepage.com/admin
>
> > Here is my Auth stuff in the app_controller.php setup:
>
> > $this->Auth->loginAction = '/admin/users/login';
> > $this->Auth->loginRedirect = '/admin/users/login';
> > $this->Auth->logoutRedirect = '/';
> > $this->Auth->allow('display', );
> > $this->Auth->authorize = 'controller';
>
> > if (isset($this->params['admin'])) {
> >      $this->layout = 'admin_default';
>
> > }
>
> > function isAuthorized(){
> >      return true;
>
> > }

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Does redirect clear variables?

2009-12-07 Thread Jeremy Burns
My problem here was that I wanted to call a view, which depended on a
variable. As the redirect was clearing the variable, the display of
the view failed. I solved by (i) calling the view function [including
the $id of the record I wanted to view] and (ii) rendering the view.
By calling the function all variables needed by the view are prepared
by the the view function in the controller and rendering the view
displays it as expected. For full details see here:
http://www.jeremy-burns.co.uk/2009/12/cakephp-adding-a-delete-confirm-function/

On Dec 5, 9:16 am, Jeremy Burns  wrote:
> Thanks for the tip. That isn't in the docs (although it is in the
> API). Regrettably, that doesn't work either - it is clearing the
> variables. However, I solved this issue now (very simply and
> elegantly) and am in the process of writing up my solution, which I'll
> post back here).
>
> On Dec 4, 5:49 pm, Miles J  wrote:
>
>
>
> > Well of course, its another HTTP request and a complete new page load.
> > If you want toredirectit to another action, use setAction().
>
> > On Dec 4, 7:24 am, euromark  wrote:
>
> > > of course it does
>
> > > variables in a script are always for that "session" only
> > > aredirecteven to the same url starts the whole process again
>
> > > use session, file cache, or pass them with yourredirecturl
> > > (depending on the kind of information and how much it is)
>
> > > On 4 Dez., 13:59, Jeremy Burns  wrote:
>
> > > > I am setting a variable using $this->set('name', value), and then
> > > > redirecting the user to a different page using $this->redirect(array
> > > > ('action' => 'index'), null, true);. The variable $name is no longer
> > > > recognised. Does aredirectclearthe set variables? If so, how can I
> > > > pass the variable along to be used after aredirect?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Delete confirm

2009-12-07 Thread Jeremy Burns
I now have this working just as I wanted it. See here:
http://www.jeremy-burns.co.uk/2009/12/cakephp-adding-a-delete-confirm-function/

On Dec 1, 10:07 am, jburns  wrote:
> Thanks for the reply. I guess it is a tad unreasonable to expect two
> year old code to 'just work'! I just like stuff out of the box :-)
>
> I'll follow your suggestions and then rather than slavishly try and
> make this function I'll branch off my own way until I get something
> working. I'll post back my solution here.
>
> On Dec 1, 9:34 am, AD7six  wrote:
>
>
>
> > On 27 nov, 12:28, jburns  wrote:
>
> > > @AD7Six
>
> > > Apologies, but I am still struggling with this. I have deployed your
> > > code as is, with the following changes:
>
> > > I have removed this line:
> > > if (isset($this->params[CAKE_ADMIN]) && !$this->RequestHandler->isAjax
> > > ()) {
> > >             $this->layout = 'admin';
> > >         }
> > > ...because it errors and is not relevant to me.
>
> > > Same with this line:
> > > if ($this->javascripts) {
> > >             $this->set('javascripts', $this->javascripts);
> > >         }
>
> > > I am not using admin routing, so have changed references to
> > > admin_delete todelete.
>
> > > This line errors:
> > > $this->Security->__generateToken($this);
> > > ...but works if I change the double underscore to a single underscore.
>
> > > I have created the _generic folder and put the confirm_action view in
> > > it.
>
> > > I *think* I understand what is going on in the code. It picks up that
> > > I am calling thedeleteaction via a link (and therefore a GET). As
> > > 'delete' is in the $postActions array, I am directed to the
> > > _confirmAction function. This renders the confirm_action view, which
> > > contains a form that calls thedeleteaction via a POST. When I submit
> > > the form it ought to come back into app_controller and pass through to
> > > thedeleteaction. However, I am still being directed back to the
> > > confirm_action view.
>
> > > Stumped. I notice that it is calling Security->_generateToken. Should
> > > this be being picked up anywhere else? If not, what is its purpose?
>
> > > I appreciate your help. This is gnawing away at me and I can't work it
> > > through.
>
> > > Thanks.
>
> > Without seeing your exact code I|other people can't help much.
>
> > Yes, the core changed a little in the past 2 years, as did a few other
> > things. e.g. I personally don't use a _generic folder anymore since
> > you can just do $this->render('/elements/this_one'); - as can be seen
> > in the repo solution I linked to.
>
> > If you're being redirected to confirm_action in a loop the form token
> > that's generated 'manually' (see the form helper create function if
> > you want to see what else uses it) doesn't match what the security
> > component is expecting. Except for the period of time when I was
> > originally writing this technique - I haven't seen that happen. You'd
> > need to debug and find out why.
>
> > hth,
>
> > AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Noob having problems getting started.

2009-12-05 Thread Jeremy Burns
Your directory structure doesn't look right. The directory 'cakephp'
is effectively the root of your site. The files/folders within it
should be:
.htaccess
/app
/cake
/docs (optional, but useful)
index.php
/vendors

All of the files and folders that you create go in the /app folder.

If you follow this set up you'll get to your homepage at 
http://localhost/cakephp/.

May I make a suggestion? Why not create a folder in your web root call
todo, and then deploy the structure I outlined. Then you can get to
your site at http://localhost/todo/. When you deploy to live, you
simply move the entire contents of /todo to your web server's root and
it should all work nicely.


On Dec 5, 8:31 am, BearState  wrote:
> Hello,
>
> I have downloaded CakePHP,  Windows XP.
>
> I am referencing the book   "Beginning CakePHP" by David Golding.
>
> I have Apache on my staging server, but it has many things there, so I
> set up a  cakephp package as follows:
>
> /cakephp
>     cake
>     apps
>     todo
>         modules/item.php
>         controllers/items_controller.php
>
> I have worked my way through Chapter 3 and things are NOT going
> right.
>
> 1st Problem:
>
>      The display does not appear correct.   It is not tabular, but has
> colored and sized fonts.
>
> 2nd Problem:
>
>      http://localhost/cakephp/todo       brings up the page, not
> looking right as explained above
>
>      http://localhost/cakephp/todo/items              results in 404
> Not found error.
>
> If I go and fudge the routes.php   file and add
>
>      Router::connect('/', array('controller' => 'Items'));
>
> I can get a screen that has a form that would be used to add an item,
> but ...
>             when submit is clicked,    http://localhost/cakephp/todo/items/add
>                   is not found.
>
> The reference book doesn't provide a clue as to why it is failing.
>
> Any guidance would be appreciated.
>
> Thanks,

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Does redirect clear variables?

2009-12-05 Thread Jeremy Burns
Thanks for the tip. That isn't in the docs (although it is in the
API). Regrettably, that doesn't work either - it is clearing the
variables. However, I solved this issue now (very simply and
elegantly) and am in the process of writing up my solution, which I'll
post back here).

On Dec 4, 5:49 pm, Miles J  wrote:
> Well of course, its another HTTP request and a complete new page load.
> If you want to redirect it to another action, use setAction().
>
> On Dec 4, 7:24 am, euromark  wrote:
>
>
>
> > of course it does
>
> > variables in a script are always for that "session" only
> > a redirect even to the same url starts the whole process again
>
> > use session, file cache, or pass them with your redirect url
> > (depending on the kind of information and how much it is)
>
> > On 4 Dez., 13:59, Jeremy Burns  wrote:
>
> > > I am setting a variable using $this->set('name', value), and then
> > > redirecting the user to a different page using $this->redirect(array
> > > ('action' => 'index'), null, true);. The variable $name is no longer
> > > recognised. Does a redirect clear the set variables? If so, how can I
> > > pass the variable along to be used after a redirect?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Does redirect clear variables?

2009-12-04 Thread Jeremy Burns
I am setting a variable using $this->set('name', value), and then
redirecting the user to a different page using $this->redirect(array
('action' => 'index'), null, true);. The variable $name is no longer
recognised. Does a redirect clear the set variables? If so, how can I
pass the variable along to be used after a redirect?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: what does it mean to bake something

2009-12-03 Thread Jeremy Burns
Bake just gets you started really. If you follow the instructions in
the online guide you'll be able to create basic models, controllers
and views for the tables in your database. The results are pretty
good, but not what you'd want to go live with. If you are learning
your way around Cake it's a really good place to start. I'd recommend
doing all three for a couple of tables that are joined (are you
familiar with $hasMany and $belongsTo?) and then look at the results.

On Dec 3, 3:19 pm, "www.landed.at"  wrote:
> I thought it was just a term that was meaning a finished project, but
> the more I see I think it is actually some tool ?
>
> php is not compiled so I'm thinking its not a compiler as such, bit of
> a dumb question but it isnt really clear to a noob like me.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Delete confirm

2009-12-03 Thread Jeremy Burns
I thought it might be about time to jot down how I am implementing
this (based around AD7Six's code). I have got it working *pretty much*
as I want it, but still have a few questions. I never thought this
would be so tough! I readily acknowledge that I am stumbling in the
dark here at times.

First, I have amended my app_controller, adding:

$this->Security->blackHoleCallback = '_confirmAction';
$this->Security->requirePost('delete');

I am only really interested in trapping deletes at present, but can
soon resort to an array of actions later if needed. This stops a
delete request processing if it does not come from a POST. It's ideal
for me as the delete instruction comes from a link (and hence a GET).

Then I have my _confirmAction function:

function _confirmAction ($reason = null) {
if ($reason == 'post') {
$this->Security->_generateToken($this);
$this->redirect(array('action' => 'deleteConfirm', $this->params
['pass'][0]));
}
$code = 404;
if ($reason == 'login') {
$code = 401;
} else {
$this->Session->setFlash('Access Denied');
}
$this->redirect(null, $code, true);
}

This is called when a delete is attempted by anything other than a
POST. For my part, it safely redirects the user to the "deleteConfirm"
action. $this->params['pass'][0] refers back to $id passed in by the
delete link, and therefore contains the id of the record that is going
to be deleted.

Then I have my deleteConfirm action (it's in my app_controller so that
I don't have to propagate it throughout all of my controllers):

function deleteConfirm($id) {
$this->redirect(array('action' => 'view', $id, 'delete'));
}

You'll notice that I am redirecting the user to the view screen. I am
doing this because I want to present details of the record they are
going to delete rather than a reasonably anonymous screen. I am adding
an unnamed parameter - 'delete'. I'll explain that a bit more in a
second.

Here's where I stumble upon my first issue. I'd love to set a variable
called 'mode' to indicate what I am going to do in my 'view'. I have
tried $this-set('mode', 'delete'), but it seems to be cleared after
the redirect. Is this correct, or am I doing something wrong?

Back in my controller, I have amended my view function:

function view($id = null, $mode=null) {
$this->set('mode', empty($this->params['pass'][1]) ? 'view' : $this-
>params['pass'][1]);
...

Here I am inspecting the second passed parameter ($id first, then
$mode). If it is empty I am doing a straightforward view. Therefore,
the view renders without any reference to deleting. If, on the other
hand, $mode is not empty, I am doing something else. The only other
alternative at the moment is 'delete', so let's assume that's what's
happening. The view renders, but with some changes to reflect the fact
that I am deleting. This includes a health warning and a form to
perform the actual delete via a POST:

if ($mode == 'delete'):
echo $this->Html->tag('p', 'WARNING! You are about to delete the
following ' . $type . '. If you proceed, this delete cannot be
reversed.', array('class' => 'flashWarning'));
echo $this->Form->create(null, array('url' => array('action' =>
'delete', $id)));
echo $this->Form->input ($referer, array('type'  =>  'hidden',
'value' => $referer));
echo '';
echo $this->Html->tag('li', $this->Form->submit ('Yes - delete',
array('div' => false)));
echo $this->Html->tag('li', $this->Html->link ('No - cancel', 
array
('controller' => $referer)));
echo '';
echo $this->Form->end();
endif;

I've also added a 'cancel' link that returns the user to where they
came from using $this->referer(). The action on the form is 'delete'.
As it comes from a POST the security component does not block it. So
the delete action in app_controller triggers (again, only have it in
app_controller as it is very standard):

function delete($id) {
if ($this->{$this->modelClass}->del($id)) {
$this->Session->setFlash(__('The record was deleted.', true), 
true,
array('class' => 'flashSuccess'));
$this->set('mode', 'view');
$this->redirect(array('action' => 'index'), null, true);
}
...

Here is where I run into my next couple of problems.

First, again I'd like to set $mode back to 'view', so that my next
function knows that it is not doing a delete. The redirect *appears*
to reset it, so it's an unrecognised variable.

Second, I can use $this->referer() to send the user back to somewhere
meaningful (rather than just the index), but (i) if it is a view
screen the deleted record isn't there so it's meaningless and (Ii) it
still has the second parameter ('delete'). I *can* handle both of
these in the view, but it isn't very elegant.

It's been a long post! To sum up, this is sort of working but it is a
bit clunky. I 

Re: modifying baked sources

2009-12-03 Thread Jeremy Burns
I think my first suggestion is close to what you need, isn't it? What
I have done in the past is rename my controller to xcontroller, my
model to xmodel and my view folder xfolder. Then rebake, and then take
what I want out of my old (x-named) objects into the new ones.
Alternatively, once the new objects are baked, rename those with a y,
then take the x off of the old renamed objects and take what I want
out of the new (now named y) objects. Hope that makes some sort of
sense! Either way, you have a set of new objects and a set of old
objects and you are going to have to do some sort of compare and
merge.

On Dec 3, 9:00 am, Lorenzo Bettini  wrote:
> as for the manual merge I had in mind that one too; however, I was
> thinking of some way of having bake generate some classes, and I'd
> derive from them and redefine/add something; is it feasible?  In order
> to do this I should either have bake generate files/classes with a
> different name, or tell cake to use my derived classes; is it possible
> to do so?
>
> and concerning this other question:
> is bake documented in more details than it is
> here:http://book.cakephp.org/view/113/Code-Generation-with-Bake?
>
> thanks
>         Lore
>
>
>
>
>
> Jeremy Burns wrote:
> > I guess there are two approaches. 1. Rename the model/views/
> > controllers before you bake, then do a comparison and merge
> > afterwards. 2. Once you have the initial bake complete, just amend the
> > files rather than re-baking. This has the advantage of helping you
> > learn as well.
>
> > On Dec 2, 6:23 pm, Lorenzo Bettini  wrote:
> >> Hi
>
> >> If I create models, controllers and views with bake, and I modify those
> >> files, the next time I run bake they'll overwritten (say that I added
> >> some new fields that I "want to bake"); is there a general idiom to deal
> >> with that?
>
> >> thanks in advance
> >>         Lorenzo
>
> >> P.S. is bake documented in more details than it is 
> >> here:http://book.cakephp.org/view/113/Code-Generation-with-Bake?
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Any chance to get the ID of a new created record BEFORE I save it to the DB?

2009-12-03 Thread Jeremy Burns
I forgot to add...

If the insert of B fails, you can delete A because you know the id of
the most recently added row in A.

On Dec 3, 8:32 am, Jeremy Burns  wrote:
> Have you considered an approach where you save A and B independently
> (i.e. without worrying about the connecting ids), collecting the ids
> of both A and B (using $this->A->id immediately after save) and then
> doing a subsequent update?
>
> On Dec 3, 7:54 am, Quess  wrote:
>
>
>
> > @Miles J
> > Your idea won't work with mysql and id field as autoincrement (dunno
> > how with other db but i assume that can be the same).
> > If you have 100 rows with id from 1 to 100 and you will delete last 5
> > (from 96 to 100), then doing insert new rown you will get id 101, not
> > 96.
>
> > @DigitalDude
> > Please take a look athttp://blog.jamiedoris.com/geek/560/
>
> > Best Regards,
> > Miro
>
> > On Dec 3, 12:40 am, Miles J  wrote:
>
> > > Its impossible to get the ID for a row your about to save, until after
> > > you save it.
>
> > > The most you can do is do a query to select the last row in the table,
> > > then increment its ID by one.
>
> > > On Dec 2, 2:18 pm, Dave  wrote:
>
> > > > I think this would really help your situation
>
> > > >http://bakery.cakephp.org/articles/view/wizard-component-1-2-1
>
> > > > I have used it in the past and if you read the documentation thoroughly 
> > > > it
> > > > is very easy to implement.
>
> > > > On Wed, Dec 2, 2009 at 1:05 PM, DigitalDude 
> > > > wrote:
>
> > > > > Hey,
>
> > > > > I have a serious problem, and I need a hint from you guys to solve it!
>
> > > > > In one of my controller actions, I have the problem that I need to
> > > > > create some records , let's say A, B, and C.
>
> > > > > The problem is, that record A needs a field from record B, which is
> > > > > the ID of record B, and which I only can set when record A is saved,
> > > > > and B is saved. In model C I need some information from the new
> > > > > created models A and B, which I only have when model A and B are
> > > > > saved.
>
> > > > > As this has to do with a register-process for my app, I need to
> > > > > validate the data for all models. The problem is, that when model A
> > > > > passes validation, and get's saved (which is needed to save the other
> > > > > models) and model B fails, I have a "never used" record of model A in
> > > > > my database. I need to get around that, because that's like a worst
> > > > > case for me!
>
> > > > > I hope there's any chance to create a record, set this record with the
> > > > > data I get from my registration form, and use the data for the other
> > > > > records and save everything at the end of the action when every record
> > > > > validates!
>
> > > > > I know I can check a record for validation by setting the model data
> > > > > with
>
> > > > > $this->Model->set($this->data)
>
> > > > > and then
>
> > > > > if($this->Model->validates()) {
> > > > >    save the record(s)
> > > > > }
>
> > > > > But right now I'm only able to do this when I have an edit action and
> > > > > I set the Model to a specific record with like
>
> > > > > $this->Model->id = $id_from_get_parameter_or_so
>
> > > > > It would be VERY cool if there is a slight chance that I could create
> > > > > a new record with current auto-increment id from the database, use
> > > > > that id for my other models, and at the end when I created all needed
> > > > > records I'd check every record for validation and if every record is
> > > > > ok, they all get saved.
>
> > > > > If anyone knows how to achieve this, I would be very very happy!
>
> > > > > Cheers,
>
> > > > > DD
>
> > > > > P.S.:
>
> > > > > If needed, I can post the code of the whole RequestAction to see if
> > > > > maybe there's another solution to this...
>
> > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers
> > > > > with their CakePHP related questions.
>
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups
> > > > > "CakePHP" group.
> > > > > To post to this group, send email to cake-php@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > cake-php+unsubscr...@googlegroups.com > > > >  om>For more options, visit this group at
> > > > >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Any chance to get the ID of a new created record BEFORE I save it to the DB?

2009-12-03 Thread Jeremy Burns
Have you considered an approach where you save A and B independently
(i.e. without worrying about the connecting ids), collecting the ids
of both A and B (using $this->A->id immediately after save) and then
doing a subsequent update?

On Dec 3, 7:54 am, Quess  wrote:
> @Miles J
> Your idea won't work with mysql and id field as autoincrement (dunno
> how with other db but i assume that can be the same).
> If you have 100 rows with id from 1 to 100 and you will delete last 5
> (from 96 to 100), then doing insert new rown you will get id 101, not
> 96.
>
> @DigitalDude
> Please take a look athttp://blog.jamiedoris.com/geek/560/
>
> Best Regards,
> Miro
>
> On Dec 3, 12:40 am, Miles J  wrote:
>
>
>
> > Its impossible to get the ID for a row your about to save, until after
> > you save it.
>
> > The most you can do is do a query to select the last row in the table,
> > then increment its ID by one.
>
> > On Dec 2, 2:18 pm, Dave  wrote:
>
> > > I think this would really help your situation
>
> > >http://bakery.cakephp.org/articles/view/wizard-component-1-2-1
>
> > > I have used it in the past and if you read the documentation thoroughly it
> > > is very easy to implement.
>
> > > On Wed, Dec 2, 2009 at 1:05 PM, DigitalDude 
> > > wrote:
>
> > > > Hey,
>
> > > > I have a serious problem, and I need a hint from you guys to solve it!
>
> > > > In one of my controller actions, I have the problem that I need to
> > > > create some records , let's say A, B, and C.
>
> > > > The problem is, that record A needs a field from record B, which is
> > > > the ID of record B, and which I only can set when record A is saved,
> > > > and B is saved. In model C I need some information from the new
> > > > created models A and B, which I only have when model A and B are
> > > > saved.
>
> > > > As this has to do with a register-process for my app, I need to
> > > > validate the data for all models. The problem is, that when model A
> > > > passes validation, and get's saved (which is needed to save the other
> > > > models) and model B fails, I have a "never used" record of model A in
> > > > my database. I need to get around that, because that's like a worst
> > > > case for me!
>
> > > > I hope there's any chance to create a record, set this record with the
> > > > data I get from my registration form, and use the data for the other
> > > > records and save everything at the end of the action when every record
> > > > validates!
>
> > > > I know I can check a record for validation by setting the model data
> > > > with
>
> > > > $this->Model->set($this->data)
>
> > > > and then
>
> > > > if($this->Model->validates()) {
> > > >    save the record(s)
> > > > }
>
> > > > But right now I'm only able to do this when I have an edit action and
> > > > I set the Model to a specific record with like
>
> > > > $this->Model->id = $id_from_get_parameter_or_so
>
> > > > It would be VERY cool if there is a slight chance that I could create
> > > > a new record with current auto-increment id from the database, use
> > > > that id for my other models, and at the end when I created all needed
> > > > records I'd check every record for validation and if every record is
> > > > ok, they all get saved.
>
> > > > If anyone knows how to achieve this, I would be very very happy!
>
> > > > Cheers,
>
> > > > DD
>
> > > > P.S.:
>
> > > > If needed, I can post the code of the whole RequestAction to see if
> > > > maybe there's another solution to this...
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers
> > > > with their CakePHP related questions.
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "CakePHP" group.
> > > > To post to this group, send email to cake-php@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com > > >  om>For more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Help accessing array from HABTM relationship

2009-12-02 Thread Jeremy Burns
I have spread your array out so I can see its layout. I *think* you'd
need to do a foreach loop on users too.

On Dec 3, 12:02 am, Casmit  wrote:
> I have a table called Group that has a HABTM relationship to table
> Points.  Group also has a HABTM relationship to Users.  Groups_Points
> table manages this relationship.
>
> I can run a $this>Point>Group>findAll command and get an array that
> looks like this:
>
> Array ( [0] => Array ( [Group] => Array ( [id] => 1 [user_ID] => 1
> [name] => Dallas Photogs [pic1] => [created] => 2009-12-01 21:23:15
> [Moderate] => 0 ) [Point] => Array ( [0] => Array ( [id] => 1 [title]
> => Dallas, Texas [description] => dallas [user_ID] => 1 [type] => City
> [address] => 101 main st. dallas, tx [city] => dallas [state] => TX
> [zip] => 76010  [GroupsPoint] => Array ( [id] => 1 [group_id] => 1
> [point_id] => 1 [created] => 2009-12-02 14:36:10 [modified] =>
> 2009-12-02 14:36:10 ) ) ) [User] => Array ( [0] => Array ( [id] => 1
> [username] => John [email] => j...@gmail.com [password] =>
> 79467e27a472 [first_name] => John [last_name] => Smith  [created] =>
> 2009-11-24 23:15:16 [modified] => 2009-11-29 01:00:26 [GroupsUser] =>
> Array ( [id] => 1 [group_id] => 1 [user_id] => 1 [admin] => 1
> [created] => 2009-12-02 14:36:10 [modified] => 2009-12-02
> 14:36:10 ) ) ) ) )
>
> I can do a foreach command in the view i.e. $groups as $group and
> access Group.Name as $group['Group']['name'].
>
> What's the best way to access the User.name data in this array. $group
> ['User']['username'] results in index not found...I see it's nested
> one level deep.
>
> Thanks for the advice in advance!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to get two input fields in same line?

2009-12-02 Thread Jeremy Burns
You could also do this:

input('User.name', array('div' => false));?>

You could do your own surrounding div, then two inputs with div =>
false; in other words, take case of the divs yourself.


On Dec 3, 5:46 am, anand angadi  wrote:
> Hi,
> This may help you...
>
>  class="content">
>   
>     UserName :  
>     input('username',array('label'=>false)); ?>
> Password :  
>     input('password',array('label'=>false)); ?>
>   
> 
>
> Cheers:
> Anand
>
>
>
> On Thu, Dec 3, 2009 at 11:05 AM, cake  wrote:
> > Hi all
>
> > How can I get two input fields in same line in cakephp?
> > By default each input field are coming in seperate line.
> > How can we put a space and bring it in same line.
> > Please help..
>
> > Thanking You
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: modifying baked sources

2009-12-02 Thread Jeremy Burns
I guess there are two approaches. 1. Rename the model/views/
controllers before you bake, then do a comparison and merge
afterwards. 2. Once you have the initial bake complete, just amend the
files rather than re-baking. This has the advantage of helping you
learn as well.

On Dec 2, 6:23 pm, Lorenzo Bettini  wrote:
> Hi
>
> If I create models, controllers and views with bake, and I modify those
> files, the next time I run bake they'll overwritten (say that I added
> some new fields that I "want to bake"); is there a general idiom to deal
> with that?
>
> thanks in advance
>         Lorenzo
>
> P.S. is bake documented in more details than it is 
> here:http://book.cakephp.org/view/113/Code-Generation-with-Bake?
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Simple Multiple File upload

2009-11-17 Thread Jeremy Burns
Try this: 
http://bakery.cakephp.org/articles/view/file-upload-component-w-automagic-model-optional

Jeremy Burns
jeremybu...@me.com

On 17 Nov 2009, at 08:18, appel268576 wrote:

> Hi Cake Community.
> 
> I am busy developing an application and looking towards a solution /
> plugin that will help me upload files / images etc.
> 
> I have been banging my head searching for a decent tutorial that is
> well documented, is there anything that you can suggest and one that
> you have used before?
> 
> Regards
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Delete confirm

2009-11-16 Thread Jeremy Burns
I am trying to apply this to my site but whenever I access my 'delete' action 
(I have removed references to 'admin_' in the sample code as I am not using 
admin_delete yet) I get the error message "The view for XXXController::delete() 
was not found" (where XXX is my controller). The controller doesn't have a 
'delete' function in it as I am using the generic delete function in the 
app_controller. What am I doing wrong?

Jeremy Burns


On 13 Nov 2009, at 15:44, AD7six wrote:

> 
> 
> On 13 nov, 16:30, jburns  wrote:
>> No responses on this - any takers?
> 
> Try this for background: http://www.ad7six.com/e/67
> This (the component is in the mi_plugin branch) for a ~pnp solution,
> but probably a bit too integrated/dependent:
> http://code.assembla.com/mi/subversion/nodes/branches/mi_plugin/controllers/components/swiss_army.php#ln302
> 
> or simply:
> 
> function delete($id) {
> if (!$this->data) {
>  $this->set('referer', $this->referer()); // pick this up in the
> view, and add it to the form
>  return $this->render('/elements/confirm_delete');
> }
> ... actually delete ..
> $this->redirect($this->data[$this->modelAlias]['referer']); // where
> they came from
> }
> 
> hth,
> 
> AD
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Delete confirm

2009-11-14 Thread Jeremy Burns
Thanks to everyone for their input. AD&six's post is indeed comprehensive and I 
am just picking my through it now. I will post back my final implentation here.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 14 Nov 2009, at 12:35, j0n4s.h4rtm...@googlemail.com wrote:

> Nevermind, AD7six post explains it well and very better (and included
> my note, but post alone seems not to be sufficient anyway)
> 
> On Nov 14, 1:27 pm, "j0n4s.h4rtm...@googlemail.com"
>  wrote:
>> Another possibility is adding delete links within a  that has
>> method = post,
>> check the request method (if its POST) on the action as well.
>> 
>> in addition: give that form a class and css stylize it down to a link
>> (though why not keep it a button, buttons = post, links = get paradigm
>> works well too)
>> 
>> On Nov 13, 4:55 pm, Jeremy Burns  wrote:
>> 
>>> Thanks - good approach.
>> 
>>> Jeremy Burns
>>> jeremybu...@me.com
>>> (Skype) +44 208 123 3822 (jeremy_burns)
>>> (m) +44 7973 481949
>>> (h) +44 208 530 7573
>> 
>>> On 13 Nov 2009, at 15:44, Marcelo Andrade wrote:
>> 
>>>> On Fri, Nov 13, 2009 at 4:14 AM, jburns  wrote:
>>>>> I am not happy with the javascript delete confirm method, as it
>>>>> doesn't appear if javascript is disabled and the delete happens with
>>>>> no checking. I want to ask the user to confirm that he wants to delete
>>>>> a record, and would like to do something like this:
>> 
>>>>> 1. User clicks a delete link, which points at the delete action.
>>>>> 2. The delete action redirects the user to the view screen for the
>>>>> record with a flash message asking him to confirm the delete, and
>>>>> links to confirm or reject the deletion.
>>>>> 3. If the user clicks the confirm link they are redirected back to the
>>>>> delete action but this time with a parameter that shows the action has
>>>>> been confirmed, and the deletion takes place.
>>>>> 4. The parameter identified in (3) is not present in stage (2), which
>>>>> is how (2) knows to direct to the view screen and ask for
>>>>> confirmation, rather than just processing the delete.
>>>>> 5. I am reusing the view screen and action in (2) so that I don't have
>>>>> to build new confirm_delete screens and actions (I would need to build
>>>>> about 60 of them).
>> 
>>>> It's not so hard to do it with ordinary $html->link.
>>>> Point the delete link to a question action that do what
>>>> you want (a link to the real delete action and another
>>>> to go back).
>> 
>>>> If you can realize how to do it this way, so you could
>>>> encapsulate the all stuff creating your own helper,
>>>> overriding the $html->link method.
>> 
>>>> Best regards.
>> 
>>>> --
>>>> MARCELO DE F. ANDRADE
>>>> Belem, PA, Amazonia, Brazil
>>>> Linux User #221105
>> 
>>>> --
>> 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "CakePHP" group.
>>>> To post to this group, send email to cake-...@googlegroups.com.
>>>> To unsubscribe from this group, send email to 
>>>> cake-php+unsubscr...@googlegroups.com.
>>>> For more options, visit this group 
>>>> athttp://groups.google.com/group/cake-php?hl=.
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Delete confirm

2009-11-13 Thread Jeremy Burns
Thanks - good approach.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 13 Nov 2009, at 15:44, Marcelo Andrade wrote:

> On Fri, Nov 13, 2009 at 4:14 AM, jburns  wrote:
>> I am not happy with the javascript delete confirm method, as it
>> doesn't appear if javascript is disabled and the delete happens with
>> no checking. I want to ask the user to confirm that he wants to delete
>> a record, and would like to do something like this:
>> 
>> 1. User clicks a delete link, which points at the delete action.
>> 2. The delete action redirects the user to the view screen for the
>> record with a flash message asking him to confirm the delete, and
>> links to confirm or reject the deletion.
>> 3. If the user clicks the confirm link they are redirected back to the
>> delete action but this time with a parameter that shows the action has
>> been confirmed, and the deletion takes place.
>> 4. The parameter identified in (3) is not present in stage (2), which
>> is how (2) knows to direct to the view screen and ask for
>> confirmation, rather than just processing the delete.
>> 5. I am reusing the view screen and action in (2) so that I don't have
>> to build new confirm_delete screens and actions (I would need to build
>> about 60 of them).
> 
> It's not so hard to do it with ordinary $html->link.
> Point the delete link to a question action that do what
> you want (a link to the real delete action and another
> to go back).
> 
> If you can realize how to do it this way, so you could
> encapsulate the all stuff creating your own helper,
> overriding the $html->link method.
> 
> Best regards.
> 
> --
> MARCELO DE F. ANDRADE
> Belem, PA, Amazonia, Brazil
> Linux User #221105
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Delete confirm

2009-11-13 Thread Jeremy Burns
Thanks very much - I'll do some reading.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 13 Nov 2009, at 15:44, AD7six wrote:

> 
> 
> On 13 nov, 16:30, jburns  wrote:
>> No responses on this - any takers?
> 
> Try this for background: http://www.ad7six.com/e/67
> This (the component is in the mi_plugin branch) for a ~pnp solution,
> but probably a bit too integrated/dependent:
> http://code.assembla.com/mi/subversion/nodes/branches/mi_plugin/controllers/components/swiss_army.php#ln302
> 
> or simply:
> 
> function delete($id) {
> if (!$this->data) {
>  $this->set('referer', $this->referer()); // pick this up in the
> view, and add it to the form
>  return $this->render('/elements/confirm_delete');
> }
> ... actually delete ..
> $this->redirect($this->data[$this->modelAlias]['referer']); // where
> they came from
> }
> 
> hth,
> 
> AD
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Where should this code go?

2009-11-13 Thread Jeremy Burns
Yup - I've got that, but the data I want to access is outside of the current 
MVC - it's navigation based so data so system wide. I'd call this function from 
just about every MVC, so want to put it in one place (DRY).

Jeremy Burns
jeremybu...@me.com

On 13 Nov 2009, at 15:47, Marcelo Andrade wrote:

> On Fri, Nov 13, 2009 at 12:38 PM, Jeremy Burns  wrote:
>> Thanks - can a helper interrogate the database (which is a key requirement)?
> 
> According to MVC, this is extremelly not recommended.
> You should query the database in your controller and just
> pass the fetched results to your view.
> 
> Best regards.
> 
> --
> MARCELO DE F. ANDRADE
> Belem, PA, Amazonia, Brazil
> Linux User #221105
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Where should this code go?

2009-11-13 Thread Jeremy Burns
Thanks - can a helper interrogate the database (which is a key requirement)?

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 13 Nov 2009, at 15:37, Marcelo Andrade wrote:

> On Fri, Nov 13, 2009 at 12:25 PM, jburns  wrote:
>> No responses to this yet - any ideas please?
>> 
>> On Nov 11, 8:44 am, jburns  wrote:
>>> I want to write somecodethat can be passed some variables, then
>>> reads data from a table (menus) and produces some html (one or more
>>> ULs) to display as a dynamic and context sensitive navigation bar. The
>>> ULs will most probably be displayed in an element as they will appear
>>> on every view.
>>> 
>>> I'm not sure if thisshouldbe a plugin, a component or a helper. Some
>>> advice would be much appreciated.
> 
> I think if it outputs html code, it should be in a helper.
> 
> Best regards.
> 
> --
> MARCELO DE F. ANDRADE
> Belem, PA, Amazonia, Brazil
> Linux User #221105
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




<    12   13   14   15   16   17   18   >