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?
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
What's the solution?
Well, one of them could be, to stay with what one already knows, like me and my XP,
if one does not want to learn, again and again, just to keep on doing, what one has
been so familiar with before ...
And one cannot survive, on longer terms, by always doing the same, that's Business !
Ernie
( PS: Especially, since MS re-activated the official Upgrade-Gate again for XP`s
)
Well, one of them could be, to stay with what one already knows, like me and my XP,
if one does not want to learn, again and again, just to keep on doing, what one has
been so familiar with before ...

And one cannot survive, on longer terms, by always doing the same, that's Business !
Ernie
( PS: Especially, since MS re-activated the official Upgrade-Gate again for XP`s

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
"Google is your friend"... with a link that explains how to do this in PHP.
I know how to do this in PHP.
I have it done in PHP.
But in case you didn't notice, PHP code doesn't work in Twig templates.
And if I try to use the solution/s listed online, they require the "Mobile Detect" library to be installed. Which isn't included.
That's my point. With half the users out there being on mobile browsers, why not include a mobile-detect library in the distro, so developers can have the SAME functionality as what they get with the PHP libraries installed on most hosting servers?
I know how to do this in PHP.
I have it done in PHP.
But in case you didn't notice, PHP code doesn't work in Twig templates.
And if I try to use the solution/s listed online, they require the "Mobile Detect" library to be installed. Which isn't included.
That's my point. With half the users out there being on mobile browsers, why not include a mobile-detect library in the distro, so developers can have the SAME functionality as what they get with the PHP libraries installed on most hosting servers?
Code: Select all
<?php
$ismobile = check_user_agent('mobile');
if($ismobile) {
echo('<div class="mobile_wrapper">');
include('product-block-mobile-version.php');
echo('</div>');
} else {
echo('<div class="desktop_wrapper">');
include('product-block-desktop-version.php');
echo('</div>');
}
?>
Try it, and discover that the basic function "check_user_agent" is NOT THERE.
Unless it's called something else entirely?
You dont. You do that in the controller, in PHP, like I said before.
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
Who is online
Users browsing this forum: No registered users and 14 guests