0

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>
2
  • This js is in template phtml file? Mar 11, 2017 at 8:52
  • Yes, I updated the question
    – Marc Pont
    Mar 13, 2017 at 8:21

1 Answer 1

1

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>

2
  • yup, this fixed that error... But the thing is, doing this practice (using my own template that inheritance from their template) I won't be able to customize the template the same way I'd if the 3rd party template was enabled instead mine?
    – Marc Pont
    Mar 13, 2017 at 11:03
  • When you need to override 3rd party theme (your case) you will need to use your theme override. Mar 13, 2017 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.