SMF Shop
SMFShop => Coding => Topic started by: Abangyarudo on September 01, 2007, 06:44:51 am
-
Hi I was wondering cause I don't know how advanced this would be but I'd like to hide the shop button for members of certain membergroups. I run a role playing forum and am planning to use the smf shop to be able to let characters buy items and equipment for their characters so groups like the player membergroup and staff membergroups would not need the shop button. Thanks in Advance.
-
Are they primary membergroups, or aditional membergroups?
In Themes/<your theme name>/index.template.php, find your shop button code. It will look a little like this:
//Begin SMFShop code
echo ($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=shop">Shop</a>
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
//END SMFShop code
(search for ?action=shop to find it)
Right above the "echo" bit (in this case, it's directly below the // Begin SMFShop code line), add this:
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3);
// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
Change the "1" to the ID of the group you want to hide the button from. In the "Membergroups" section of the admin panel, clicking the "Modify" link will show the ID in your browser's address bar (eg. ?action=membergroups;sa=edit;group=4).
-
thank you
-
just for future reference; what about multiple groups?
-
just for future reference; what about multiple groups?
just add a comma, then a space, then the next number. in the list.
-
I made the changes but I get this error
Parse error: parse error, unexpected T_GLOBAL, expecting ',' or ';' in /BlackRain1/index.template.php on line 949 that command is the global command
global $user_info;
-
ok got some help from main smf site you move the command
echo
to just after where it says
//loadLanguage("shop");
but group 1 which would be admin still sees it as well as other groups in the array so does moving the command invalidate the code?
-
The echo needs to be directly under the "if" statement. So, if you move the echo, also move the if statement.
-
The echo needs to be directly under the "if" statement. So, if you move the echo, also move the if statement.
it was under the global I moved it but still doesn't seem to be working
the code is currently
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);
// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo
//loadLanguage("shop");
($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Show the [Shop] button:
echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code
-
What's right above the
//Begin SMFShop
bit?
And please remove the //loadLanguage("shop");
, it's not needed ;)
Edit: Looking at your code again, it should look something like:
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);
// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code
The ($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
bit was for the default theme, and is not needed for this theme.
-
What's right above the //Begin SMFShop
bit?
And please remove the //loadLanguage("shop");
, it's not needed ;)
Edit: Looking at your code again, it should look something like:
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);
// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code
The ($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
bit was for the default theme, and is not needed for this theme.
right above begin is // Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin']){
echo '<li><a href="', $scripturl, '?action=admin"><span>', $txt[2], '</span></a></li>';
this is part of the search code
-
ok I have the following error
Parse error: parse error, unexpected T_IF, expecting ',' or ';' in */smf/Themes/BlackRain1/index.template.php on line 959
this line is right below the editted smfshop code. it refers to the following line
if ($context['allow_edit_profile'])
this shows the lines except whats above it which is the modified code you said it should say above I also showed a few lines below it.
// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo '<li><a href="', $scripturl, '?action=profile"><span>', $txt[467], '</span></a></li>';
/* // View Groups Interface... [groups]
if (allowedTo('view_groups'))
echo '<li><a href="', $scripturl, '?action=groups"><span>Groups</span></a></li>';
I also wanted to say thanks for helping me out as much as ya have .
-
still having this problem and would apperciate any assistance. I do understand your very busy though.