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
Add achievement badge in profile column in post.
Avatar
Paul Browning
Member
Pro Subscribers
sp_UserOfflineSmall Offline
May 17, 2014 - 10:59 am

Hello,

I am attempting to add an achievement badge under the user name on a post (please see attached image). I am able to query the database with the user id so I have two questions:

1. How do you suggest I insert new html into the template file? I am worried that if I just add it into the template that when the plugin is updated the code will be lost. 

2. Where should the function that grabs this data be defined? If i define it in the sp_functions.php file will it have the correct scope to be available in the template file?

 

Thanks for your help!

 

simplepress-badge-1.jpgImage Enlarger

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 17, 2014 - 11:14 am

yes, you can insert any custom php or html where you would like it in your sp theme template files...  As long as the theme is your theme and not one of ours, no changes will be lost on updates... 

see:  http://codex.simple-press.com/.....g-a-theme/ for more info on creating your own theme from one of ours...

you can create the php function for grabbing the data in the template file itself if only used there... remember, the template file itself is php so you can put any php code there that you like...  as you probably know, this is the spTopicView.php template file...

or the spFunctions.php template file is available on all forum pages that get loaded so it has much greater scope and the functions could be put there...  the only downside to spFunctions.php is that it is loaded on all forum pages (very minimal impact unless the function size is quite large)...

out of curiosity, is this a custom or homegrown achievements thing?  or are you using the wp achievements plugin and subsequently our sp achievements integration plugin?

Avatar
Paul Browning
Member
Pro Subscribers
sp_UserOfflineSmall Offline
May 17, 2014 - 11:30 am

Thank you for that info! That should point me in the right direction.

Yes I am using the wpAchievements plugin and may use the simple:press integration plugin in the future. As I understand it, the sp achievements integration plugin allows for tracking events from simple:press like posting, but it doesn't allow for any custom theming using the data. 

Thanks again.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 17, 2014 - 11:35 am

yes, you can track forum events with our achievements integration plugin.... but if the core wp plugin for it has template tags for displaying a badge, you should just be able to use that function in our template file...

you are welcome!

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: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626