Re: form issue

2008-03-23 Thread Dardo Sordi Bogado

On Mon, Mar 24, 2008 at 1:32 AM, damo <[EMAIL PROTECTED]> wrote:
>
>  thanks again Dardo,
>  I got the date working, although I also had to add the 'minYear' also
>  or else we only have very young students ;)

You are welcome.

>  Also got the search function to work with only a little tinkering.
>  Took me a while to realise that I needed to change the form to: '  echo $form->create('Student', array('action' => 'search')); ?>'
>  but that was straight forward.  I also needed to change the flash
>  message to $this->Flash('Student not found','/students/search');

Nice.

>  Am I correct in assuming that I will need to put in different search
>  functions for each type of search I want to do.  Eg. studentsearch,
>  coursesearch?  Where coursesearch returns all the students doing the
>  course (I would also need a different view function also, or could I
>  just manipulate my viewall function, because that is how I would like
>  it presented).

That depends of your style, but in general I think is a good practice
to put those search separated (I'm talking without having seen your
code).

>  Now I'm really getting somewhere!  Albeit with my hand held :)

I'm happy you are right on track, enjoy CakePHP!

>
>
>  On Mar 23, 5:16 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
>
>
> > On Sun, Mar 23, 2008 at 3:00 AM, damo <[EMAIL PROTECTED]> wrote:
>  >
>  > >  Thanks Dardo, I have taken your advise and added the additional
>  > >  field.  It all seems to work great now, I'm suprised with how quickly
>  > >  things come together even on my first attempt.  So now I have an add,
>  > >  edit, delete, view functions.  All of this is based of the tutorial
>  > >  and I am very pleased with my progress but I am quickly realising how
>  > >  much more there is to it!!
>  >
>  > You are wecome, I'm glad you are making progress, cake is so powerful.
>  >
>  > >  A couple of more questions:
>  > >  I have a 'date' field which is for Date of Birth.  In the addformas
>  > >  it is it lists dates from 1988 to 2028.  I obviously don't need future
>  > >  dates for this, so how can I change this so that the latest date is
>  > >  today (or some arbitrary recent date), and it's earliest date is back
>  > >  x amount of years.
>  >
>  > $form->input('mydatefield', array('maxYear' => 2008));
>  >
>  > >  Second, I would like to put together a very simple search function
>  > >  preferably based upon the tutorial (because I understand that).  I
>  > >  haven't been able to find anything particularly easy to implement in
>  > >  my reading so far.  All I really want to do is search for the
>  > >  'student_number' and then 'view' that record, failing that echo
>  > >  'student doesn't exist', or something like that.
>  >
>  > This may work,
>  >
>  > in your controller :
>  >
>  > function search() {
>  >
>  > if (!empty($this->data)) {
>  >  $number = $this->data['Student']['student_number'];
>  >  $student = $this->Student->findByStudentNumber($number);
>  > // or : $student =
>  > $this->Student->find(array('Student.student_number' => $number));
>  >
>  >  if ( $student) {
>  > $this->redirect(array('action' => 'view', 
> $student['Student']['id']));
>  >  } else {
>  > $this->Session->setFlash('Student not found');
>  >  }
>  >
>  > }
>  > >  On Mar 22, 7:04 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
>  > >  > Cake automagically sets primary keys fields as hidden, you can
>  > >  > override the default behavior:
>  >
>  > >  > echo $form->input('id', array('label' => 'Student Number: ', 'type' 
> => 'text'));
>  >
>  > >  > Maybe is better, just to add a new field called student_number and
>  > >  > make it an sql unique index and let the ids alones.
>  >
>  > > > On Sat, Mar 22, 2008 at 2:41 AM, damo <[EMAIL PROTECTED]> wrote:
>  >
>  > >  > >  I'm sure this is ridiculously simple to resolve, but the below 
> seems
>  > >  > >  to work perfectly:
>  >
>  > >  > >  Add Student Record
>  >
>  > >  > >  create('Student'); ?>
>  >
>  > >  > > > >  > > echo $form->input('id', array('label' => 'Student Number: 
> '));
>  > >  > > echo $form->input('studentname', array('label' => 'Student
>  > >  > >  Name: '));
>  > >  > > echo $form->input('studentdob', array('label' => 'Student 
> Date
>  > >  > >  of Birth: '));
>  > >  > > echo $form->input('course', array('label' => 'Current 
> Course:
>  > >  > >  '));
>  > >  > >   ?>
>  >
>  > >  > >  end('Insert'); ?>
>  >
>  > >  > >  except that the id component of theformdoesn't display at all
>
>
> > >  > >  When I insert the record, everything goes in correctly, except
>  > >  > >  obviously the the 'id'.  The 'id' is set as the primary key for the
>  > >  > >  table, although I have toggled this.  Also, I would have preferred 
> to
>  > >  > >  have the 'id' labelled something like 'studentnumber', but the view
>  > >  > >  option wouldn't work when I had it setup this way.
>  >
>  > >  > >  

Re: form issue

2008-03-23 Thread damo

thanks again Dardo,
I got the date working, although I also had to add the 'minYear' also
or else we only have very young students ;)

Also got the search function to work with only a little tinkering.
Took me a while to realise that I needed to change the form to: 'create('Student', array('action' => 'search')); ?>'
but that was straight forward.  I also needed to change the flash
message to $this->Flash('Student not found','/students/search');

Am I correct in assuming that I will need to put in different search
functions for each type of search I want to do.  Eg. studentsearch,
coursesearch?  Where coursesearch returns all the students doing the
course (I would also need a different view function also, or could I
just manipulate my viewall function, because that is how I would like
it presented).

Now I'm really getting somewhere!  Albeit with my hand held :)


On Mar 23, 5:16 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 23, 2008 at 3:00 AM, damo <[EMAIL PROTECTED]> wrote:
>
> >  Thanks Dardo, I have taken your advise and added the additional
> >  field.  It all seems to work great now, I'm suprised with how quickly
> >  things come together even on my first attempt.  So now I have an add,
> >  edit, delete, view functions.  All of this is based of the tutorial
> >  and I am very pleased with my progress but I am quickly realising how
> >  much more there is to it!!
>
> You are wecome, I'm glad you are making progress, cake is so powerful.
>
> >  A couple of more questions:
> >  I have a 'date' field which is for Date of Birth.  In the addformas
> >  it is it lists dates from 1988 to 2028.  I obviously don't need future
> >  dates for this, so how can I change this so that the latest date is
> >  today (or some arbitrary recent date), and it's earliest date is back
> >  x amount of years.
>
> $form->input('mydatefield', array('maxYear' => 2008));
>
> >  Second, I would like to put together a very simple search function
> >  preferably based upon the tutorial (because I understand that).  I
> >  haven't been able to find anything particularly easy to implement in
> >  my reading so far.  All I really want to do is search for the
> >  'student_number' and then 'view' that record, failing that echo
> >  'student doesn't exist', or something like that.
>
> This may work,
>
> in your controller :
>
> function search() {
>
> if (!empty($this->data)) {
>  $number = $this->data['Student']['student_number'];
>  $student = $this->Student->findByStudentNumber($number);
> // or : $student =
> $this->Student->find(array('Student.student_number' => $number));
>
>  if ( $student) {
> $this->redirect(array('action' => 'view', $student['Student']['id']));
>  } else {
> $this->Session->setFlash('Student not found');
>  }
>
> }
> >  On Mar 22, 7:04 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> >  > Cake automagically sets primary keys fields as hidden, you can
> >  > override the default behavior:
>
> >  > echo $form->input('id', array('label' => 'Student Number: ', 'type' => 
> > 'text'));
>
> >  > Maybe is better, just to add a new field called student_number and
> >  > make it an sql unique index and let the ids alones.
>
> > > On Sat, Mar 22, 2008 at 2:41 AM, damo <[EMAIL PROTECTED]> wrote:
>
> >  > >  I'm sure this is ridiculously simple to resolve, but the below seems
> >  > >  to work perfectly:
>
> >  > >  Add Student Record
>
> >  > >  create('Student'); ?>
>
> >  > >>  > > echo $form->input('id', array('label' => 'Student Number: '));
> >  > > echo $form->input('studentname', array('label' => 'Student
> >  > >  Name: '));
> >  > > echo $form->input('studentdob', array('label' => 'Student Date
> >  > >  of Birth: '));
> >  > > echo $form->input('course', array('label' => 'Current Course:
> >  > >  '));
> >  > >   ?>
>
> >  > >  end('Insert'); ?>
>
> >  > >  except that the id component of theformdoesn't display at all
> >  > >  When I insert the record, everything goes in correctly, except
> >  > >  obviously the the 'id'.  The 'id' is set as the primary key for the
> >  > >  table, although I have toggled this.  Also, I would have preferred to
> >  > >  have the 'id' labelled something like 'studentnumber', but the view
> >  > >  option wouldn't work when I had it setup this way.
>
> >  > >  Many thanks,
> >  > >  Damo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



3 errors happening to files out of the app folder

2008-03-23 Thread Raistlin Majere

The 3 errors are happening to files out of the app Folder.


1

Query: INSERT INTO rated (account_id) VALUES ('3')
Warning: SQL Error: 1062: Duplicate entry '0' for key 1 in C:\AppServ
\www\CakePHP\cake\libs\model\datasources\dbo_source.php on line 440

2

Query: INSERT INTO rated (points) VALUES ('10')
Warning: SQL Error: 1062: Duplicate entry '0' for key 1 in C:\AppServ
\www\CakePHP\cake\libs\model\datasources\dbo_source.php on line 440

3

Warning: Cannot modify header information - headers already sent by
(output started at C:\AppServ\www\CakePHP\cake\basics.php:697) in C:
\AppServ\www\CakePHP\cake\libs\controller\controller.php on line 447


What do these error messages mean?


$rated=$this->Article->query("SELECT * FROM rated WHERE
account_id='$account_id'");

if (!empty($points) && empty($rated))
{
$this->Article->query("INSERT INTO rated (article_id) VALUES
('$article_id')");

$this->Article->query("INSERT INTO rated (account_id) VALUES
('$account_id')");

$this->Article->query("INSERT INTO rated (points) VALUES
('$points')");

$this->redirect('/articles/result/select/'.$article_id.'/'.
$account_id);
}


Why is article_id not giving me an error?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Different flash layout for public and admin ?

2008-03-23 Thread John R

You can also easily modify the flash() function and add an additional
parameter for which layout to render.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Modal / Lightbox?

2008-03-23 Thread John R

I am gathering I might need some sort of Ajax listener loaded on each
page and activate it via the Controller? Help! =[
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Different flash layout for public and admin ?

2008-03-23 Thread jonknee

You could go a couple different ways... Since you have a different
layout you probably also have a different stylesheet. If that's the
case, just modify the message style in it and you're good to go. If
you're using a shared stylesheet you can modify the call to
sessionComponent::setFlash() and set a custom layout (its the second
parameter).

On Mar 23, 2:55 pm, Neveldo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've ever a different layout for the website and the administration by
> using $this->layout in app_controller.php.
>
> But, is it possible to do the same thing for the flash layout ? In
> fact, I want to use a different layout for the flashes on the website
> and the flashes on the admin.
>
> Thank !
>
> Cordially,
> Neveldo -http://www.neveldo.fr
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can you separate controller from view in this mixed code?

2008-03-23 Thread Raistlin Majere

I solved the problem! I rewrote the code.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



/articles/ is disappering from url

2008-03-23 Thread Raistlin Majere

$articlesurl=$html->url('/articles/');

if($session->check('Account') && !empty($all[$result]['articles']
['mark']) && $all[$result]['articles']['mark'])
{
echo ''.
$subject.' [Modify] [Delete]';
}

How to solve?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Login box in layout

2008-03-23 Thread Dardo Sordi Bogado

Store referer in session (if referer is different from actual action)
and redirect to it when login is successful.  Storing referer in
session is an idea of AD7six (http://bin.cakephp.org/view/316159681)
and it let you do some interesting tricks.

On Sun, Mar 23, 2008 at 7:20 PM, Dave J <[EMAIL PROTECTED]> wrote:
>
>  Hey Nick,
>
>  You're right about that. I guess you can tackle it either two ways.
>
>  1) Submit the form using AJAX, so if there's any errors, you get them
>  back without a page refresh. And on successful login, you could either
>  hide the login form and replace it with a 'logged-in' message. Or send
>  back a JS command to refresh the page, so the page would reflect the
>  new logged-in status
>
>  2) Or use the flash feature of the Session Component/Helper to return
>  any errors as soon as the page refreshes. (Just make sure you have
>  $session->flash() somewhere in your layout)
>
>
>
>
>
>  On Mar 23, 8:00 pm, Nick Timchenko <[EMAIL PROTECTED]> wrote:
>  > Yeah, I was trying it, but that way I lose any data according to
>  > validation/authentication errors. Is there any solution?
>  >
>  > Regards,
>  > Nick
>  >
>  > Dave J wrote:
>  > > How about in the action which processes the form data, you pick up the
>  > > referer URL  ($this->referer() )  and at the end - after the user
>  > > successfully authenticates - you just redirect to that URL
>  > > basically leaving him on the same page.
>  >
>  > > Dave
>  >
>

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



Re: Login box in layout

2008-03-23 Thread Dave J

Hey Nick,

You're right about that. I guess you can tackle it either two ways.

1) Submit the form using AJAX, so if there's any errors, you get them
back without a page refresh. And on successful login, you could either
hide the login form and replace it with a 'logged-in' message. Or send
back a JS command to refresh the page, so the page would reflect the
new logged-in status

2) Or use the flash feature of the Session Component/Helper to return
any errors as soon as the page refreshes. (Just make sure you have
$session->flash() somewhere in your layout)



On Mar 23, 8:00 pm, Nick Timchenko <[EMAIL PROTECTED]> wrote:
> Yeah, I was trying it, but that way I lose any data according to
> validation/authentication errors. Is there any solution?
>
> Regards,
> Nick
>
> Dave J wrote:
> > How about in the action which processes the form data, you pick up the
> > referer URL  ($this->referer() )  and at the end - after the user
> > successfully authenticates - you just redirect to that URL
> > basically leaving him on the same page.
>
> > Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problems with Cake Blog tutorial preventing me from further using Cake

2008-03-23 Thread Baz
I think you missed the point or maybe I wasn't clear. I'm not disputing how
people learn. I personally, learned by baking (by far the greatest learning
tool I've found in CakePHP). However, you can't go from 0 to 60. Nobody
said, study the entire manual. But at least read the section on setup.

The way THIS particular tutorial is set up is IN ADDITION to the manual.

On Sat, Mar 22, 2008 at 3:19 PM, Ryan.Bergman <[EMAIL PROTECTED]>
wrote:

>
> All you need to do is set write access to the folder. In Mac terminal
> enter something like this:
> chmod -R 777 /applicationcontext/app/tmp.
>
> This will set the proper permissions for tmp and everything under it (-
> R =  recursive)
>
> As to the rest of this thread. Most people do not learn by reading a
> bunch of dry specs but by jumping in, taking things apart and putting
> them back together again. Tutorials are great for this kind of
> learningand it is a completely illegitimate way to introduce
> yourself to a technology. If you have a problem with the question then
> just don't answer it and let others in the community be helpful and
> welcoming.
>
>
> >
>

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