SMF Shop

SMFShop => Coding => Topic started by: Martin on January 29, 2007, 07:42:24 pm

Title: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on January 29, 2007, 07:42:24 pm
Okay, here's what I've done:
(http://img258.imageshack.us/img258/1411/userstatsni3.png)
It all works fine, it displays the money there but the problem is that it displays only in the shop and in the admin cp. On the main page and everywhere else it's just blank, what should I do to make it work on every page?
Title: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on January 31, 2007, 06:16:54 am
Sorry for the double post but can anyone tell me how? I still haven't figured out  :-\
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on February 03, 2007, 08:21:57 am
Hmm, I guess no one can help then, it's been days...I've tried many ways, but none of them is successful.. (Sorry for this whole double and tripleposting..)
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Daniel15 on February 03, 2007, 08:47:39 am
Sorry, I've been very busy (just started school again).
Are you using formatMoney()? formatMoney only works if you're inside the shop. Elsewhere, you'll need to do something like:
Code: [Select]
$modSettings['shopCurrencyPrefix'] . $context['user']['money'] . $modSettings['shopCurrencySuffix']
Hope this helps you :)
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on February 03, 2007, 08:52:12 am
Well, here's my current faulty code:

Code: [Select]
// User Statistics
if (!empty($settings['enable_news']))
echo '
<div class="headertitles" style="width: 260px;"><img src="', $settings['images_url'], '/blank.gif" height="12" alt="" /></div>
<div class="headerbodies" style="width: 260px; position: relative; background-image: url(', $settings['images_url'], '/box_bg.gif); margin-bottom: 8px;">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/newsbox.gif" style="position: absolute; left: -1px; top: -16px;" alt="" />
<div style="height: 50px; overflow: auto; padding: 5px;" class="smalltext">

', sprintf($txt['userareahave'], ($context['user']['money'])),
($modSettings['shopBankEnabled'] ? sprintf($txt[''],
  ($context['user']['moneyBank'])) : ''), '
  <br>
 
', sprintf($txt[''], ($context['user']['money'])),
($modSettings['shopBankEnabled'] ? sprintf($txt['userareahave2'],
  ($context['user']['moneyBank'])) : ''), '


</div>
</div>';

I know, laugh as much as you want, I ain't that smart at PHP but usually I get stuff I need, done.
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on February 10, 2007, 10:17:10 am
This topic is still unresolved :( lol
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Daniel15 on February 10, 2007, 12:58:48 pm
Firstly, the $txt[''] will be causing heaps of errors (check your error log!). Change this:
Code: [Select]
', sprintf($txt['userareahave'], ($context['user']['money'])),
($modSettings['shopBankEnabled'] ? sprintf($txt[''],
  ($context['user']['moneyBank'])) : ''), '
  <br>
 
', sprintf($txt[''], ($context['user']['money'])),
($modSettings['shopBankEnabled'] ? sprintf($txt['userareahave2'],
  ($context['user']['moneyBank'])) : ''), '

into this:
Code: [Select]
', sprintf($txt['userareahave'], ($context['user']['money'])), '<br />
', ($modSettings['shopBankEnabled'] ? sprintf($txt['userareahave2'], ($context['user']['moneyBank'])) : ''), '

Secondly, make sure that $txt['userareahave'] and $txt['userareahave2'] are defined in Themes/default/Modifications.english.php. If they're in Shop.english.php, it won't work (that file is only loaded when you're in the shop)
Title: Re: Display amount of your money in the News Box (Stats box for me)?
Post by: Martin on February 10, 2007, 01:35:51 pm
GREAT! That works, thanks a lot :D