Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Second administrator with different admin templates

Quote Reply
Second administrator with different admin templates
Hello,
I am trying to add a different adminstrator to my LINKS SQL but with his/her own admin template set.
Therefore, I did the following:

1 - Made new copy of admin.cgi and called it second_admin.cgi.
2 - Made new copy of of the entire directory structure ".../templates/admin" and called it ".../templates/second_admin" and modified them with different colors.
3 - Changed the template name set in second_admin.cgi from ".../templates/admin" to ".../templates/second_admin"

Now, I loaded .../links/admin/second_admin.cgi but I am still getting the ".../templates/admin" templates loaded instead of ".../templates/second_admin" templates?

Any idea please!!?
maybe I still need to change some path or something in header of the second_admin.cgi but I do not know where exactly...

Thank you
Mark
Quote Reply
Re: [Mark2] Second administrator with different admin templates In reply to
This is because the admin templates are defined in sub admin_page in Links.pm. You would need to make your changes in there.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Second administrator with different admin templates In reply to
Hi Alex,

Thank you for yor reply..

I looked at the Links.pm. It seems that the only thing that can determine which Administrator is logged in is the name of the admin file that was used, which is in my case, could be admin.cgi or second_admin.cgi.
Then if I know the name, then I can load the right template set for it using this logic:

if requesting file was admin.cgi
load templates/admin templates
else
load templates/second_admin templates
fi;

..... but how would I do this condition in the code?
Can you please point it out.
Thank you

here is some of the code of sub admin_page:
Code:


sub admin_page {

# ------------------------------------------------------------------

# Display an admin template page.

#

(defined $_[0] and $_[0] eq 'Links') and shift;

my ($file, $params, $opts) = @_;

my $cookies = [];

if ($IN->param('set-cookie')) {

foreach my $key ($IN->param) {

if ($key =~ /^cookie-(.*)/) {

my $path = $IN->param("cookie_path-$1") || '/';

my $exp = $IN->param("cookie_exp-$1") || '+5y';

push @$cookies, $IN->cookie(-name => $1, -value => $IN->param($key), -path => $path, -expires => $exp);

}

}

}

@$cookies ? print $IN->header (-cookie => $cookies ) : print $IN->header();

$file ||= $IN->param('page');

$file =~ /\.\./ and return die "Invalid template '$file' requested (Invalid name)";

$file =~ m,^/, and return die "Invalid template '$file' requested (Invalid name)";



-e "$CFG->{admin_root_path}/templates/admin/$file" or return die "Invalid template '$file' requested (File does not exist)";

-r _ or return die "Invalid template '$file' requested (Permission denied)";

# Add on $IN

$params ||= [];

my $cgi = $IN->get_hash;

foreach (keys %$cgi) {

$cgi->{$_} = (ref $cgi->{$_} eq 'ARRAY') ? join ("\n", @{$cgi->{$_}}) : $cgi->{$_};

}

ref $params eq 'ARRAY' ? (push @$params, $cgi) : ($params = [$cgi, $params]);

# Make sure a root is set.

$opts ||= {};

$opts->{root} ||= "$CFG->{admin_root_path}/templates/admin";

defined $opts->{print} or ($opts->{print} = 1);

# Print the page.

GT::Template->parse ( $file, $params, $opts );

}



Thank you in advance for your help
Mark