Re: Help controlling data returned from query

2010-01-07 Thread John Andersen
Don't include Profile in your contain, just make a condition straight
on Cardset.profile_id!

[code snippet]
> 'contain' => false,
> 'conditions' => array(
>'Cardset.profile_id' => $profileId['Profile']['id']
> ),
> 'fields' => array('id')
[/code snippet]

Enjoy,
   John


On Jan 8, 6:31 am, trobrock  wrote:
> I have some models set up with the following relations:
>
> Profile->Cardset->Card
>
> I am trying to get all the Cardsets related to a specific Profile Id
> and am using this:
>
> $cardsets = $this->Cardset->find('all', array(
>     'contain' => array(
>         'Profile' => array(
>             'conditions' => array(
>                 'Profile.id' => $profileId['Profile']['id']
>             ),
>             'fields' => array('id')
>         )
>     )
> ));
>
> The problem with this is it returns $cardsets[n]['Profile']['id'] the
> only data I want returned is the Cardset Model data and no Profile
> data, what is the best way of achieving 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: cake book offline pdf version!!

2010-01-07 Thread Walther
It is not possible for CakePHP to generate a print version of the
manual for each version because the CookBook is very much like
wikipedia. There is no 'versions' of it, anybody can make edits and
suggestions.
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 techniques

2010-01-07 Thread Walther
You can do exactly what you want using custom routing (Check the
cookbook).

But, as euromark pointed out, you'll need to ensure that users can't
register with your existing controller names, and that you have some
filtering in your route to make sure that your other controllers still
work.

On Jan 7, 3:19 pm, rahulb  wrote:
> Hello,
>           I want to know whether , there is any way by which I can
> change the routing mechanism of cakephp.
> For example,
>   If i want to change my routing mechanism in such a way that i can
> manipulate urls like these :
>      http://my.website.com/[username]/profile
> Where the [username] will be the name of the user and every new user
> who registers with my site , should be able to access his profile in
> the manner given above.
>
> Is there a way by which this can be achieved.
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: cakephp und google base / merchants

2010-01-07 Thread Walther
Hi.

Take a look here: http://github.com/dogmatic/cakephp_google_plugin

Dogmatic69 (From the IRC channel) has created that plugin with the
goal of having all google apis available. Perhaps you can help him.

You can catch him on the IRC channel most of the time.

On Jan 7, 4:04 pm, euromark  wrote:
> did anyone build a class for interacting with google base or google
> merchants
> like for publishing products etc.?
>
> you can use the cake1.3 CakeSocket (or HttpSocket in cake1.2) to
> connect to the account and its feed and POST the data.
>
> i started to create a lib class for updating the feed via POST of an
> xml-file
> and thought maybe somebody else came up with something similar idea
>
> gerenelly i can think of 2 different approaches
> - behaviour which updates the feed in real time (afterSave and
> afterDelete callbacks)
> - cronjob which updates the feed frequently (full override with a
> complete xml file of all products) - many companies do it this way
>
> I might have to integrate it in an online shop
> PS: if somebody is interested in working together (because he/she
> needs it as well) feel free to contact 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


EmailComponent - Attachments

2010-01-07 Thread Krrose27
I am attempting to attach a file that is posted to my server...

$this->Email->attachments = array($_FILES[log][tmp_name]);

The above works and the file is attached...

It however attaches it with the php tmp name

So I attempted the following to attach it as the file name...

$this->Email->attachments = array($_FILES[log][name] => $_FILES[log]
[tmp_name]);

No luck...

Any clues on how to pull this off?
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: CakeFest IV - America - Help us pick a location!

2010-01-07 Thread Chris Roush
New York, NY!

On Nov 13 2009, 11:19 pm, BrendonKoz  wrote:
> Although I live east coast, I'd be more apt to go if it was some place
> warm/tropical.  Once you're in DC, it's not bad, but getting there if
> you don't fly is a pain.  Chicago's airport's pretty cool, but I've
> never been outside of it.  How is Texas's night life?  Safe?
>
> Anyway, nice of the Cake team to ask!  Thanks!
>
> On Nov 13, 11:02 pm, Miles J  wrote:
>
> > Chicago seems cheap and cold, also one of the worse major cities in
> > the US, why there?
>
> > I vote for New York, or Seattle, or Boston, or something.
>
> > On Nov 13, 7:36 pm, Renan Gonçalves  wrote:
>
> > > Looks like Chicago is a nice place to host.
>
> > > On Fri, Nov 13, 2009 at 1:43 AM, Graham Weldon 
> > > wrote:
>
> > > > Hi all,
>
> > > > The CakePHP team has been considering the location for the next upcoming
> > > > CakeFest.
> > > > We've decided to bring it back home to the United Sates of America.
> > > > Thus far we haven't chosen a location for the event, but to ensure we 
> > > > reach
> > > > as many people as possible, we'd like your opinion on where we should 
> > > > host
> > > > the event.
>
> > > > Essentially, our choices are:
> > > > - USA East Coast
> > > > - USA West Coast
> > > > - USA Central
>
> > > > If I have missed another location that you feel might be more popular or
> > > > accessible to interested attendees, feel free to suggest it.
> > > > We're keen to hear peoples thoughts on it.
>
> > > > Cheers,
>
> > > > Graham Weldon (AKA: Predominant)
>
> > > > e. gra...@grahamweldon.com
> > > > w.http://grahamweldon.com
>
> > > >  --
> > > > 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=.
>
> > > --
> > > Renan Gonçalves aka renan.saddam
> > > CakeDC Software Engineer
> > > CakePHP Core Developer
> > > Website: renangoncalves dot com
> > > Extrema, MG, Brazil- 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


