PHPackages                             andrewdanilov/yii2-city-switch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. andrewdanilov/yii2-city-switch

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

andrewdanilov/yii2-city-switch
==============================

Widget for switching city on site

1.0.0(7y ago)111MITPHPPHP &gt;=5.6.0

Since Apr 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/AndrewDanilov/yii2-city-switch)[ Packagist](https://packagist.org/packages/andrewdanilov/yii2-city-switch)[ RSS](/packages/andrewdanilov-yii2-city-switch/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

City Switch
===========

[](#city-switch)

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
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

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
-----

[](#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:

```

```

To display current city value:

```
