I'm having difficulty installing this plugin.
https://github.com/mmikkel/Detect-Craft
In the readme it mentions installing the folder into /craft/plugins directory but as far as i know we have no such directory. The most appropriate folder i could find is
html/catalog/view/theme/journal2/lib
which i've popped it in and called, but any checks i've made for user devices are invalid so i'm feeling this isn't the correct directory to place the folder in.
The Twig documentation talks of registering the modules in services.yaml in Symphony only and i can't locate any Opencart specific information to help install this.
The plugin documentation does say install through the Craft Control Panel but afaik Opencart doesn't have/use Craft but would the equivalent be installing through the opencart extensions control panel?
Sorry this may be all over the place, i've never installed custom twig plugins only ones from the store this is one problem i haven't been able to google my way out of.
Is this even doable?
https://github.com/mmikkel/Detect-Craft
In the readme it mentions installing the folder into /craft/plugins directory but as far as i know we have no such directory. The most appropriate folder i could find is
html/catalog/view/theme/journal2/lib
which i've popped it in and called, but any checks i've made for user devices are invalid so i'm feeling this isn't the correct directory to place the folder in.
The Twig documentation talks of registering the modules in services.yaml in Symphony only and i can't locate any Opencart specific information to help install this.
The plugin documentation does say install through the Craft Control Panel but afaik Opencart doesn't have/use Craft but would the equivalent be installing through the opencart extensions control panel?
Sorry this may be all over the place, i've never installed custom twig plugins only ones from the store this is one problem i haven't been able to google my way out of.
Is this even doable?
According to the documentation, you need to copy the package into the storage/vendor folder (without autoload.php) and to follow how it works from the readme.md file.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thank you for replying! How did you find that? Which documentation is that in?straightlight wrote: ↑Tue Sep 04, 2018 11:59 pmAccording to the documentation, you need to copy the package into the storage/vendor folder (without autoload.php) and to follow how it works from the readme.md file.
There are two readme.md files, one in the top level mentions installing via the craft CP,
and another in mobiledetect/mobiledetect/lib is general info.
I've placed my entire detect folder into /storage/vendor and removed the autoload.php file and in my header.twig i have established
Code: Select all
{% set isUserMobile = craft.detect.isMobile %}
{% if isUserMobile %}
Display mobile menu
{% else %}
Display desktop menu
{% endif %}
Since this is about an integration project, I would suggest to create a new service request in the Commercial Support section of the forum to get this done as a custom job.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I understand this should be moved but i am so close!
I have the plugin working within my Opencart, i have it detecting the device but only in my php, i just have it echo if i am mobile or not.
Unfortunately, if i try to create a new twig environment to pass a php bool into twig global it returns 500 internal server error. I have isolated most code and it is specifically the creation of the new twig environment that is crashing me.
and in my twig i am calling it
I'm certain i wrote this correctly according to the twig documentation
https://twig.symfony.com/doc/2.x/advanced.html#globals
Can somebody help me learn why this is incorrect?
I have the plugin working within my Opencart, i have it detecting the device but only in my php, i just have it echo if i am mobile or not.
Unfortunately, if i try to create a new twig environment to pass a php bool into twig global it returns 500 internal server error. I have isolated most code and it is specifically the creation of the new twig environment that is crashing me.
Code: Select all
$twig = new Twig_Environment($loader);
$mobTwig->addGlobal('isMobile', true);
Code: Select all
{% if is_mobile() %}
do mobile stuff
{% else %}
do desktop stuff
{% endif %}
https://twig.symfony.com/doc/2.x/advanced.html#globals
Can somebody help me learn why this is incorrect?
Using a custom TWIG function could accomplish your request: https://stackoverflow.com/questions/132 ... on-in-twig . However, take note that this methodology has been restricted on the new OC alpha release since it now uses extends methods rather than plugins from the TWIG Engine to specifically be used in the Design Theme of the OC admin.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: Baidu [Spider], shivankagrawal and 147 guests