html select State/Country dropdown in CakePHP ?

2008-06-17 Thread butangphp

Hey, I was wondering if there Cake has a way to automatically generate
a list of states/countries in the form of a dropdown menu.  Maybe
using the form helper or html helper ?   Any help would be greatly
appreciated.  Thanks!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Setting Variables in Foreach Loops...

2008-02-13 Thread butangphp

Hey all,

I'm trying to create a condition in my controller within a foreach
loop and then use this information in the view.

A quick note, $comments is a proper array, as is $online_now, so it is
not an array issue.  The question is where (or if) I can set the
variable $user_online so that it it has a different value for each
case ?  At the moment it is only returning the value of the last
element in the array (so, if there are 15 elements and the 15th
element is true, they are all true.  If the 15th element is false,
they are all false.  )

foreach ($comments as $comment) {

if (in_array($comment['Comment']['user_id'], $online_now))
   {
$user_online = true;
   }
else
{
$user_online = false;
}
}

$this-set('user_online', $user_online);


Any help would be greatly appreciated!
--~--~-~--~~~---~--~~
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: Setting Variables in Foreach Loops...

2008-02-13 Thread butangphp

Spark,

Thanks so much for the help.  It solved the problem.  And don't worry,
I wasn't actually using boolean variables as strings, just the actual
variables I am using are long, similar hyperlinks.  Maybe red/blue
would have been a better choice :)


On Feb 13, 1:01 pm, DJ Spark [EMAIL PROTECTED] wrote:
Brett, look:
 BEGIN
   LOOP1 - $user_online = true;
   LOOP2 - $user_online = true;
   LOOP3 - $user_online = false;
 END

 SET VARIABLE TO VIEW
$view-user_online = $user_online;

 which value will be there in the view ?

   Now, the simplest way, is to use the user array itself:

 foreach ($comments as $comment) {
   if (in_array($comment['Comment']['user_id'], $online_now))
   {
 $comment['Comment']['user_online'] = true;
   } else {
 $comment['Comment']['user_online'] = false;
   }

 }

 when looping the $comments variable in view, just use that
 ['Comment']['user_online'] array key.
 and , plase, don't use boolean variables as strings :)
 true is not true

  Spark

 On Feb 13, 2008 2:16 PM, butangphp [EMAIL PROTECTED] wrote:





  Hey all,

  I'm trying to create a condition in my controller within a foreach
  loop and then use this information in the view.

  A quick note, $comments is a proper array, as is $online_now, so it is
  not an array issue.  The question is where (or if) I can set the
  variable $user_online so that it it has a different value for each
  case ?  At the moment it is only returning the value of the last
  element in the array (so, if there are 15 elements and the 15th
  element is true, they are all true.  If the 15th element is false,
  they are all false.  )

  foreach ($comments as $comment) {

  if (in_array($comment['Comment']['user_id'], $online_now))
 {
  $user_online = true;
 }
  else
  {
  $user_online = false;
  }
  }

  $this-set('user_online', $user_online);

  Any help would be greatly appreciated!

 --
 [livesets]http://djspark.com.br/
 [web]http://sydi.net
 [filmes]http://melhoresfilmes.com.br
--~--~-~--~~~---~--~~
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: Function to ignore an element of an array

2007-12-05 Thread butangphp

Thanks man I appreciate the help.  I probably will use a regular
expression on that 'split' step, something like $email_list = split(/,
\s*/, $data['Mail']['receiver_username']) to eliminate any spaces
following the commas.

