Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Andrés <diegoandres_cortes@outlook.com>
  • Loading branch information
DiegoAndresCortes committed Feb 28, 2023
1 parent 6d11672 commit a702ded
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
19 changes: 17 additions & 2 deletions Themes.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,14 +816,29 @@ function template_pick()
{
echo '
<label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>:
<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant(', $theme['id'], ', this);">';
<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="profileChangeVariant(this.value);">';

foreach ($theme['variants'] as $key => $variant)
echo '
<option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';

echo '
</select>';
</select>
<script>
var vThumbnails = {';

// All the variant thumbnails.
$count = 1;
foreach ($theme['variants'] as $key => $variant)
{
echo '
\'', $key, '\': \'', $variant['thumbnail'], '\'', (count($theme['variants']) == $count ? '' : ',');
$count++;
}

echo '
}
</script>';
}

echo '
Expand Down
8 changes: 7 additions & 1 deletion scripts/custom/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,10 @@ $(function() {
});
}
});
});
});

// Variants in the pick theme area
function profileChangeVariant(sVariant)
{
document.getElementById('theme_thumb_' + smf_theme_id).src = vThumbnails[sVariant];
}
14 changes: 11 additions & 3 deletions themecustoms/Config/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,14 @@ public static function main_menu(&$buttons) : void
*
* @return void
*/
public function strip_menu() : void
public function strip_menu(&$current_action) : void
{
global $context, $settings, $txt;

// Check for Ultimate Menu doing witchcraft?
if (!empty($current_action) && $current_action == 'admin' && isset($_REQUEST['area']) && $_REQUEST['area'] == 'umen')
return;

// Remove elements?
$remove = !empty($settings['st_remove_items']) ? explode(',', $settings['st_remove_items']) : [];

Expand All @@ -210,7 +214,7 @@ public function strip_menu() : void
$context['menu_buttons'] = $current_menu;

// Community button
$this->community();
$this->community($current_action);
}


Expand All @@ -222,7 +226,7 @@ public function strip_menu() : void
*
* @return void
*/
private function community() : void
private function community(&$current_action) : void
{
global $context, $settings;

Expand All @@ -242,6 +246,10 @@ private function community() : void
$temp_menu['community']['sub_buttons'][$action] = $button;
}
$context['menu_buttons'] = $temp_menu;

// Update the active button
if (isset($context['menu_buttons']['community']['sub_buttons'][$current_action]) && array_key_exists($current_action, $context['menu_buttons']['community']['sub_buttons']))
$context['menu_buttons']['community']['active_button'] = true;
}

/**
Expand Down

0 comments on commit a702ded

Please sign in to comment.