Question

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>
Was it helpful?

Solution

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>

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top