Post by doodleslr » Tue Sep 04, 2018 9:11 am

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?

Newbie

Posts

Joined
Mon Aug 06, 2018 1:07 pm

Post by straightlight » Tue Sep 04, 2018 11:59 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by doodleslr » Wed Sep 05, 2018 12:14 pm

straightlight wrote:
Tue Sep 04, 2018 11:59 pm
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.
Thank you for replying! How did you find that? Which documentation is that in?
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 %}
I know there are more steps but i really can't find what they are.

Newbie

Posts

Joined
Mon Aug 06, 2018 1:07 pm

Post by straightlight » Wed Sep 05, 2018 10:12 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by doodleslr » Thu Sep 06, 2018 1:02 pm

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.

Code: Select all

$twig = new Twig_Environment($loader);
$mobTwig->addGlobal('isMobile', true);
and in my twig i am calling it

Code: Select all

{% if is_mobile() %}
do mobile stuff
{% else %}
do desktop stuff
{% endif %}
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?

Newbie

Posts

Joined
Mon Aug 06, 2018 1:07 pm

Post by straightlight » Thu Sep 06, 2018 7:40 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by doodleslr » Thu Sep 06, 2018 8:05 pm

Thank you Straightlight i'll take a look into it :)

Newbie

Posts

Joined
Mon Aug 06, 2018 1:07 pm
Who is online

Users browsing this forum: Baidu [Spider], shivankagrawal and 147 guests