Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Adding a donate button
Avatar
Alex T
Member
sp_UserOfflineSmall Offline
Apr 21, 2016 - 12:34 pm

 How can I add a donate button, from PayPal, next to the add topic button?  PayPal allows you to create a donate button, which they provide you with the html code, then you may stick it into your site.  Is this possible to add to the forum?

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Apr 21, 2016 - 12:46 pm

I would have thought it was as simple as adding it to a template. If you could post up the code PayPal gives you (using our syntax highlighter) I can see about adding it to a template and help you find where to place it.

Avatar
Alex T
Member
sp_UserOfflineSmall Offline
Apr 21, 2016 - 12:49 pm

Here is the code:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BQS7YMRYTEAJC">
<input type="image" src="http://www.ohhtee.com/wp-content/uploads/2015/08/b2.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Apr 21, 2016 - 12:54 pm

Nice and simple, all you need to do is add a closing PHP tag before, and an opening PHP tag after. This is because the code PayPal give you is HTML so you need to drop out of PHP (as the templates use) in order for it to work, and then open it up again after so the template can continue. I did this on line 159 of spForumViewDesktop.php to add the donate button in the header.

I.e just after 'sp_TopicNewButton' which I've left in for reference:

sp_TopicNewButton('tagClass=spButton spRight iconStatusClass=spLockPosition&iconLock=sp_ForumStatusLockWhite.png', __sp('Add Topic'), __sp('Start a new topic'), __sp('This forum is locked'));
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BQS7YMRYTEAJC">
<input type="image" src="http://www.ohhtee.com/wp-content/uploads/2015/08/b2.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<?php
Avatar
Alex T
Member
sp_UserOfflineSmall Offline
Apr 21, 2016 - 1:08 pm

OK that was easy.  How may I move the image?  Currently it will sit on the far left, right above the page number.  I want to move it towards where this red arrow in the pic below is.

Image Enlarger

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Apr 21, 2016 - 1:11 pm

You can just add an inline float rule to the first opening div:

?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" style="float: right;">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BQS7YMRYTEAJC">
<input type="image" src="http://www.ohhtee.com/wp-content/uploads/2015/08/b2.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<?php
Avatar
Alex T
Member
sp_UserOfflineSmall Offline
Apr 21, 2016 - 1:17 pm

Awesome, works perfectly.  I'm assuming that if I wanted to add this in topic view, then basically add it in the same area as well?  What if I wanted to add this for mobile?  

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Apr 21, 2016 - 1:29 pm

Glad it works how you want it!..

Yes, you could add this in topic view, you could experiment putting it before or after certain functions, and changing the float: right to float: left to get it to look how you want.

As to mobile, sure - You can add it to any of the mobile templates just the same. Although it might be up to PayPal to give you something more suitable for mobile view. You would have to experiment..

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
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: 617
Members: 17359
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10125
Posts: 79620