Gossamer Forum
Home : Products : Gossamer Links : Discussions :

User_Status

Quote Reply
User_Status
We are asking more and more of link.html, but the User tags don't seem to be available. isLinkOwner is not always enough, the User->{Status} (Administrator, Editor, User, etc) is often more important for providing options.

I've asked Alex to consider adding in the following line to site_html_link:

Code:
(defined $Links::USER->{Status}) ?
($rec->{'User_Status'} = $Links::USER->{Status}) :
($rec->{'User_Status'} = 0);


But, you can get the same effect with the following template global:

Code:
User_Status => sub {
(defined $Links::USER->{Status}) ? (return $Links::USER->{Status}) : (return 0);
}


This is *extremely* useful for showing admin-only options in the templates during debugging, or for enhancing features such as edit/modify/add features beyond what 'isLinkOwner' can do.

Example:

Code:
<%if User_Status eq 'Administrator'%>
<%GT::Template::dump%>
<%endif%>


And that way, your site can still function "normally" while you try to debug or change some templates.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] User_Status In reply to
Or you could create something more flexible by allowing yourself to pass in the key you want.....

Code:
sub {
return exists $Links::USER->{$_[0]} ? $Links::USER->{$_[0]} : '';
}

Then in your template you can pas in any field from the user table..eg...

<%MyGlobal(Username)%>
Quote Reply
Re: [Paul] User_Status In reply to
Not bad :)

User_Data => sub {
return exists $Links::USER->{$_[0]} ? $Links::USER->{$_[0]} : '';
}

and in the templates use

<%User_Data(Status)%>


*BUT* the construct above doesn't seem to work in the <%if%> clause, so you still need to use a variable, not a function call to make that work.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] User_Status In reply to
>>
*BUT* the construct above doesn't seem to work in the <%if%> clause, so you still need to use a variable, not a function call to make that work.
<<

Maybe it will work with a set tag?

<%set my_username = myglobal(Username)%>

I did think you could use globals and functions in if tags though.
Quote Reply
Re: [Paul] User_Status In reply to
That doesn't work either.

It seems to be a function of the behavior of the template globals not being recognized as a true "function" in terms of the parser.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.