aiphee/related-content 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aiphee/related-content

Composer 安装命令:

composer require aiphee/related-content

包简介

RelatedContent plugin for CakePHP

README 文档

README

Build Status

Related content plugin for CakePHP 3

Autocomplete Related view

This is a fast made plugin made for simple maintaining of relationships.

You can define that one entry in table has similar entries in other tables.

It also has basic element with ajax which relies on Bootstrap 3.

Please, be noted that this is not a complex plugin, there may be serious bugs, you are welcome to report or repair them.

Installation

  • Run migration from plugin or create table manually.
CREATE TABLE `related_contents` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `source_table_name` varchar(255) DEFAULT NULL COMMENT 'Table which you link from',
  `target_table_name` varchar(255) DEFAULT NULL COMMENT 'Table which you link to',
  `source_table_id` int(11) NOT NULL COMMENT 'ID of table you link from',
  `target_table_id` int(11) NOT NULL COMMENT 'ID of table you link to',
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`)
)
  • Copy repo content to plugins directory and add to your cakephp composer.json
    "autoload": {
        "psr-4": {
            "App\\": "src",
            "RelatedContent\\": "./plugins/RelatedContent/src",
        }
    }

or use packagist composer require aiphee/related-content

  • Add to your bootstrap.php
Plugin::load('RelatedContent', ['routes' => true]);

Usage

  • add first behavior to your table for it to be searchable (added to cache for search)
$this->addBehavior('RelatedContent.InRelatedIndex');
  • add second behavior which will have Similar
$this->addBehavior('RelatedContent.HasRelated', isset($config['options']) ? $config['options'] : []);
  • Add element to your view
<?= $this->element('RelatedContent.managingRelated', ['tables_to_get' => ['ContentNews', 'ContentPages']]) ?>

Parameter tables_to_get is optional, it will allow to search just in some tables.

  • To get related content with your entry, you have to pass parameter to find
$entity = $this->ContentPages->get($id, [
				'getRelated' => true
			]);
  • You can also use element in view, which model does not have HasRelated behavior, to populate some fields (target_table_name and target_table_id are directly in table)
<?= $this->element('RelatedContent.foreignTableSearch') ?>
<?= $this->Form->input('foreign_table_id', ['type' => 'hidden']) ?>
<?= $this->Form->input('foreign_table_name', ['type' => 'hidden']) ?>

It looks like this then:

Managing related without associations

aiphee/related-content 适用场景与选型建议

aiphee/related-content 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 01 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 aiphee/related-content 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aiphee/related-content 我们能提供哪些服务?
定制开发 / 二次开发

基于 aiphee/related-content 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-01-21