Glad to hear you were able to get that resolved.

Check out the documentation for the Auth component
http://book.cakephp.org/view/172/Authentication, in particular the
user method http://book.cakephp.org/view/387/user.

On Feb 24, 3:04 pm, deek <derek.bon...@gmail.com> wrote:
> Andy,
>
> It looks like the debug issue was the problem and everything is now
> working properly.
>
> My final question is this.  Once a user is logged on (through the
> built-in Auth of CakePHP), what built-in functions should I use to
> determine that user's id number? For that matter what is a good way to
> test of a user is logged on or not? I ask because I would like some
> options/posts to be shown only to logged in (Admin) users.
>
> Currently this is my form for creating an new post:
> <h1>Add Post</h1>
> <?php
> echo $form->create('Post');
> echo $form->input('title');
> echo $form->input('category');
> echo $form->input('body', array('rows' => '10', 'columns' => '40'));
> echo $form->radio('frontpage', array('1'=>'Yes','0'=>'No'));
> echo $form->end('Save Post');
> ?>
>
> I want to thank everyone who has helped out with my questions.
>
> On Feb 24, 7:21 am, Andy Dirnberger <andy.dirnber...@gmail.com> wrote:
>
>
>
> > If you have debug set to 0 in core.php and added displayname to the
> > user table after Cake first saw the it, you need to update the cache
> > of the table's layout. (Either set debug to 1, reload the page, and
> > set it back to 0 or delete the file in tmp.)
>
> > On Feb 24, 2:36 am, deek <derek.bon...@gmail.com> wrote:
>
> > > Also when I try and add a user with this form
> > > <h1>Add User</h1>
> > > <?php
> > >     echo $form->create('User', array('action' => 'register'));
> > >     echo $form->input('username');
> > >     echo $form->input('displayname');
> > >     echo $form->input('password');
> > >     echo $form->end('Add User');
> > > ?>
>
> > > the displayname never makes it to the MySQL database. I have no idea
> > > why not
>
> > > On Feb 23, 11:27 pm, deek <derek.bon...@gmail.com> wrote:
>
> > > > Well everything seems to be working now with "var $belongsTo =
> > > > array('User');" but I have tried putting "<?php echo $post['User']
> > > > ['displayname']; ?>" in my index.ctp and the it does not output any of
> > > > the information.  If I put <?php echo $post['User']['id']; ?> or <?php
> > > > echo $post['User']['username']; ?> those values will output just fine
> > > > but not displayname, what might cause this?
>
> > > > On Feb 23, 8:36 pm, Andy Dirnberger <andy.dirnber...@gmail.com> wrote:
>
> > > > > Did you try just using "var $belongsTo = array('User');"? The values
> > > > > you are supplying for className and foreignKey should be the defaults.
>
> > > > > If you remove the $belongsTo piece, do your posts show up again? If
> > > > > not, what else did you change? What code do you currently have in your
> > > > > controller? No special code is needed in your controller to handle
> > > > > relationships, and you'd only need to add code to your User model
> > > > > (e.g., var $hasMany = array('Post');) if you wanted posts to be
> > > > > retrieved every time you query your user table, which you probably
> > > > > don't.
>
> > > > > Once you have it working, 'User'] will be added as an index alongside
> > > > > 'Post' (e.g., $post['User']['displayname']).
>
> > > > > On Feb 23, 5:16 pm, deek <derek.bon...@gmail.com> wrote:
>
> > > > > > So I updated my post model to what you see below and now when I go 
> > > > > > to
> > > > > > my index (index.ctp) view that I have listed on my first post 
> > > > > > nothing
> > > > > > shows up. Do I need to add anything in the controllers or the user
> > > > > > model?  Once get it to show properly how would I call the the User
> > > > > > displayname in my foreach loop in the index.ctp?
>
> > > > > > class Post extends AppModel {
> > > > > >     var $name = 'Post';
> > > > > >     var $belongsTo = array (
> > > > > >         'User' => array(
> > > > > >             'className' => 'User',
> > > > > >             'foreignKey' => 'user_id'
> > > > > >         )
> > > > > >     );
> > > > > >     var $validate = array (
> > > > > >         'title' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'category' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'body' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'frontpage' => array(
> > > > > >             'rule' => 'numeric'
> > > > > >         )
> > > > > >     );}
>
> > > > > > On Feb 23, 12:01 am, WebbedIT <p...@webbedit.co.uk> wrote:
>
> > > > > > > ^^ What @Andy says is right.
>
> > > > > > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > > > > > relationships ... whichever model your foreign_key is in, it 
> > > > > > > belongs
> > > > > > > to the other model.
>
> > > > > > > Welcome to CakePHP, it should make learning complex PHP a lot 
> > > > > > > easier
> > > > > > > for you.  I sometimes wish I hadn't taught myself a lot of bad 
> > > > > > > habits
> > > > > > > by learning raw PHP first :)

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

Reply via email to