Never mind. So far two posts... ZERO answers... I kept banging on it
and fixed it.
Instead of using ($session->check...), which now I learned returns
true or false, I am now using ($session->read...) which works well.
I guess I have to figure out the right combination of things to put
into a post in order to receive an answer from this group. I will keep
trying.
In case any other newbie has this issue, here is the code that works:
<div id="navbar">
<ul>
<?php if ($session->read('Auth.User.group_id') == 1): ?>
<li><?php echo $html->link(__
('distributors',true),''.'/'.'distributors'); ?></li>
<li><?php echo
$html->link(__('dealers',true),''.'/'.'dealers'); ?
></li>
<li><?php echo
$html->link(__('groups',true),''.'/'.'groups'); ?></
li>
<li><?php echo
$html->link(__('users',true),''.'/'.'users'); ?></
li>
<?php elseif ($session->read('Auth.User.group_id') ==
2): ?>
<li><?php echo $html->link(__
('distributors',true),''.'/'.'distributors'); ?></li>
<?php elseif ($session->read('Auth.User.group_id') ==
3): ?>
<li><?php echo
$html->link(__('dealers',true),''.'/'.'dealers'); ?
></li>
<?php endif;?>
<?php if (!$session->check('Auth.User.id')): ?>
<li><?php echo $html->link(__
('login',true),''.'/'.'users'.'/'.'login'); ?></li>
<?php else: ?>
<li><?php echo $html->link(__
('logout',true),''.'/'.'users'.'/'.'logout'); ?></li>
<?php endif;?>
</ul>
</div>
On Aug 7, 1:23 pm, FrederickD <[email protected]> wrote:
> I am in a quandary as to what is wrong with this code:
>
> <div id="navbar">
> <ul>
> <?php if ($session->check('Auth.User.group_id') ==
> 1): ?>
> <li><?php echo $html->link(__
> ('distributors',true),''.'/'.'distributors'); ?></li>
> <li><?php echo
> $html->link(__('dealers',true),''.'/'.'dealers'); ?></li>
>
> <li><?php echo
> $html->link(__('groups',true),''.'/'.'groups'); ?></
> li>
> <li><?php echo
> $html->link(__('users',true),''.'/'.'users'); ?></
> li>
> <?php elseif ($session->check('Auth.User.group_id')
> == 2): ?>
> <li><?php echo $html->link(__
> ('distributors',true),''.'/'.'distributors'); ?></li>
> <?php elseif ($session->check('Auth.User.group_id')
> == 3): ?>
> <li><?php echo
> $html->link(__('dealers',true),''.'/'.'dealers'); ?></li>
>
> <?php endif;?>
> <?php if (!$session->check('Auth.User.id')): ?>
> <li><?php echo $html->link(__
> ('login',true),''.'/'.'users'.'/'.'login'); ?></li>
> <?php else: ?>
> <li><?php echo $html->link(__
> ('logout',true),''.'/'.'users'.'/'.'logout'); ?></li>
> <?php endif;?>
> </ul>
>
> </div>
>
> The "If" construct at the bottom works to toggle the 'Login' and
> 'Logout' buttons. However, the "If" construct above based on
> 'Auth.User.group_id' always acts as if the value == '1'
>
> I have DebugKit installed and it shows the value of 2 for the person
> logged in through Session->Auth->User. The field 'group_id' is a
> foreign key in the Users table.
>
> Please help me out here! Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---