문제

I'm trying to create my own template and inheritance from another that I bought on themestore. I think it's a good practice, just for change some things, doing this way the 3rd party template is intact.

But I get some JS errors, because some snippets are empty, like this:

var ThemeOptions = {
    box_wide: ,
    rtl_layout: ,
    sticky_header: 
};

I think that is because this options are defined on admin panel, but because the 3rd party template is not active, this values are not defined.

Is there any way to make this practice well done?

UPDATE: this JS snippet is on: Magento_Theme/templates/html/head_options.phtml

<script type="text/javascript">
var ThemeOptions = {
    box_wide: <?php echo $_themeHelper->getConfig('general_section/layout/box_wide') ?>,
    rtl_layout: <?php echo $_themeHelper->getConfig('general_section/layout/enable_rtl') ?>,
    sticky_header: <?php echo $_themeHelper->getConfig('general_section/header/sticky_header') ?>       
}; 
if(navigator.userAgent.match(/iPad|iPhone|iPod|iPad Simulator|iPhone Simulator|iPod Simulator/i) !== null){
    document.addEventListener("DOMContentLoaded", function(event) { 
        document.body.classList.add('iMenu');
    });
}
</script>
도움이 되었습니까?

해결책

Do this to avoid JS error for empty results:

<script type="text/javascript"> var ThemeOptions = { box_wide: '<?php echo $_themeHelper->getConfig('general_section/layout/box_wide') ?>', rtl_layout: '<?php echo $_themeHelper->getConfig('general_section/layout/enable_rtl') ?>', sticky_header: '<?php echo $_themeHelper->getConfig('general_section/header/sticky_header') ?>'
}; if(navigator.userAgent.match(/iPad|iPhone|iPod|iPad Simulator|iPhone Simulator|iPod Simulator/i) !== null){ document.addEventListener("DOMContentLoaded", function(event) { document.body.classList.add('iMenu'); }); } </script>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top