basz / SlmLocale

Auto detection of locale through different strategies for Zend Framework 2
Other
68 stars 34 forks source link

Conflict with the module ZfTable | Deactivate dynamically the locale strategy #68

Closed yannickvid closed 9 years ago

yannickvid commented 9 years ago

When using SlmLocale with the strategy "uripath", the module ZfTable (https://github.com/dudapiotr/ZfTable) is not working anymore. (Issue: https://github.com/dudapiotr/ZfTable/issues/57)

I believe that the issue is due to the fact that the strategy add the locale in the URL and the Ajax requests of the module ZfTable do not know how to handle it.

Is there a way to deactivate dynamically the strategy in a controller to avoid the addition of the locale in the URL?

Has anyone tried to work with both these modules at the same time?

yannickvid commented 9 years ago

This may not be the best way to do it, but at least it solves the issue:

For the calls in Zftable views, instead of calling: $("#tableContainer").zfTable('/admin/members/ajax-list');

You need to call the full URL with the locale: $("#tableContainer").zfTable('<?php echo "http://" . $_SERVER['SERVER_NAME']; ?>/en/admin/members/ajax-list');

juriansluiman commented 9 years ago

Why are you using static links? If you use the zf2 view helper, SlmLocale is configured to inject the base path including the language part.

yannickvid commented 9 years ago

Hello,

Thank you for your answer, using View Helpers is actually better yes.

For people facing the same problem, a better way to solve the issue is to call:

$("#tableContainer").zfTable('<?php echo $this->url('admin-members', array('action' => 'ajax-list'), array('force_canonical' => true))?>');

Please note that you need the "array('force_canonical' => true)" to display the full URL, otherwise it will not work.