Ajax Form Not Posting anything to $this->data

2010-01-07 Thread Chris Roush
Hello everyone,
I'm trying to get an ajax form working on my site, and I'm having a
strange issue. The div set to update updates fine and displays the
view file it's supposed to, but in my controller, $this->data is
empty.

Here are the relevant sections:




<  INDEX.CTP  -->
link(array('prototype', 'scriptaculous')); ?>

form('/bda_classes/search','post', array('url'=>'/
bda_classes/search','update'=>'results'));?>
 input('BdaClass.keyword',array('label'=>'')); ?
>
.
.
.

submit("Search"); ?> 
end(); ?>


<  END OF INDEX.CTP  -->



< bda_classes_controller  -->

var $helpers = array('Html', 'Form', 'Ajax', 'Javascript');
var $components = array( 'RequestHandler');


function search(){
   debug($this->data);
   $this->render('search', 'ajax');
}





When I submit the form, it updates the div with :

app/controllers/bda_classes_controller.php (line 286)


I know this should be easy, I've done it before on other sites. But
after a couple hours of banging my head against a wall, I can't figure
out what the problem could be. Any help would be much 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


FCKEditor Edit Page Isssue

2010-01-07 Thread Uresh

This is my View page shows in controller code :::

class AdminController extends AppController {

var $name = 'Admin';
var $uses = array('Frmcontent'); // we can use multiple models by defining
the $uses variable.
var $components = array ('Crypter');
var $paginate = array('limit' => 1, 'page' => 1);
var $helpers = array('Html', 'Form', 'Javascript','FCKeditor1');

--
my function edit

function contentedit($id=null)
{
$this->sidebar ='CONTENT_MANAGEMENT';
$this->evnt = 'contentedit';
$this->layout = 'admin/admin';
$this->page='edit';
$this->set('page',$this->page);
$this->set('sidebar',$this->sidebar);
$this->set('evnt',$this->evnt);
$this->Frmcontent->id = $id;

if(!empty($this->data))
{
if($this->Frmcontent->save($this->data))
{
$this->Session->setFlash('Your post has been updated.');

$this->redirect(array('controller'=>'admin',
'action'=>"contentview"));
}
}
else
{
$this->data=$this->Frmcontent->read();
}
}

This is my View page shows in view page error shows :::

http://localhost/bestgymdeal_parth/admin/contentedit/23

As i click on edit link myurl show above link contenetedit is action in
controller and 23 is id of particular row.

The page displays error like.

/**/
Missing Method in AdminController

Error: The action FCKeditor is not defined in controller AdminController

Error: Create AdminController::FCKeditor() in file:
app\controllers\admin_controller.php.

http://old.nabble.com/file/p27071557/contentedit.ctp contentedit.ctp 

/***/

-- 
View this message in context: 
http://old.nabble.com/FCKEditor-Edit-Page-Isssue-tp27071557p27071557.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


Help controlling data returned from query

2010-01-07 Thread trobrock
I have some models set up with the following relations:

Profile->Cardset->Card

I am trying to get all the Cardsets related to a specific Profile Id
and am using this:

$cardsets = $this->Cardset->find('all', array(
'contain' => array(
'Profile' => array(
'conditions' => array(
'Profile.id' => $profileId['Profile']['id']
),
'fields' => array('id')
)
)
));

The problem with this is it returns $cardsets[n]['Profile']['id'] the
only data I want returned is the Cardset Model data and no Profile
data, what is the best way of achieving 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


How to detect the associations included when using ContainableBehavior

2010-01-07 Thread gianpaulo
How can I detect if a specific association is included within a find()
method of a model when using ContainableBehavior. I want to filter the
data on afterFind but I don't want to loop through the results  and
check for the Model name if it's included.

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


App::import at the beginning of a file?

2010-01-07 Thread Josh
Does anybody have an opinion on using App::import for an abstract base
class before defining the concrete sub-class? It seems like a way to
avoid including all abstract parents before creating a concrete
instance... but it violates good OO practices it seems? Do people have
an opinion on this?

Outside of cake, I'd probably group these classes in the same file, or
perhaps group the abstract classes in one file and leaves in
another... to avoid unnecessary includes.

Example (with a composite pattern where Unit and UnitComposite are
abstract and Army extends UnitComposite which extends Unit):

App::import('Component', 'Unit');
App::import('Component', 'UnitComposite');

class ArmyComponent extends UnitComposite...
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


Crazy email question

2010-01-07 Thread Dave
In my set up every user has a unique slug. 
Now on their profile i would like the option to cloak their address if they
choose to hide it so myn...@atmyreal.com becomes s...@site.com which ends up
going to their real address. 

Idea is like craigslist where their emails in ads are
543-hn...@craigslist.com 
but when you send to that address it ends up going to whatever info the user
has on file email address.

Is there an easy way to do such a thing with cake? I know it's a weird
question, probably nothing to do with cake but I had to ask.

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


Re: Subdomains

2010-01-07 Thread Juan Luis Baptiste
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


RE: Validate Question

2010-01-07 Thread Dave
Thanks,

I guess I will just keep what I have, was just curious as to which maybe
better but my guess is the inList function is an array_diff() so its pretty
much the same thing I got going on now

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Miles J
Sent: January-07-10 2:24 PM
To: CakePHP
Subject: Re: Validate Question

You will have to set the validation rule during runtime in your model/
controller, like so:

$this->Model->validate['field']['inList'] = array('rule' => array ('inList',
$myListVariable));

On Jan 7, 2:06 am, John Andersen  wrote:
> Hi Dave,
>
> Is your rule made in accordance with CakePHP custom validation rules?
> If yes, then I don't see a better solution.
>
>
Seehttp://book.cakephp.org/view/150/Custom-Validation-Rules#Adding-your-...
> for the custom validation rules.
>
> Enjoy,
>    John
>
> On Jan 7, 7:48 am, "Dave"  wrote:
>
> > Using the inList validation rule I have 2 questions.
>
> > 'rule' => array('inList', array('0', '1', '2','3', '4', '5', '6', 
> > '7')), will allow values matching 0 thru 7 anything else is invalid
>
> > So my first question is if I created an variable array of values 
> > from a find could i just use 'rule' => array('inList', 
> > $myListVariable),
>
> > and if that is possible how do i get the $myListVariable into the 
> > validation function?
>
> > Or is better to just stick with what im currently doing. For example 
> > I have my country select list and it has a validation 'rule' => 
> > array('checkCountryValues'),
>
> > Model function for the country validation
> > /*
> >  Form Modification Validation
> >  Checks that entered values for Country are Valid
>
> >  */
> >   public function checkCountryValues($data)
> >       {
> >     $valid = false;
> >     $model_table = Inflector::classify($this->useTable);
>
> >     if (!empty($this->data))
> >     {
> >      // this section matches values against database
> >      $value = array($this->data[$model_table]['country_id']);
> >      $results = array_diff($value, $this->Country->find('list', 
> > array('fields' => 'id')));
>
> >      if (empty($results))
>
> >      $valid = true;
> >     }
>
> >   return $valid;
> >       }
>
> > So if anyone messes with the form it returns invalid.
>
> > Ideas?
>
> > Dave

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/07/10
04:05: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


Re: Can CakePHP run in a user account?

2010-01-07 Thread Fred Riley
Oops. Sorry. Can I say d'oh! now? D'OH!!

Thanks, Jon. I really should have known better :(

Cheers

Fred

On Jan 7, 2:27 am, Jon Bennett  wrote:
> Hi Fred,
>
> > Thanks, Marcelo. I did try that but it didn't work out, I'm afraid. I
> > edited the 3 .htaccess files (in /, /apps, /apps/webroot) to look
> > like:
>
> > 
> >    RewriteBase /~fredriley
> >    RewriteEngine on
> >    RewriteRule    ^$    webroot/    [L]
> >    RewriteRule    (.*) webroot/$1    [L]
> >  
>
> Each htaccess file is different, if you've made them the same, things
> certainly won't work with modrewrite enabled.
>
> J
>
> --
> jon bennett -www.jben.net- blog.jben.net
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: Validate Question

2010-01-07 Thread Miles J
You will have to set the validation rule during runtime in your model/
controller, like so:

$this->Model->validate['field']['inList'] = array('rule' => array
('inList', $myListVariable));

On Jan 7, 2:06 am, John Andersen  wrote:
> Hi Dave,
>
> Is your rule made in accordance with CakePHP custom validation rules?
> If yes, then I don't see a better solution.
>
> Seehttp://book.cakephp.org/view/150/Custom-Validation-Rules#Adding-your-...
> for the custom validation rules.
>
> Enjoy,
>    John
>
> On Jan 7, 7:48 am, "Dave"  wrote:
>
> > Using the inList validation rule I have 2 questions.
>
> > 'rule' => array('inList', array('0', '1', '2','3', '4', '5', '6', '7')),
> > will allow values matching 0 thru 7 anything else is invalid
>
> > So my first question is if I created an variable array of values from a find
> > could i just use 'rule' => array('inList', $myListVariable),
>
> > and if that is possible how do i get the $myListVariable into the validation
> > function?
>
> > Or is better to just stick with what im currently doing. For example I have
> > my country select list and it has a validation 'rule' =>
> > array('checkCountryValues'),
>
> > Model function for the country validation
> > /*
> >  Form Modification Validation
> >  Checks that entered values for Country are Valid
>
> >  */
> >   public function checkCountryValues($data)
> >       {
> >     $valid = false;
> >     $model_table = Inflector::classify($this->useTable);
>
> >     if (!empty($this->data))
> >     {
> >      // this section matches values against database
> >      $value = array($this->data[$model_table]['country_id']);
> >      $results = array_diff($value, $this->Country->find('list',
> > array('fields' => 'id')));
>
> >      if (empty($results))
>
> >      $valid = true;
> >     }
>
> >   return $valid;
> >       }
>
> > So if anyone messes with the form it returns invalid.
>
> > Ideas?
>
> > 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: 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 Juan Luis Baptiste
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


Re: Add Fields

2010-01-07 Thread LunarDraco
To solve your problem without irritating the end user I would start
the form with one empty field under your User Defined section with an
"add" button/link to add additional fields to the form. The Add button
should use ajax and client side script to insert additional fields to
the web form.

Next to each additional Field I would place a remove.

With this UI structure you maintain a single form, the UI is not
cluttered with a bunch of empty fields, and your not arbitrarily
limiting any user to a specific number of fields. All the work of
adding/removing fields occurs at the client without the need to do
round trips to the server.

Your model relationship is already setup. However you will need to do
some additional work in the Controller to parse out the data in the
fields and save it to the Many side of your relation.

For a good live example of this type of Web ajax UI take a look at
Googles Contacts in gmail. When you edit a contact you can have
unlimited phone numbers. But it is all done in the one form. Using
ajax to add or remove the additional phone numbers. The underlying
relationship is Contacts have many Phones. They use the same model and
concept for the Contacts Email, Phone, Address and Website.

I really like this UI structure because it solves the very problem
you've presented in a very intuitive way for the end user.


On Jan 6, 1:50 pm, "Dave"  wrote:
> It is a separate Additional table with relations to
> user hasMany Additional,
> Additional belongsTo User
>
> The problem with SCS idea is this is all in 1 form. Does not make sense in
> my situation where a user is editing thier profile in 1 form to send them to
> another form to edit 1 field, and if they have more than 1 additional to go
> thru the repeated process, or fill out half the Profile form to click edit
> additional only to find out any data they changed was not saved and have to
> go back and edit it all over again. Not going to bother saving to data to
> session and all that since this area of the profile is not to important in
> terms of the site.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
>
> Of John Andersen
> Sent: January-06-10 5:09 PM
> To: CakePHP
> Subject: Re: Add Fields
>
> Dave, what is your database design for this issue?
> As scs stated, are you saving the additional information in a separate table
> or in the profile table as 10 independent columns?
> Depending on your answer, we will try better to help you :) In my own
> opinion, scs' idea is sound!
> And if I remember correctly, then CakePHP can accepts more than one record
> for the related table if you use the form field definition as
> Model.indexNumber.fieldname - example: Userinfo.0.uservalue.
> That should also make it easier for you to create the 10 additional
> information form fields by looping!
> Enjoy,
>    John
>
> On Jan 6, 9:45 pm, "Dave"  wrote:
> > Yeah I could do that but the average user will not have more than 3 or
> > 4 and honestly its more of a pain to add new, add new, add new 3 or 4
> > times for the user. This way its all done on 1 page in 1 shot.
>
> > -Original Message-
> > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On
> > Behalf
>
> > Of scs
> > Sent: January-06-10 4:02 PM
> > To: CakePHP
> > Subject: Re: Add Fields
>
> > The way I would handle this is to add a new table (1->Many) this way
> > you can allow the user to enter as many fields they want.
> > example:
> > CREATE TABLE profile_addons (
> >   id int(10) unsigned NOT NULL auto_increment,
> >   profile_id int(11) unsigned NOT NULL,
> >   name varchar(75) default NULL,
> >   PRIMARY KEY  (`id`)
> > ) ENGINE=InnoDB AUTO_INCREMENT=1 ;
>
> > On Jan 6, 1:34 pm, "Dave"  wrote:
> > > What would be the easiest way to add say 10 input fields to a form
> > > that hasMany?
>
> > > I am allowing a user to add additional info to a profile and want to
> > > have 10 empty fields where they can type in whatever they want.
>
> > > I can manually make a form with 10 input fields but would like to
> > > know a simplified approach.
>
> > > Working with the idea of a foreach and build the fields but cant
> > > seem to get the idea of how to loop thru when there is nothing to loop
> ):
>
> > > $count++
> > > if $count > 10 type idea
>
> > > Ideas to point me in the right direction would be great.
>
> > > Thanks
>
> > > Dave
>
> > No virus found in this incoming message.
> > Checked by AVG -www.avg.com
> > Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date:
> > 01/06/10 04:05:00
>
> No virus found in this incoming message.
> Checked by AVG -www.avg.com
> Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/06/10
> 04:05: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-

Best practices question

2010-01-07 Thread Foroct
I have a users table and would like to view my users by username with
a url like example.com/users/view/username
In order to do that I have set my view function in my users controller
to
function view($username) {
if (!$username) {
$this->Session->setFlash(__('Invalid User.', true));
$this->redirect('/pages/error');
exit();
}
if ($user = $this->User->findByUsername($username)) {
$this->set('user', $user);
}
if ($this->Auth->user('role') == 'admin') {
// $this->flash('You have admin access');
$this->Session->setFlash(__('You have admin access', 
true));
}
}

While this will work correctly, showing an existing users profile it
fails to redirect to an error page when you replace the username with
one that doesn't exist. As I was looking for an answer to this I found
a few articles that state I should always set my function view to $id
then rewrite the url to contain the username.

I was wondering if there was a best practice to follow or if what I am
doing is okay?
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-07 Thread Kerr
euromark -- I had done that, but for some reason had totally blanked
on the issue.  It was likely due to the fact that I'd been up for 20
hours coding. :/

On Jan 7, 7:52 am, euromark  wrote:
> well, its always a good idea to jump into the section in the cake core
> file
> before you bang your head to any solid objects in the room :)
>
> On 7 Jan., 14:40, Kerr  wrote:
>
> > Thanks for the prompt replies, guys!  I am using $this->Session->setFlash() 
> > in my controller after a successful form submission, then
>
> > redirecting, where I echo $session->flash().  I removed the echo, and
> > all is good!  I can't believe I hadn't thought of that before, as I
> > spent an inordinate amount of time banging my head against the wall.
>
> > Hah, I guess I'll have to keep the echo in mind when migrating to
> > 1.3!  I'm only using $session->flash() in a single place in
> > default.ctp, so no big issue there.
>
> > CakePHP rawks!
>
> > On Jan 7, 2:09 am, euromark  wrote:
>
> > > the problem: you echo too much (twice)
>
> > > remove the echo in front of your method
> > > it is a "void" function - at least in 1.2
>
> > > since cakephp 1.3 it actually returns the value and therefore needs
> > > the echo in front of it!
>
> > > On 7 Jan., 06:44, Jeremy Burns  wrote:
>
> > > > 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: 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


Re: Subdomains

2010-01-07 Thread Juan Luis Baptiste
On Thu, Jan 7, 2010 at 9:31 AM, Jeremy Burns  wrote:
> 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?.
>

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: Routing techniques

2010-01-07 Thread euromark
i would not recommand that
usually http://my.website.com/user/[username]/ or 
http://my.website.com/profile/[username]/
is the better approach

the main problem with your url is that you might get conflicts with
other routes
example:
a user registers with "images"

if you have a controller "images"
you would have the images on http://my.website.com/images
even if you add /profile etc it is at least still confusing

you should be able to accomplish that with custom routes, though
there might be more on that matter in the cookbook


On 7 Jan., 14:19, rahulb  wrote:
> Hello,
>           I want to know whether , there is any way by which I can
> change the routing mechanism of cakephp.
> For example,
>   If i want to change my routing mechanism in such a way that i can
> manipulate urls like these :
>      http://my.website.com/[username]/profile
> Where the [username] will be the name of the user and every new user
> who registers with my site , should be able to access his profile in
> the manner given above.
>
> Is there a way by which this can be achieved.
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


Editing/delete multiple records

2010-01-07 Thread rahul jain
Hi All

I am new to cakephp.
I am displaying list of categories along with check box placed next to
each category.
Now I want to edit/delete only those categories if the check box is
checked.
How can I achieve this in cakephp.
I will highly appreciate the help.

Thanks and Regards
Rahul Jain
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


cakephp und google base / merchants

2010-01-07 Thread euromark
did anyone build a class for interacting with google base or google
merchants
like for publishing products etc.?

you can use the cake1.3 CakeSocket (or HttpSocket in cake1.2) to
connect to the account and its feed and POST the data.

i started to create a lib class for updating the feed via POST of an
xml-file
and thought maybe somebody else came up with something similar idea

gerenelly i can think of 2 different approaches
- behaviour which updates the feed in real time (afterSave and
afterDelete callbacks)
- cronjob which updates the feed frequently (full override with a
complete xml file of all products) - many companies do it this way

I might have to integrate it in an online shop
PS: if somebody is interested in working together (because he/she
needs it as well) feel free to contact 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


Routing techniques

2010-01-07 Thread rahulb
Hello,
  I want to know whether , there is any way by which I can
change the routing mechanism of cakephp.
For example,
  If i want to change my routing mechanism in such a way that i can
manipulate urls like these :
 http://my.website.com/[username]/profile
Where the [username] will be the name of the user and every new user
who registers with my site , should be able to access his profile in
the manner given above.

Is there a way by which this can be achieved.
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-07 Thread dilip bakotiya
Use this

$session->flash();

instead of
echo $session->flash();


Thanks
Dilip Bakotiya

On Thu, Jan 7, 2010 at 11:14 AM, Jeremy Burns  wrote:

> 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.comFor
>  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: setFlash() appending a "1"

2010-01-07 Thread euromark
well, its always a good idea to jump into the section in the cake core
file
before you bang your head to any solid objects in the room :)


