Bloodhound
Bloodhound

Reputation: 2966

How to find users' location during a web site visit in yii2

 echo Html::a( Yii::t( 'app', ' {modelClass}', [
                    'modelClass' => $loc_name,
                    ] ), [ 'site/city' ], [ 'class' => 'btn btn-link  fa fa-map-marker btn-primary city' ]
                    );

given above is a code for a dropdown to select a city. is there any way to get it automatically by sensing the location of the user in yii2?

Upvotes: 0

Views: 712

Answers (2)

user5201742
user5201742

Reputation:

You can use geoip. There's a module for Yii2: https://github.com/rmrevin/yii2-geoip

Upvotes: 4

Lynch
Lynch

Reputation: 910

You could use the Url helper class.

use yii\helpers\Url

// Current URL route...
Url::current()

It has a current() method that returns the current URL. You can see more about it here

Upvotes: -1

Related Questions