On Dec 4, 11:40 pm, Adam Royle [EMAIL PROTECTED] wrote:
 One more thing, if you're not going to use a regular expression to
 split a string, you should just use:

 $input_usernames = explode(,, $data['Mail']['receiver_username']);

 Cheers,
 Adam

 On Dec 5, 3:38 pm, Adam Royle [EMAIL PROTECTED] wrote:

  I would use a single query and some array functions. This is off the
  cuff (untested) but should work as far as I can tell. Might do it
  slightly differently if you need the id of the User as well to do
  further processing, but you should be able to figure out the rest
  yourself.

  $input_usernames = split(,, $data['Mail']['receiver_username']);
  $found_usernames = $this-User-findAll( array('User.username' =
  $input_usernames), 'User.field' );
  $found_usernames = Set::extract($found_usernames,
  '{n}.User.username');

  $orphan_usernames = array_diff($input_usernames, $found_usernames);
  pr($orphan_usernames); // the list of usernames that were not found

  Cheers,
  Adam

  On Dec 5, 1:15 pm, butangphp [EMAIL PROTECTED] wrote:

   Basically, I am writing a mailing class

   $comma = ,;
   if (strchr($data['Mail']['receiver_username'], $comma))
   {
   //remove the commas and create and array of usernames
   $email_list = split(,, 
   $data['Mail']['receiver_username']);

   foreach ($email_list as $receivers)
   {
   $receivers_id = 
   $this-User-getUserIdByUsername($receivers);
   $conditions = 'User.id = '.$receivers_id.'';
   $receivers = $this-User-field('username', 
   $conditions);

   if ($receivers == 'FALSE')
   {
   //if one of the usernames is false, remove it and 
   continue with the
   rest
   }

   }

   If theres a comma (and hence more than one name listed) I split the
   string and create an array.
   I need a function in order to weed out usernames that are not in the
   database.  Any suggestions??
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination nightmares

2007-11-15 Thread butangphp

I'm a beginner and struggling to use pagination correctly in cakephp.
The Bakery recommends using this code in the controller.  I know its a
dumb question, but do I need to create a function called index() in
order to make this built in helper work ??

?php
class PostsController extends AppController
{
var $name = 'Posts'; // for PHP4 installs
var $components = array ('Pagination'); // Added
var $helpers = array('Pagination'); // Added

function index() {
$criteria=NULL;
list($order,$limit,$page) = $this-Pagination-
init($criteria); // Added
$data = $this-Post-findAll($criteria, NULL, $order, $limit,
$page); // Extra parameters added

$this-set('data',$data);
}
}
?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Newbie...really simple question

2007-11-13 Thread butangphp

I'm trying to create a new Cakephp application, however when I load up
localhost/cake it gives me the message

Missing Database Table

No Database table for model Post (expected  posts), create it
first.  Posts is another application I previously made but deleted,
and now I cannot get Cake to recognize my new application.  I have
changed the name of the database in the database.php configuration
file so I'm not exactly sure what my problem is.  Any suggestions
would be greatly appreciated.


--~--~-~--~~~---~--~~
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: Newbie...really simple question

2007-11-13 Thread butangphp

Well what I'm trying to do is forget about this table/database all
together...it was a simple example I was trying to do in order to
familiarize myself with cakephp, but I have since deleted all files
related to Post (the controller, model, views, sql table, etc.)
However when I try and load localhost cake, its telling me

Missing controller
You are seeing this error because controller PostsController could not
be found.
Notice: If you want to customize this error message, create app\views/
errors/missing_controller.thtml.
Fatal: Create the class below in file : app\controllers
\posts_controller.php

?php
class PostsController extends AppController {
   var $name = 'Posts';
}

I just want to forget about this stupid Posts_controller and
everything associated and create another application in cake without
this message interfering! Quite frustrating...any advice?
On Nov 13, 10:50 am, Chris Hartjes [EMAIL PROTECTED] wrote:
 On Nov 13, 2007 11:17 AM, butangphp [EMAIL PROTECTED] wrote:



  I'm trying to create a new Cakephp application, however when I load up
  localhost/cake it gives me the message

  Missing Database Table

  No Database table for model Post (expected  posts), create it
  first.  Posts is another application I previously made but deleted,
  and now I cannot get Cake to recognize my new application.  I have
  changed the name of the database in the database.php configuration
  file so I'm not exactly sure what my problem is.  Any suggestions
  would be greatly appreciated.

 It's complaining that there is no 'posts' table in your database.  I
 know it's a dumb question, but are you sure the table is in the
 database you've specified in database.php?

 --
 Chris Hartjes

 My motto for 2007:  Just build it, damnit!

 @TheKeyboard -http://www.littlehart.net/atthekeyboard


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---