PHPackages                             vojtasvoboda/oc-locationtowns-plugin - 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. vojtasvoboda/oc-locationtowns-plugin

ActiveOctober-plugin

vojtasvoboda/oc-locationtowns-plugin
====================================

Adds towns to states managed by RainLab.Location plugin.

1.0.8(6y ago)4103[1 issues](https://github.com/vojtasvoboda/oc-locationtowns-plugin/issues)MITPHPPHP &gt;=5.4

Since Jul 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/vojtasvoboda/oc-locationtowns-plugin)[ Packagist](https://packagist.org/packages/vojtasvoboda/oc-locationtowns-plugin)[ Docs](https://github.com/vojtasvoboda/oc-locationtowns-plugin)[ RSS](/packages/vojtasvoboda-oc-locationtowns-plugin/feed)WikiDiscussions master Synced 1mo ago

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

Location Town plugin for OctoberCMS
===================================

[](#location-town-plugin-for-octobercms)

[![Codacy](https://camo.githubusercontent.com/20d2a4236b2bfa1dda4e9adb62a34aaf92faca9fb7a7b37944f982bc3d18c0aa/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f64646237653563653065313534323035386330663364393131316138383736652e737667)](https://www.codacy.com/app/vojtasvoboda/oc-locationtowns-plugin)[![Scrutinizer Coverage](https://camo.githubusercontent.com/883b8bfa3f7242599f8e25e35d2365260901fd3abc22883315803befbf4820aa/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f766f6a746173766f626f64612f6f632d6c6f636174696f6e746f776e732d706c7567696e2e737667)](https://scrutinizer-ci.com/g/vojtasvoboda/oc-locationtowns-plugin/?branch=master)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/vojtasvoboda/oc-locationtowns-plugin/blob/master/LICENSE)

Adds towns to states managed by RainLab.Location plugin. Included:

- component for state towns with pagination
- component for Town detail
- hooks for RainLab.Sitemap
- extends RainLab State model

Required plugins: RainLab.Location.

Tested with the latest stable OctoberCMS build 349.

Render Town detail
------------------

[](#render-town-detail)

This component render town detail. Just create page Town-detail with slug `/town-detail/:slug?` and insert Town component:

[![Town component](assets/images/locationtowns-component-town.png)](assets/images/locationtowns-component-town.png)

To override Town detail template just create partial file `/town/default.htm` as copy of `/plugins/vojtasvoboda/components/town/default.htm` and make own changes.

Render list of Towns
--------------------

[](#render-list-of-towns)

Create page Towns with slug `/towns/:page?` where page means paginating. Insert component Towns. Set filter for State and select page for show Town detail created above:

[![Towns component](assets/images/locationtowns-component-towns.png)](assets/images/locationtowns-component-towns.png)

To override Towns listing template just create partial file `/towns/default.htm` as copy of `/plugins/vojtasvoboda/components/towns/default.htm` and make own changes.

Add towns to sitemap
--------------------

[](#add-towns-to-sitemap)

Just install RainLab.Sitemap plugin and insert one town or all towns to sitemap:

[![Towns in sitemap](assets/images/locationtowns-sitemap-integration.png)](assets/images/locationtowns-sitemap-integration.png)

Front-end usage
---------------

[](#front-end-usage)

Following [example from Location plugin](https://github.com/rainlab/location-plugin#front-end-usage) this plugin just adds `form_select_town` function:

```
{% set countryId = countryId|default(form_value('country_id')) %}
{% set stateId = stateId|default(form_value('state_id')) %}
{% set townId = townId|default(form_value('town_id')) %}

{{ form_open() }}

        Country
        {{ form_select_country('country_id', countryId, {
            id: 'accountCountry',
            class: 'form-control',
            emptyOption: '',
            'data-request': 'onInit',
            'data-request-update': {
                'country-state': '#partialCountryState'
            }
        }) }}

        State
        {{ form_select_state('state_id', countryId, stateId, {
            id: 'accountState',
            class: 'form-control',
            emptyOption: '',
            'data-request': 'onInit',
            'data-request-update': {
                'country-state': '#partialCountryState'
            }
        }) }}

        Town
        {{ form_select_town('town_id', stateId, townId, {
            id: 'accountTown',
            class: 'form-control',
            emptyOption: ''
        }) }}

{{ form_close() }}

```

Services
--------

[](#services)

List of available services provided by plugin:

### locationtowns service

[](#locationtowns-service)

```
$towns = App::make('locationstowns');
$town = $towns->findOneBySlug('praha');
$allTowns = $towns->all();
$townsByState = $towns->where('state_id', 285)->get();

```

### RainLab State extension

[](#rainlab-state-extension)

```
$state = \RainLab\Location\Models\State::find('285');
$towns = $state->towns;

```

TODO
----

[](#todo)

- !!fix fixed URL path at Town:114 and Town:129 (there should by path set in component)
- !filter only by active states in towns component
- directly extend RainLab.Location.State form to manage towns related to this state
- run plugin without RainLab.Location (only town management)
- add select box 'country' to backend listing for filtrating states
- it is not possible to do october:down
- add import and export

**Feel free to send pullrequest!**

Contributing
------------

[](#contributing)

Please send Pull Request to master branch.

License
-------

[](#license)

LocationTown plugin is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) same as OctoberCMS platform.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1110 days

Total

2

Last Release

2480d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/533ab9a0897c6c6754ac9baf2ad6e42ecbc2a57aa67c72b885fcc647c7ae6930?d=identicon)[VojtaSvoboda](/maintainers/VojtaSvoboda)

---

Top Contributors

[![vojtasvoboda](https://avatars.githubusercontent.com/u/374917?v=4)](https://github.com/vojtasvoboda "vojtasvoboda (20 commits)")[![alvaro-canepa](https://avatars.githubusercontent.com/u/5142298?v=4)](https://github.com/alvaro-canepa "alvaro-canepa (2 commits)")

---

Tags

octobercms-pluginpluginlocationcityoctobertown

### Embed Badge

![Health badge](/badges/vojtasvoboda-oc-locationtowns-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/vojtasvoboda-oc-locationtowns-plugin/health.svg)](https://phpackages.com/packages/vojtasvoboda-oc-locationtowns-plugin)
```

###  Alternatives

[offline/oc-mall-plugin

E-commerce solution for October CMS

1744.6k2](/packages/offline-oc-mall-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
