Changeset 325

Show
Ignore:
Timestamp:
09/21/07 21:26:39 (1 year ago)
Author:
btrott
Message:

Switched to using a template_source callback rather than template_output,
which makes it a little bit easier to catch all of the places where we
need to add the Other Profile nav item.

And now, Other Profiles is highlighted properly when you're on that screen.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Elsewhere/plugins/Elsewhere/elsewhere.pl

    r323 r325  
    4343        }, 
    4444        callbacks => { 
    45             'MT::App::CMS::template_output.edit_author' => sub { 
    46                 $plugin->insert_profile_link( @_ ); 
    47             }, 
    48             'MT::App::CMS::template_output.other_profiles' => sub { 
     45            'MT::App::CMS::template_source.users_content_nav' => sub { 
    4946                $plugin->insert_profile_link( @_ ); 
    5047            }, 
     
    8784sub insert_profile_link { 
    8885    my $plugin = shift; 
    89     my( $cb, $app, $html_ref, $param, $tmpl ) = @_; 
     86    my( $cb, $app, $html_ref ) = @_; 
    9087    my $base_uri = $app->uri; 
    91     $$html_ref =~ s/(<li>.*?Permissions<\/a><\/li>)/$1\n<li><a href="$base_uri?__mode=other_profiles">Other Profiles<\/a><\/li>/; 
     88    my $mode = $app->mode; 
     89    my $active = $mode eq 'other_profiles' ? ' class="active"' : ''; 
     90    if ( $active ) { 
     91        $$html_ref =~ s/<li class="active">/<li>/g; 
     92    } 
     93    ## Somewhat nasty: we need to match in users_content_nav.tmpl under 
     94    ## only certain scenarios, i.e. in the Author Profile cases of that 
     95    ## template. Yuck. 
     96    $$html_ref =~ s/(<li[^>]*>.*?author_id=.*?<__trans phrase="Permissions"><\/a><\/li>)/$1\n<li$active><a href="$base_uri?__mode=other_profiles">Other Profiles<\/a><\/li>/g; 
    9297} 
    9398