問題タブ [device-detection]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
0 に答える
55 参照

symfony - eventListener を使用してフォルダー内のテンプレートを見つけます

情報については、私が現在取り組んでいるプロジェクトは Symfony 2.3 です。

DeviceListenerユーザーデバイスのチェックというイベントリスナーがあります。( MobileDetectクラスを使用します)

そのデバイスに関連付けられているテンプレートがあるフォルダーを指定する必要があります (例としてモバイル)

現時点では、イベントリスナーが機能し、ユーザーがスマートフォンまたはデスクトップを使用しているかどうかを確認でき、Mobileフォルダーを見つけることができます。しかし、テンプレに間に合わなかった。

これがリスナーの作業コードです

そして私が設定したservice.yml:

ご覧のとおり、私は使用していますが、使用する方がより良い解決策であるonKernelRequestと思います。onKernelView

また、テスト目的で、Resources/viewsモバイル デバイス用のテンプレートを含む Mobile フォルダーに作成しました。

私のテンプレート

何か案は?

0 投票する
1 に答える
231 参照

php - How to detect if it is a desktop device using the DeviceDetector php library?

I am using this library to detect the device and client program from the http user agent string.

Device Detector

On the library's demo page, they are able to distinguish if the device is a desktop or smartphone even if the device model is not detected. However, they don't have a document to state what function they have use to do that. On the read me on github, I guessed it is $dd->getDevice(), but it seems that function only return an integer 1 or 0 (and I have no idea what does it means)

They didn't provide the source code for the demo page, and there are no further documentation other than the read me page. Anybody know what is the function they are using to detect if it is smartphone or desktop on the demo page?