Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Get avatar outside of forum
Avatar
Focus97
Member
Free Members
sp_UserOfflineSmall Offline
Apr 3, 2012 - 8:35 pm

I saw an earlier thread about using sp functions outside the forum, and it alluded to needing to include forum files, variables, etc. I'm wondering how specifically to do this.

Is there a global variable to include so that I can echo sp_UserAvatar();? Or is there a file to include that will allow me to bootstrap sf functions - something akin to including wp-load.php?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 3, 2012 - 8:43 pm

whoops. looks like we did not think that through all the way.  We used to have a template tag for displaying the avatar outside the forum, but removed it in 5.0 in favor of the display template tag your referenced... problem is, as you discovered, its not available outside the forum...

you should be able to call:  sp_forum_api_support()

and then it should be available...  will have to consider the wrapper once again or make it more know about that function...

and for reference, you can get the details on the avatar function here:  http://codex.simple-press.com/.....seravatar/

Avatar
Focus97
Member
Free Members
sp_UserOfflineSmall Offline
Apr 3, 2012 - 10:01 pm

Yep, I did see the codex article. I couldn't glean much from it that would help me get the function working. As for now, I did try and declare the function above, but I'm still getting nothing on the page (in fact, the entire output of HTML now breaks after the functions).

 

I'm using this and wondering if I'm declaring the function you suggested correctly?

<div class="bio-photo" id="forum-bio-photo">
                <?php
                sp_forum_api_support();
                echo sp_UserAvatar();
                ?>
            </div>

Currently the page is rendering white where the php begins (it's a dev site, so I'm not terribly worried).

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 4, 2012 - 12:14 am

well, you dont want the echo...  the sp_UserAvatar() function (as per the codex page) already outputs the data unless you set the echo=0 argument in which case it would be returned...

also, since you are not passing anything to the function, its assuming it will use the avatar of the currently logged in user...  is that what you want?

do you have a link to this example? would like to see if any output is generated just to make sure the function is really getting called (ie not missing an include file)...

if you want it for a specific user vs current logged in user, you would do something like

<?php
sp_forum_api_support();
sp_UserAvatar('context=user', $user);
?>

where $user is the user id or user email address that you want the avatar for...

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 4, 2012 - 2:28 am

The function sp_forum_api_support() will not be available until SP version 5.0.5...

In the meantime please use the function sp_forum_ahah_support() which will eventually be deprecated although not that quickly.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 4, 2012 - 8:21 am

doh! I knew that! argh...

Avatar
Focus97
Member
Free Members
sp_UserOfflineSmall Offline
Apr 5, 2012 - 11:20 am

You guys are awesome. The ahah_support function with the avatar works perfectly to display on non-forum pages. I used just the sp_UserAvatar() to display the currently logged-in user's avatar. Works brilliantly!

I just sent a PM to you both to provide access to the forum to view. Many thanks for the help.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 5, 2012 - 1:57 pm

Will take a look...
Just so you know the sp_forum_ahah_support() function is going to be deprecated after 5.0.5 in favour of the more usefully named sp-forum_api_support() but it will be several versions before the old one disappears for good.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616