andrewdanilov / yii2-city-switch
网站城市切换小部件
1.0.0
2019-04-16 12:37 UTC
Requires
- php: >=5.6.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-16 22:47:20 UTC
README
警告:组件正在开发中。请勿使用。
用于在网站上切换城市的小部件。您可以显示与所选城市关联的个性化信息(例如地址或电话)。它使用cookie,因此请注意,更改城市不会更改网页地址。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require andrewdanilov/yii2-city-switch "~1.0.0"
或者
"andrewdanilov/yii2-city-switch": "~1.0.0"
将其添加到您的 composer.json
文件的要求部分。
然后您需要运行迁移,以创建城市表
yii migrate --migrationPath=@andrewdanilov/cityswitch/migrations
使用方法
将以下内容添加到您后端主配置的 bootstrap 部分
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'], ], ], ];
这需要在您站点的后端中编辑城市数据。后端地址为
admin/cityswitch
要显示城市切换菜单,使用
<?= \andrewdanilov\cityswitch\CitySwitchMenu::widget() ?>
要显示当前城市值,使用
<?= \andrewdanilov\cityswitch\CitySwitchValue::widget(['param' => 'phone']) ?>