On 7 Jan., 14:40, Kerr  wrote:
> Thanks for the prompt replies, guys!  I am using $this->Session->setFlash() 
> in my controller after a successful form submission, then
>
> redirecting, where I echo $session->flash().  I removed the echo, and
> all is good!  I can't believe I hadn't thought of that before, as I
> spent an inordinate amount of time banging my head against the wall.
>
> Hah, I guess I'll have to keep the echo in mind when migrating to
> 1.3!  I'm only using $session->flash() in a single place in
> default.ctp, so no big issue there.
>
> CakePHP rawks!
>
> On Jan 7, 2:09 am, euromark  wrote:
>
> > the problem: you echo too much (twice)
>
> > remove the echo in front of your method
> > it is a "void" function - at least in 1.2
>
> > since cakephp 1.3 it actually returns the value and therefore needs
> > the echo in front of it!
>
> > On 7 Jan., 06:44, Jeremy Burns  wrote:
>
> > > 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: setFlash() appending a "1"

2010-01-07 Thread Kerr
Thanks for the prompt replies, guys!  I am using $this->Session-
>setFlash() in my controller after a successful form submission, then
redirecting, where I echo $session->flash().  I removed the echo, and
all is good!  I can't believe I hadn't thought of that before, as I
spent an inordinate amount of time banging my head against the wall.

