andrewdanilov / yii2-city-switch
Widget for switching city on site
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.6.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-02-16 23:37:38 UTC
README
Warning: component is under cunstruction. Do not use it.
Component for switching city on site. You can display a personificated info associated to selected city (for example address or phone in that city). It uses cookies, so pay attention to that fact, that by changing city you do not change page web address.
Installation
The preferred way to install this extension is through composer.
Either run
composer require andrewdanilov/yii2-city-switch "~1.0.0"
or add
"andrewdanilov/yii2-city-switch": "~1.0.0"
to the require section of your composer.json
file.
Then you need to run migrations, to create cities table
yii migrate --migrationPath=@andrewdanilov/cityswitch/migrations
Usage
Add to bootstrap section in main config of your backend:
return [ ... 'bootstrap' => [ ... 'cityswitch' => [ 'class' => andrewdanilov\cityswitch\backend\Bootstrap, // data params which you want to be associated with each city // in addition to city alias (`city`) and city name (`city_name`) 'dataParams' => [ 'address' => 'City address', 'phone' => 'City phone', 'coords' => 'City address coordinates', ], // defining access to module 'access' => ['admin'], ], ], ];
This needs to edit cities data in backend of your site. Backend url would be:
admin/cityswitch
To display city switcher menu, use:
<?= \andrewdanilov\cityswitch\CitySwitchMenu::widget() ?>
To display current city value:
<?= \andrewdanilov\cityswitch\CitySwitchValue::widget(['param' => 'phone']) ?>