Gossamer Forum
Quote Reply
Get a user
Hi,

How can I access all the fields of a specific user from anywhere?

Ex:
<%load_user($klaus)%>
<%Name%>
<%Designation%>

<%load_user($peter)%>
<%Name%>
<%Designation%>

Thanks in advance
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Get a user In reply to
From anywhere? Or in the templates?

In the templates, you need a global, called Fetch_User which, as you show, takes a Usesrname and loads the fields for that username. There are several pitfalls, akin to name-space collisions, but if you know the users ahead of time, you can avoid that.

What you need to do in the global is to simple call the Users table using Username=>$user where $user is the passed in username.

The *problem* is passing this back to the template. The fields will cause a name-space collision.

So, the *best* way to deal with it, is to have the global load the template, and return a formatted string to the original template. You can either embed the HTML in the global, or load the template into the global.

By returning the formatted string, you avoid the potential collisions.

I can try to hack this later, it shold only be a few lines of code, or a minor change to one of the existing globals, but it's to chaotic here now.

<%Fetch_User('string')%>
<%returned_user%>

<%Fetch_User('string2')%>
<%returned_user%>

The function should be initialized each time it's called, and the value of <%returned_user%> should change based on the most recent call.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [klauslovgreen] Get a user In reply to
For future reference see:

http://www.gossamer-threads.com/...i?post=234573#234573

For those not wanting to load editor records, just remove Editors from the table call.
Quote Reply
Re: [pugdog] Get a user In reply to
Thanks for your help pugdog - Paul's global did the trick :-)

Klaus

http://www.ameinfo.com