Author Topic: Question about shop.php  (Read 2789 times)

Offline Basil Beard

Question about shop.php
« on: April 25, 2006, 12:48:52 am »
All through out shop.php there are these $context lines.

Code: [Select]
$context['shop_bank_link']

I have determined that the $context lines provoide certain amounts of text formatting and all that, but I can't figgure out where they are defined? Is in one of the subs files in the sources folder? Or is it someplace else?

Thanks  :D
Arrrrr!

Offline Daniel15

Re: Question about shop.php
« Reply #1 on: April 25, 2006, 03:50:32 pm »
Hello again,
 The $context lines are set in the Sources/shop/Shop.php file. For example, the bank link is defined like so:
Code: [Select]
    if ($modSettings['shopBankEnabled']) {
        $context['shop_bank_link'] = "<a href='$scripturl?action=shop;do=bank'>{$txt['shop_bank']}</a><br />";
    } else {
        $context['shop_bank_link'] = "";
    }
This is so if the bank is turned off, no link appears for it in the shop. I use $context[] variables a lot, usually to store data to pass to the template (when I started making SMFShop, I didn't know of any *proper* way to pass the data, so I stored it in $context[] variables).

Anyway, to finish answering your question, the variables are set in Sources/shop/Shop.php, and used in Templates/default/Shop.template.php.

Some of the variables I use include the variable
Code: [Select]
$context['shop_buy_message'], which has a message (like the message after you purchase an item, etc.). I also use
Code: [Select]
$context['shop_items_list'], which is used on the 'Buy Stuff' and Inventory listings.

I hope this helped you,
 --daniel15

Offline Basil Beard

Re: Question about shop.php
« Reply #2 on: April 26, 2006, 01:39:13 am »
AH! I see now.  :D. The shop.template.php file does the general formatting and the $context variable tells it what to stick in the unkown spots. Very nice.  O0.
Arrrrr!

Offline Daniel15

Re: Question about shop.php
« Reply #3 on: April 26, 2006, 07:39:49 pm »
Yeah, exactly. One of the main benefits is that someone can change the look of the shop, without the risk of accidentally changing something that they shouldn't.

If you look at most of the SMF files, the *.template.php files do the formatting, whereas the Sources/*.php do the actual backend work.