neonbug/meexo-gallery 问题修复 & 功能扩展

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

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

neonbug/meexo-gallery

Composer 安装命令:

composer require neonbug/meexo-gallery

包简介

Gallery package for Meexo CMS

README 文档

README

Use gallery images as data type in other modules

  1. Open your module's model (e.g. /Models/Shop.php) and implement \Neonbug\Gallery\Traits\GalleryImagesTraitInterface interface.

    Example:

<?php namespace App\Packages\Shop\Models;

class Shop extends \Neonbug\Common\Models\BaseModel implements \Neonbug\Gallery\Traits\GalleryImagesTraitInterface {
	
	public $gallery_images = []; // keys are id languages, then field names
	public static function getTableNameForGalleryImages() { return 'shop'; } // from GalleryImagesTraitInterface
	public static function getUploadsFolderNameForGalleryImages() { return 'shop'; } // from GalleryImagesTraitInterface
  1. Use trait \Neonbug\Gallery\Traits\GalleryImagesTrait in your module's ServiceProvider (e.g. /Providers/ServiceProvider.php.

    Example:

<?php namespace App\Packages\Shop\Providers;

class ServiceProvider extends \Neonbug\Common\Providers\BaseServiceProvider {
	
	use \Neonbug\Gallery\Traits\GalleryImagesTrait;
  1. Add a field (or multiple) with type gallery_admin::add_fields.gallery_images in your module's config file (e.g. /config/shop.php).

    Example:

<?php
return [
    ...
    'add' => [
        [
            'name' => 'images', 
            'type' => 'gallery_admin::add_fields.gallery_images', 
            'value' => '', 
        ], 
    ], 
    ...
];
  1. To load images, use getImages method on GalleryRepository. It returns a collection of GalleryImage objects.

    Example:

<?php
...
$images = App::make('\Neonbug\Gallery\Repositories\GalleryRepository')->getImages(
	'shop', // table name
	'images', // field name
	$item->id_shop, // item id
	null // language id (or null, if this field is language independent)
);
  1. To display images in views, use getPath method on GalleryImage to get the image path.

    Example:

@foreach ($images as $image)
    <?php
	$image_path = $image->getPath(
        'shop', // table name
        'images', // 
        $item->id_shop, // item id
        0 // language id (or 0, if this field is language independent)
    );
	if (!file_exists($image_path))
	{
		continue;
	}
    ?>
    <img src="{!! Croppa::url($image_path, 420, 280) !!}" />
@endforeach

License

Available under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固