From: Chris W. <ch...@cw...> - 2002-06-04 11:04:19
|
On Tue, 2002-06-04 at 03:34, Die...@Be... wrote: > Hi Chris, > > we try to show user or group specific startup pages after login. > Now, after login, the first page is the ../html/index.html. > Could you please tell us how to call user- or group-dependent startup-pages? You could do this one of two ways: 1) Make the normal startup page (/index.html) display certain information based on group membership using normal template directives: html/index.html: ---------------------------------------- [%- is_manager = 0; is_marketing = 0; ... -%] [% FOREACH group = OI.login_group %] [% SET is_manager = 1 IF group.id == 4; SET is_marketing = 1 IF group_id == 5; ... %] [% END %] [% IF is_manager %] Hi manager! Here is your information ... [% ELSIF is_marketing %] Hi marketer! Here is your information ... [% ELSE %] Hi common user! Here is your information ... [% END %] ---------------------------------------- Instead of embedding the information in the page, you could also have the content be templates and do something like: ---------------------------------------- [% IF is_manager %] [% INCLUDE startup_manager %] [% ELSIF is_marketing %] [% INCLUDE startup_marketing %] [% ELSE %] ... [% END %] ---------------------------------------- And create $WEBSITE_DIR/template/startup_manager and $WEBSITE_DIR/template/startup_marketing with the information you want. 2) Create a component to do this for you: In the startup page, just have: html/index.html: ---------------------------------------- [% OI.comp( 'lookup_starting_page' ) %] ---------------------------------------- And then create a component in one of your packages: conf/action.perl: ---------------------------------------- $action = { lookup_starting_page => { class => 'OpenInteract::StartingPage', method => 'handler', }, }; ---------------------------------------- mypkg/OpenInteract/StartingPage.pm: ---------------------------------------- package OpenInteract::StartingPage; sub handler { my ( $class ) = @_; my $R = OpenInteract::Request->instance; unless ( $R->{auth}{logged_in} ) { return 'Sorry, not logged in.'; } foreach my $group ( @{ $R->{auth}{group} } ) { return $class->get_page( 'marketing' ) if ( $group->id == 4 ); return $class->get_page( 'management' ) if ( $group->id == 5 ); } return $class->get_page( 'main' ); } sub get_page { my ( $class, $type ) = @_; # ... code to pull the page from the filesystem/database # based on the type ... } ---------------------------------------- In theory you could also implement a custom login handler to do this, but right now there is no support for short-circuiting the process in this manner to return content directly. I'll get something along these lines (redirects, at least) implemented for the next version since it's pretty useful. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |