Author Topic: Extended Profile theme_linktree();  (Read 2188 times)

0 Members and 1 Guest are viewing this topic.

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Extended Profile theme_linktree();
« on: February 09, 2009, 06:23:28 PM »
The theme_linktree() is the "tree" you see above your forums that tells you where you currently are.

For example:

SMF Helper > Simple Tricks > Start new topic

Currently SMF is designed to only show this tree in messages and other areas, but doesn't include the areas/subactions of those other areas.

If you visit your profile, regardless if you're viewing "posts" of a user or if you're perhaps editing your own profile, the linktree remains at {your_forum} > Profile.

I have the solution to extend the linktree to include all other actions while you're in your profile.

Example, if I'm ccbtimewiz and viewing Smoky's profile:

{your_forum} > Viewing the profile of Smoky > [Profile Info] Summary

Or if I'm ccbtimewiz and viewing my own profile:

{your_forum} > Profile > [Profile Info] Summary.


This code is for SMF 2.0 RC1.

Open ./Sources/Profile.php

Find:
:
// Auto populate the above!
$defaultAction = false;
$defaultInclude = false;
$context['completed_save'] = false;
$context['password_areas'] = array();
$security_checks = array();
$include_file = false;
$requestedAreaValid = false;

Replace with:
:
// Auto populate the above!
   $category = false;
$defaultAction = false;
$defaultInclude = false;
$context['completed_save'] = false;
$context['password_areas'] = array();
$security_checks = array();
$include_file = false;
$requestedAreaValid = false;

Find:
:
// Set the page title if it's not already set...
if (!isset($context['page_title']))
$context['page_title'] = $txt['profile'] . ' - ' . $txt[$_REQUEST['area']];

Add After:
:
// Building up the theme_linktree().
# First, the owner of the profile, or if you're the owner, just show "profile".
if ($context['user']['is_owner'])
$context['linktree'][] = array(
'url' => $scripturl . '?action=profile',
'name' => 'Profile',
);
else
$context['linktree'][] = array(
'url' => $scripturl . '?action=profile;u=' . $context['id_member'],
'name' => 'The profile of ' . $context['member']['name'],
);

# Showing what area and category we're in...
if ($profile_include_data['file'] == 'Profile-View.php')
$category = $txt['profileInfo'];

if ($profile_include_data['file'] == 'Profile-Modify.php')
$category = $txt['profileEdit'];

if ($profile_include_data['file'] == 'Profile-Actions.php')
$category = $txt['profileAction'];

if (empty($profile_include_data['file']))
log_error('Linktree malfunction in profile.');

if (!empty($category))
$context['linktree'][] = array(
'url' => $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=' . $profile_include_data['current_area'],
'name' => '[' . $category . '] ' . $profile_include_data['label'],
);

# Showing any sub-actions...
if ((!empty($_REQUEST['sa']) && (!empty($profile_include_data['subsections'][$_REQUEST['sa']][0]))))
$context['linktree'][] = array(
'url' => $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=' . $profile_include_data['current_area'] . ';sa=', $_REQUEST['sa'],
'name' => $profile_include_data['subsections'][$_REQUEST['sa']][0],
);

// End of theme_linktree() code....
« Last Edit: February 10, 2009, 02:27:22 PM by ccbtimewiz »

Offline Smoky

  • who, me?
  • Guru
  • *
  • Posts: 3980
  • Karma: 1450
  • Gender: Female
  • It's all in your HEAD!
    • HangOutSpot
  • SMF Version: 2.0 ??
Re: Extended Profile theme_linktree();
« Reply #1 on: February 09, 2009, 06:27:59 PM »
kewl ccb  :lmao

how come they didnt add that bit into smf before??  :ntme
Oh wow, guess who dropped by! Im still on secondlife.. but will respond to im's *waves

Offline tyty1234

  • V.I.P.
  • *
  • Posts: 823
  • Karma: 1109
  • Gender: Male
    • tytyweb
  • SMF Version: 2.0.2
Re: Extended Profile theme_linktree();
« Reply #2 on: February 09, 2009, 10:58:33 PM »
This would be a great thing to add into RC2, or maybe even gold.  :grin :dnc

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Extended Profile theme_linktree();
« Reply #3 on: February 16, 2009, 04:46:58 PM »
Nice trick ccb. :)

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: Extended Profile theme_linktree();
« Reply #4 on: October 25, 2009, 08:17:05 PM »
Just a note-- SMF 2.0 RC2 will include this hack, so there is no need to perform it for versions later than SMF 2.0 RC1.2.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Extended Profile theme_linktree();
« Reply #5 on: October 25, 2009, 08:20:29 PM »
Good to know. :)

Offline yimseo

  • New Member
  • *
  • Posts: 1
  • Karma: 0
  • Gender: Male
    • hosting
  • SMF Version: 1.1.11
Re: Extended Profile theme_linktree();
« Reply #6 on: May 08, 2010, 10:34:45 AM »
Wow! Nice, I will use it with my forum
High Quality hosting
web hosting Fast & Reliable