Webcraft-Myplanet/wow-skeletor — pull request #245 by sjagr (2014-03-27 17:07:33+00:00)
Title: User Profile overhaul - fixes left column issue forevahhh

With a major change in the hook strategy, an explanation should be in order...

I found that the idea of using absolute positioning to place the left bar into the heading bar and overlap under the `h1` tag to be a bit messy... so I decided a re-structure of the `h1` and other various things into the left-side column would be a much better approach. This strategy requires that the `page.tpl.php` file be changed... but we don't want to change everything else in the website (because a fluid container for edit pages, projects timeline, etc. looks... ugh.)

The solution? Make a new `page.tpl.php` that hooks only into the User Profile page. Take the left sidebar from `user-profile.tpl.php` and throw it into this new User Profile page template, and include the `h1` in the left sidebar, as well as move messages to the right content area. Looks good! But the template name `page--user.tpl.php` is catching for **all** user pages, including the edit page and login page. There doesn't seem to be a specific user profile page hook such as `page--user--profile.tpl.php`, and `page--user--%.tpl.php` works but includes the edit page still.

The solution was to implement the following hook:

function unicorn_preprocess_page(&$vars) {
$vars['content_column_class'] = ' class="col-xs-offset-1 col-xs-10"';
if (arg(0) === 'user' || arg(0) === 'users') {
if (arg(2) !== 'edit') {
$vars['content_column_class'] = ' class="col-xs-12"';
// Make sure the user profile page hook is specifically called
$vars['theme_hook_suggestion'] = 'page__user__profile';
}
}
}

By setting `$vars['theme_hook_suggestion']` to a specific hook, Drupal is forced to load that `.tpl.php` page. [See here for more info](https://drupal.org/node/223440#custom-suggestions)

All of this along with a lot of tweaking and we now have an awesome user profile page (although we may need to do some further tweaking.. but now we can focus on other things rather than fixing this column all the time.)