Getting started
Minimum requirements
- Evolution CMS 3.2.0
- PHP 8.2.0
- Composer 2.2.0
- PostgreSQL 10.23.0
- MySQL 8.0.3
- MariaDB 10.5.2
- SQLite 3.25.0
Install by artisan package
Go to You /core/ folder
cd core
Run php artisan commands
php artisan package:installrequire seiger/sgallery "*"
php artisan vendor:publish --provider="Seiger\sGallery\sGalleryServiceProvider"
php artisan migrate
Configuration
Templates for displaying gallery tabs are configured in the
../core/custom/config/seiger/settings/sGallery.php
file, where the array contains template IDs for connecting the gallery.
<?php return [1, 3, 5];
More examples in Configuration page
Usage in blade
Sow all files with Image filter:
@foreach(sGallery::collections()->get() as $item)
@if(sGallery::hasImage($item->type))
<a class="swiper-slide" @if(trim($item->link))href="{{$item->link}}"@endif>
<div class="container">
<img loading="lazy" class="intro__img" src="{{$item->src}}" alt="{{$item->alt}}" width="1440" height="456">
<div class="intro__inner">
<div class="h1__title">{{$item->title}}</div>
<p class="intro__text">{{$item->description}}</p>
@if(trim($item->link_text))<div class="btn background__mod">{{$item->link_text}}</div>@endif
</div>
</div>
</a>
@endif
@endforeach
or YouTube filter
@foreach(sGallery::collections()->get() as $item)
@if(sGallery::hasYoutube($item->type))
<div class="item">
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{$item->file}}" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<p>{{$item->title}}</p>
</div>
@endif
@endforeach
or
@foreach(sGallery::collections()->documentId($product->id)->itemType('product')->get() as $item)
<div class="swiper-slide">
<a class="js-trigger-fancybox" href="{{$item->src}}" data-fancybox="product-gallery">
<img loading="lazy" src="{{$item->src}}" width="440" height="440" />
</a>
</div>
@endforeach
More examples in Use in Blade page
Integration into the Custom Module (e.g., in sCommerce)
Integrate the sGallery package seamlessly into your project by following the examples below. These snippets demonstrate both basic and advanced usage, allowing you to customize the gallery according to your specific needs.
Basic Usage
To display a simple gallery for products, insert the following code into your module’s view:
{!!sGallery::initialiseView()->itemType('product')!!}
Explanation of Methods:
- initialiseView() - Initiates the gallery builder and prepares it for configuration. This method sets up the default settings required to render the gallery.
- itemType(‘product’) - Specifies the type of items to display in the gallery. In this case, it sets the gallery to showcase products. You can replace ‘product’ with any other item type relevant to your application.
Advanced Usage with Additional Configuration
For more customized galleries, you can chain additional methods to tailor the display according to your requirements:
{!!sGallery::initialiseView()->viewType('section')->itemType('product')->idType('i')->blockName('photo')!!}
Explanation of Methods:
- initialiseView() - Starts the gallery configuration process, setting up necessary defaults and preparing for further customization.
- viewType(‘section’) - Defines the layout or style of the gallery display. The ‘section’ view type organizes the gallery items into distinct sections. Other possible values might include ‘tab’, or ‘sectionDownloads’.
- itemType(‘product’) - Determines the category or type of items the gallery will present. Here, it specifies that products will be displayed. Modify this parameter to display different item categories as needed.
- idType(‘i’) - Sets the identifier type for retrieving and managing gallery items. The identifier ‘i’ or ‘id’ may correspond to a specific scheme or format on your system. Adjust this option according to the identifier conventions used in your application. Remember that the ‘id’ parameter is reserved for modules in Evolution CMS.
- blockName(‘photo’) - Assigns a specific block or group name to the gallery items. Using ‘photo’ groups items under this block, allowing for organized and targeted display. You can change this to other block names like ‘gallery’, ‘portfolio’, or any custom groupings you utilize.
Notes
- All methods are chainable, allowing for clean and readable configuration.
- Ensure that the parameters passed to each method align with the definitions and expectations within your application’s context.
- You can omit methods that utilize default settings if no customization is needed for those aspects.
- Explore and utilize other available methods and parameters provided by sGallery to further enhance and control your gallery’s behavior and appearance.
Extra
If you write your own code that can integrate with the sGallery plugin, you can check the presence of this plugin in the system through a configuration variable.
if (evo()->getConfig('check_sGallery', false)) {
// You code
}
If the plugin is installed, the result of evo()->getConfig('check_sGallery', false)
will always be true
. Otherwise, you will get an false
.