superrb/kunstmaan-stockists-finder

KunstmaanBundles CMS 的库存商搜索组件

0.1.1 2017-11-03 11:05 UTC

This package is auto-updated.

Last update: 2024-09-04 17:56:08 UTC


README

The KunstmaanStockistsFinderBundle 是用于添加邮编搜索,并在地图上显示库存商和他们的标记。

安装

步骤 1:安装组件

composer require superrb/kunstmaan-stockists-finder

步骤 2:启用组件

在你的项目 app/AppKernel.php 中启用该组件

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Superrb\KunstmaanStockistsFinderBundle\SuperrbKunstmaanStockistsFinderBundle(),
        );

        // ...
    }

    // ...
}

步骤 3:添加路由

将以下内容添加到你的 app/config/routes.yml

superrbkunstmaanstockistsfinderbundle_stockist_admin_list:
    resource: "@SuperrbKunstmaanStockistsFinderBundle/Controller/StockistAdminListController.php"
    type:     annotation
    prefix:   /{_locale}/admin/stockist/

如果你使用的是单语言,请记住从管理员列表路由中删除 /{_locale}/

步骤 4:生成数据库表

你可以使用 Doctrine 迁移或模式更新,任选其一

bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate

bin/console doctrine:schema:update --force

步骤 5:添加所需配置

app/config/config.yml 中开启 timestampable Doctrine 扩展

stof_doctrine_extensions:
    orm:
        default:
            timestampable: true

用法

在前端输出库存商

bin/console assets:install --symlink

加载新的 js 文件 - 将以下内容添加到 .groundcontrolrc

"footer": [
    "web/bundles/superrbkunstmaanstockistsfinder/js/stockists-finder.js",
],

添加路由

superrbkunstmaanstockistsfinderbundle_stockists_form:
    pattern: /stockistsFormSubmission
    defaults: { _controller: SuperrbKunstmaanStockistsFinderBundle:StockistsFinder:stockists }

从你的页面调用 js 函数

{% block scripts %}
    stockistsMap();
{% endblock %}

确保地图尺寸已设置

#map_wrapper {
    height: 400px;
}
#map_canvas {
    width: 100%;
    height: 100%;
}

将搜索参数添加到你的 parameters.yml

    stockistsfindersearchby:          'limit'
    stockistsfindersearchbyvalue:      '4'

你只需简单地渲染控制器操作即可在前端输出库存商列表。这也可以添加到页面部分模板中,以便有更多控制。

{{ render_esi(controller('SuperrbKunstmaanStockistsFinderBundle:StockistsFinder:stockists', { 'limit' : 12, 'template' : 'SuperrbKunstmaanStockistsFinderBundle:StockistsFinder:stockists.html.twig' } )) }}

问题和故障排除

所有问题:tech@superrb.com