News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Donate button

Started by commando_lee, December 26, 2009, 08:08:39 AM

Previous topic - Next topic

commando_lee

I was wondering if some body can help me.  Im running SMF RC2.  what im trying to do is add a donate button next to the navigation bar, next to the logout link.  I have the code from paypal but i dont have a clue how to set it up.

Thanks in advance

Arantor

What theme are you using?

dansomers

http://seoguideforum.com/index.php have look I have a simply link

I have that donate button, its on the mods on this site http://custom.simplemachines.org/mods/index.php?mod=916

I have seen this http://custom.simplemachines.org/mods/index.php?mod=273 but I havent used it

commando_lee


Arantor

And what code do you need to add?

commando_lee

Quote from: Arantor on December 26, 2009, 08:16:09 AM
And what code do you need to add?

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="10748451">
<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>



That is the code paypal gave me

Arantor

OK, you need to edit your theme's index.template.php file.

Code (find) Select
</div>';
}

// Generate a strip of buttons.


Code (replace) Select
</div>';
echo '
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="10748451">
<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>';
}

// Generate a strip of buttons.

dansomers

Can you show me your forum when you have added your button ?

Im just using the MODS on here

Arantor

I didn't add it to my forum. I just showed you where that would add it in the code, right where you asked for it - to the right of the menu.

commando_lee

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
{
   global $settings, $context, $txt, $scripturl;

   if (!is_array($strip_options))
      $strip_options = array();

   // Create the buttons...
   $buttons = array();
   foreach ($button_strip as $key => $value)
   {
      if (!isset($value['test']) || !empty($context[$value['test']]))
         $buttons[] = '<a ' . (isset($value['active']) ? 'class="active" ' : '') . 'href="' . $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';
   }

   // No buttons? No button strip either.
   if (empty($buttons))
      return;

   // Make the last one, as easy as possible.
   $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

   echo '
      <div class="buttonlist', !empty($direction) ? ' align_' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
         <ul>
            <li>', implode('</li><li>', $buttons), '</li>
         </ul>
      </div>';
}

?>

thats the code from the box saying beginin from line 466

do i just over write the whole box or add the code u gave in a certain place im just a little confussed.

Thanks for your help

Arantor

Right, the bit I gave you replaces the last </div> and } in that block. There shouldn't be a ?> in that section, actually.

commando_lee

it now looks like this.  but the button doesnt show

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
{
   global $settings, $context, $txt, $scripturl;

   if (!is_array($strip_options))
      $strip_options = array();

   // Create the buttons...
   $buttons = array();
   foreach ($button_strip as $key => $value)
   {
      if (!isset($value['test']) || !empty($context[$value['test']]))
         $buttons[] = '<a ' . (isset($value['active']) ? 'class="active" ' : '') . 'href="' . $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';
   }

   // No buttons? No button strip either.
   if (empty($buttons))
      return;

   // Make the last one, as easy as possible.
   $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

   echo '
      <div class="buttonlist', !empty($direction) ? ' align_' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
         <ul>
            <li>', implode('</li><li>', $buttons), '</li>
         </ul>
      </div>';   echo '   <form action="https://www.paypal.com/cgi-bin/webscr" method="post">      <input type="hidden" name="cmd" value="_s-xclick">      <input type="hidden" name="hosted_button_id" value="10748451">      <input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">      <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">   </form>';}// Generate a strip of buttons.


Arantor

Can I have a link to your site please, so I can verify the code is in place?


Arantor

That code isn't present in the Blue Moonlight theme output, meaning you may have edited the wrong file.

commando_lee

this a copy and paste from the whole box under the heading begining from line 466.   its the last box on the modify page.  Im lost on this one

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
{
   global $settings, $context, $txt, $scripturl;

   if (!is_array($strip_options))
      $strip_options = array();

   // Create the buttons...
   $buttons = array();
   foreach ($button_strip as $key => $value)
   {
      if (!isset($value['test']) || !empty($context[$value['test']]))
         $buttons[] = '<a ' . (isset($value['active']) ? 'class="active" ' : '') . 'href="' . $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';
   }

   // No buttons? No button strip either.
   if (empty($buttons))
      return;

   // Make the last one, as easy as possible.
   $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

   echo '
      <div class="buttonlist', !empty($direction) ? ' align_' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
         <ul>
            <li>', implode('</li><li>', $buttons), '</li>
         </ul>
      </div>';   
echo ' 
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">      <input type="hidden" name="cmd" value="_s-xclick">      <input type="hidden" name="hosted_button_id" value="10748451">      <input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">      <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> 
</form>';
}
// Generate a strip of buttons.

Arantor

When you went into the theme editor, did you edit the default theme's or Blue Moonlight's files?

commando_lee

i went to modify themes, then selected bluemoonlight
browse the templates and files in this theme
and then a small list came up and i selected  index.template.php

Arantor

Did you select save at the end of editing?

commando_lee

Quote from: Arantor on December 26, 2009, 08:53:13 AM
Did you select save at the end of editing?

Yeah i did mate,  when i go into it now the code is showing

Advertisement: