We'll need to be able to figure out if the profile a user is looking at is their own. So, let's add a variable to our view that tells us if that is the case.
1. Open
index.php
, and add a variable calledis_current_user
that will determine if the profile that you are viewing is equal to the currently logged-in user.get('/user/:username', function($app) { $app->set('user', User::get_by_username($app- >request('username'))); $app->set('is_current_user', ($app->request('username') == User::current_user() ? true : false)); $app->render('user/profile'); });
2. Let's change the code in the header of
views/user/profile.php
so that we can output the user's full name as well asThis is you!
, if it's the current user's profile.<div class=-page-header-> <h1><?php echo $user->full_name; ?> <?php if ($is_current_user) { ?> <code>This is you!</code> <?php } ?> </h1> <...