Hah, I guess I'll have to keep the echo in mind when migrating to
1.3!  I'm only using $session->flash() in a single place in
default.ctp, so no big issue there.

CakePHP rawks!

On Jan 7, 2:09 am, euromark  wrote:
> the problem: you echo too much (twice)
>
> remove the echo in front of your method
> it is a "void" function - at least in 1.2
>
> since cakephp 1.3 it actually returns the value and therefore needs
> the echo in front of it!
>
> On 7 Jan., 06:44, Jeremy Burns  wrote:
>
> > 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: Login after registration not working

2010-01-07 Thread Dr. Loboto
Auth automagically hashes $this->data['User']['password'] before
action call. As Auth do not know that field "password1" is also a
password it did not hashed. So you need to do it manually.

On Jan 4, 6:19 am, EwBoonTwo  wrote:
> (Kind of) SOLUTION
>
> I've kept tinkering and noticed that the log in query was trying to
> use the unhashed password. So, I changed the register method from
> this:
> ...
> // log the user in to his new account
> $this->data['User']['password'] = $this->data['User']['password1'];
> ...
>
> to this:
> ...
> // log the user in to his new account
> $this->data['User']['password'] = $this->Auth->password($this->data
> ['User']['password1']);
> ...
>
> This did the trick. But, I'm surprised. I thought Auth was supposed to
> hash the password automagically. If I'm right about that, then I must
> be still doing something wrong and would love any insight.
>
> On Jan 3, 11:38 am, OohBunToo  wrote:
>
>
>
> > Hey all,
>
> > I'm trying to set up a user registration system that uses the Auth
> > component. I've set up both the registration and login parts of my
> > site, and separately each work as expected (i.e. a user can register
> > and is saved to the database, and a user can log in separately once
> > registered). But, I can't get seem to get the Auth component to log in
> > users automatically once they've registered.
>
> > I've poured over Google searches, the cookbook, the API documentation,
> > but nothing seems to get me around my issue.
>
> > Here's the beforeFilter in my app_controller:
> > function beforeFilter() {
> >     // Override the default fields used by Auth component
> >     $this->Auth->fields = array(
> >         'username'=>'email',
> >         'password'=>'password'
> >     );
>
> > Here are the beforeFilter and register methods in my users_controller:
> > function beforeFilter() {
> >     parent::beforeFilter();
> >     $this->Auth->allow(array('register', 'login', 'logout'));
>
> > }
>
> > function register() {
> >     if($this->Session->read('User.signedIn')) {
> >         $this->redirect(array('action'=>'account'));
> >     }
>
> >     if (!empty($this->data)) {
> >         $this->User->create();
> >         if ($this->User->save($this->data)) {
> >             // log the user in to his new account
> >             $this->data['User']['password'] = $this->data['User']
> > ['password1'];
> >             $this->Session->setFlash(__('Hooray! The User has been
> > saved', true));
> >             $this->Auth->login($this->data);
> >             $this->redirect($this->Auth->redirect());
> >         } else {
> >             $this->Session->setFlash(__('Uh oh! That didn\'t work.
> > Please, try again.', true));
> >         }
> >     }
>
> > }
>
> > The redirect takes place, but the user isn't actually getting logged-
> > in. Instead, they're dropped onto the login form with the
> > "Hooray! ..." flash message as well as the "You are not authorized..."
> > Auth flash message. So, it's clear that the $this->Auth->login($this-
>
> > >data) line isn't doing what's expected.
>
> > I've confirmed that the $this->data array contains the right keys and
> > values using debug:
> > app/controllers/users_controller.php (line 31)
>
> > Array
> > (
> >     [User] => Array
> >         (
> >             [email] => asdfi...@grr.com
> >             [password1] => aaa
> >             [password2] => aaa
> >             [password] => aaa
> >         )
> > )
>
> > So, I'm out of ideas. I really want to use the Auth component, but the
> > learning curve is giving me headaches. Any help will be hugely
> > 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: Make objects from model data

2010-01-07 Thread Grzegorz Pawlik
It has little to do with MVC, because You are referring to ORM. And
it's working different in cake.
You can call
$this->SomeModel->read(null, 1); // 1 is an id
Then You can read/write particular field this way:
$this->SomeModel->data["SomeModel"]["name"] = "new_name";
$this->SomeModel->save();

I don't this it works with getting more than one element (via
Model::find())

On 6 Sty, 05:29, frmdstryr  wrote:
> When I was learning php classes we made a model object for each type
> of data we had. Each model would have crud from another class and then
> model specific functions & attributes. For example i would have:
>
> class Person extends Crud {
>     var $first_name;
>     var $last_name;
>
>  static  function getperson{
>      return Crud::get(people,$sql);
>     }
>
>    function full_name() {
>       return $this->first_name . ' '. $this->last_name;
>    }}
>
> class Crud {
> // crud
>    static  function get() { sql stuff; return mysql_rows}
>     static function delete() {sql stuff; }
>     }
>
> something like that, but anyways we would instantiate each item
> returned from the getallPeople() into a person object and then if i
> wanted to get the full name of the person i would just type:
>
> $person = Person::getperson(id);  //creates person object
> $person->full_name();                 // use object function
>
> this made it really easy because if i wanted to add something to the
> person all i had to do was change the Person object model.  I cant get
> this to work with cakephp models.  What do i need to do for this to
> work or do I not understand cakephp's models & MVC right?
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: Validate Question

2010-01-07 Thread John Andersen
Hi Dave,

Is your rule made in accordance with CakePHP custom validation rules?
If yes, then I don't see a better solution.

See 
http://book.cakephp.org/view/150/Custom-Validation-Rules#Adding-your-own-Validation-Methods-152
for the custom validation rules.

Enjoy,
   John

On Jan 7, 7:48 am, "Dave"  wrote:
> Using the inList validation rule I have 2 questions.
>
> 'rule' => array('inList', array('0', '1', '2','3', '4', '5', '6', '7')),
> will allow values matching 0 thru 7 anything else is invalid
>
> So my first question is if I created an variable array of values from a find
> could i just use 'rule' => array('inList', $myListVariable),
>
> and if that is possible how do i get the $myListVariable into the validation
> function?
>
> Or is better to just stick with what im currently doing. For example I have
> my country select list and it has a validation 'rule' =>
> array('checkCountryValues'),
>
> Model function for the country validation
> /*
>  Form Modification Validation
>  Checks that entered values for Country are Valid
>
>  */
>   public function checkCountryValues($data)
>       {
>     $valid = false;
>     $model_table = Inflector::classify($this->useTable);
>
>     if (!empty($this->data))
>     {
>      // this section matches values against database
>      $value = array($this->data[$model_table]['country_id']);
>      $results = array_diff($value, $this->Country->find('list',
> array('fields' => 'id')));
>
>      if (empty($results))
>
>      $valid = true;
>     }
>
>   return $valid;
>       }
>
> So if anyone messes with the form it returns invalid.
>
> Ideas?
>
> 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: Conceptual problem Model on View ..

2010-01-07 Thread Grzegorz Pawlik
You should put the code in Your model. And in afterFind callback
iterate through stuff You got, call can_close() and if true - add some
virtual field to retrieved data (virtual = not in DB, but appears in
results array after find()).
It's similar to advice above, but keeps "Fat Model, Skinny Controller"
and DRY concepts. But only use it, when You need this virtual fields
in every result on that model :)
See: http://book.cakephp.org/view/681/afterFind

On 7 Sty, 05:09, qwanta  wrote:
> You would put the code to calculate the can_close values for each row
> in the model or in the controller.
>
> To put the code in the model, do not use find('all') but create your
> own method in the model, for example find_all_model_a. Now in this
> function, call $r = $this->find('all'), then iterate through the
> result array $r using a foreach and add a field called "can_close"
> that is true or false based on your criteria. From the controller you
> call $ma = $this->MODEL_A->find_all_model_a(). Then $this->set('ma',
> $ma); and ma contains everything you need in the controller with logic
> in the model.
>
> On Jan 6, 4:13 pm, Bottazzo  wrote:
>
> > I ll up this post just one more time.. thanks.
>
> > On 4 jan, 16:18, Bottazzo  wrote:
>
> > > Yes Dave, this is what I do now. But, if the condition can_close() is
> > > more than check  if the status fields == 'OPEN' ? .. for ie: check
> > > status field + check parent model status + check created date .. (and
> > > in the future add more instructions in can_close() )...  so... i
> > > really need to call the can_close() method .. right?
>
> > > Can you understand my problem now man? Do what u say it's solving my
> > > problem now.. but in the future.. can cause some problem to me..
>
> > > :)
>
> > > Thanks for the reply Dave!
>
> > > On Dec 31 2009, 3:55 am, "Dave"  wrote:
>
> > > > Not sure if I follow 100% but why not just grab the data where its OPEN?
>
> > > > $this->find('all', array('conditions' => array('MODEL_A.status' =>
> > > > 'open')));
>
> > > > Or if you need to grab all the data then add the "close" link to OPEN 
> > > > cases
> > > > do the foreach
> > > > Controller: (or better yet make a function in the MODEL)
> > > > $this->set('cases', $this->find('all'));
>
> > > > VIEW:
>
> > > > Foreach ($cases as $case)
> > > > {
> > > >         if ($case['Model']['status'] = 'open')
> > > >         {
>
> > > >                 $case_status = "button code here";
>
> > > >         } else {
>
> > > >                 $case_status = 'Case Closed';
>
> > > >         }
>
> > > > Your looped data / html  so if its open it 
> > > > will
> > > > add the button,if not "Case Closed"  will be there
>
> > > > }
>
> > > > Not 100% ure of the question but hope that helps. Maybe someone else 
> > > > has a
> > > > different idea.
>
> > > > Dave
>
> > > > -Original Message-
> > > > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On 
> > > > Behalf
>
> > > > Of Bottazzo
> > > > Sent: December-30-09 10:31 AM
> > > > To: CakePHP
> > > > Subject: Conceptual problem Model on View ..
>
> > > > Hi guys, im don't speak english but ill try to explain my problem for 
> > > > u. So,
> > > > sorry for my poor english.
>
> > > > Ok, let imagine that I have an Model named MODEL_A that have an status 
> > > > field
> > > > ( OPENED and CLOSED )..
> > > > I have an method on MODEL_A named can_close() that return true if i can
> > > > close the element..
>
> > > > I want to show a list of MODEL_A elements in the page.. so in the 
> > > > controller
> > > > I call a MODEL_A->find(all).. ok.. get all instances...and $this->set to
> > > > view... nice!
>
> > > > Ok, now i have all my MODEL_A elements on VIEW... and I want to do
> > > > this: foreach element check .. if MODEL_A->can_close()  == true...
> > > > show button CLOSE .. on the side of element name.. if can_close() == 
> > > > false..
> > > > hide it.
>
> > > > So... a ill need to import my model to the view.. to call can_close 
> > > > method..
> > > > right? but.. call model on view is the worst sin for MVC pattern ahn??
>
> > > > So.. what I do now friends?
>
> > > > Thank you for all..
>
> > > > 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 For more options, visit this group
> > > > cake-php+athttp://groups.google.com/group/cake-php?hl=en
> > > > No virus found in this incoming message.
> > > > Checked by AVG -www.avg.com
> > > > Version: 9.0.722 / Virus Database: 270.14.122/2590 - Release Date: 
> > > > 12/30/09
> > > > 03:57:00
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this

Re: setFlash() appending a "1"

2010-01-07 Thread euromark
the problem: you echo too much (twice)

remove the echo in front of your method
it is a "void" function - at least in 1.2

since cakephp 1.3 it actually returns the value and therefore needs
the echo in front of it!

On 7 Jan., 06:44, Jeremy Burns  wrote:
> 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