Why switch to Twig and not include basics like "asset" and "Mobile Detect"?
Posted: Wed Oct 11, 2017 4:44 am
I'm a little perplexed. OpenCart developers decided to switch to the Twig language for the templates, instead of the good old PHP that everyone's familiar with.
OK, that's fine, couple of days of reading manuals and I figured out most of the things I need to change.
But why couldn't they include basic functions like, well, INCLUDING assets like stylesheets? Or bundling the Mobile Detect function?
It's not like over 45% of users are mobile, and we MIGHT want to have the option to include different things on pages, depending on whether the user is desktop or mobile...
...and it's not like it would be convenient to include separate CSS files or other code-blocks, instead of trying to cram everything into one template file...
So yeah. Trying to use the "asset" command in a template, results in the following error:
Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "asset" function in "journal2/template/product/product.twig" at line 1.
What's the solution?
OK, that's fine, couple of days of reading manuals and I figured out most of the things I need to change.
But why couldn't they include basic functions like, well, INCLUDING assets like stylesheets? Or bundling the Mobile Detect function?
It's not like over 45% of users are mobile, and we MIGHT want to have the option to include different things on pages, depending on whether the user is desktop or mobile...
...and it's not like it would be convenient to include separate CSS files or other code-blocks, instead of trying to cram everything into one template file...
So yeah. Trying to use the "asset" command in a template, results in the following error:
Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "asset" function in "journal2/template/product/product.twig" at line 1.
What's the solution?