-
-
Save CrazyBoy49z/e99bb8b898f65b942f411ba15b5f0d74 to your computer and use it in GitHub Desktop.
Скрываем поля и закладки [MiniShop2] в зависимости от шаблона - http://2geek.pro/solutions/70-skryivaem-polya-minishop2-v-zavisimosti-ot-shablona
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* OnManagerPageBeforeRender */ | |
switch ($modx->event->name) { | |
case 'OnDocFormPrerender': | |
if ($mode !== 'upd') { | |
return ''; | |
} | |
if (!$template = $resource->get('template')) { | |
return ''; | |
} | |
$ids = array(); | |
$script = ''; | |
switch ($template) { | |
/* product */ | |
case '7': | |
$ids[] = 'group_furniture'; | |
$ids[] = 'color'; | |
break; | |
/* korpus */ | |
case '10': | |
$ids[] = 'collection'; | |
$ids[] = 'mechanism'; | |
$ids[] = 'material'; | |
$ids[] = 'group'; | |
break; | |
/* korpus set */ | |
case '11': | |
$ids[] = 'collection'; | |
$ids[] = 'mechanism'; | |
$ids[] = 'material'; | |
$ids[] = 'group'; | |
break; | |
default: | |
break; | |
} | |
foreach ($ids as $id) { | |
$script .= "Ext.getCmp('modx-resource-{$id}').disable().hide();"; | |
} | |
$script .= " " | |
. "for (var i in miniShop2.config.data_fields) { " | |
. "var field = miniShop2.config.data_fields[i];" | |
. "var id = 'modx-resource-'+field;" | |
. "var c = Ext.getCmp(id); | |
if (!!!c) { | |
continue; | |
} | |
if (c.getValue() == 'undefined') { | |
c.setValue(); | |
} | |
} | |
"; | |
$modx->controller->addHtml('<script type="text/javascript"> | |
Ext.onReady(function() { | |
' . $script . '; | |
}); | |
</script>'); | |
break; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* OnManagerPageBeforeRender */ | |
switch ($modx->event->name) { | |
case 'OnManagerPageBeforeRender': | |
if(isset($_REQUEST['die']) || isset($modx->event->params['die'])) {return '';} | |
if(!$config = $controller->config) {return '';} | |
if((!in_array($config['controller'], array('resource/update')))) {return '';} | |
if(!$scriptProperties = $controller->scriptProperties) {return '';} | |
if(!$resource = $modx->getObject('msProduct', $scriptProperties['id'])) {return '';} | |
if (!$template = $resource->get('template')) {return '';} | |
$ids = array(); | |
$script = ''; | |
switch ($template) { | |
default: | |
$ids[] = 'product_tab_gallery'; | |
$ids[] = 'product_tab_links'; | |
break; | |
} | |
foreach ($ids as $id) { | |
$script .= "miniShop2.config.{$id} = 0;"; | |
} | |
$modx->controller->addHtml('<script type="text/javascript"> | |
Ext.onReady(function() { | |
' . $script . '; | |
}); | |
</script>'); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment