How rjchauhan/rjgallery-for-octobercms works
Project type and purpose
• This is an OctoberCMS plugin (“Light Gallery Plugin”) written in PHP.
• It provides both front-end components for displaying responsive, touch-friendly photo galleries (assets + components) and back-end administration UIs (controllers + models + updates) for managing galleries and categories.
File structure
• Top level
• Plugin.php: plugin registration point in OctoberCMS
• Readme.md: feature overview & usage
• assets/: client-side CSS, JavaScript, fonts, images for the gallery UI
• components/: front-end “Gallery”, “GalleriesList”, “GallerySlug” classes + their partial templates (.htm)
• controllers/: back-end (OctoberCMS “backend” area) controllers for Galleries and Categories. Each has YAML config for list/form, toolbar partials, and HTML templates for create/edit/preview.
• models/: Eloquent-style models (Gallery.php, Category.php) plus YAML definitions of database columns and form fields
• updates/: migration scripts that create and modify DB tables (create_galleries_table.php etc.) and version.yaml
• lang/: localization files for multiple languages
README for additional insights
• Provides feature list (zoom, fullscreen, 32 transitions, mobile support, etc.)
• Shows how to include the {% gallery %} component on pages and configure its properties
• Notes the need for {% styles %}/{% scripts %} in the layout
a. Main components
• Client Browser (HTTP request, receives HTML/CSS/JS)
• OctoberCMS Core (routing, component engine, backend modules)
• Plugin Layer
– Front-end Components (Gallery, GalleriesList, GallerySlug)
– Assets (CSS/JS/Fonts/Images)
– Back-end Controllers (Categories, Galleries)
– Models (Gallery, Category)
– Database Migrations (updates/)
• Database (MySQL, Postgres, etc.)
b. Relationships and data flow
1. Browser → HTTP GET → OctoberCMS router
2. If front-end page includes [gallery] component → CMS invokes Gallery component class → component loads data from Model → Model queries DB → returns image records → component renders partial templates + injects assets → CMS compiles Twig & returns HTML + CSS + JS to browser
3. Admin user → OctoberCMS Backend → clicks “Galleries” or “Categories” menu (registered by Plugin.php) → Controller class loads YAML config for List/Form → renders backend UI → user actions (Create/Update/Delete) invoke Model → Model writes to Database
4. On plugin version change or install → CMS runs update scripts to create/modify tables
c. Architectural patterns/design principles
• MVC for both front-end components (Component class + partial view) and back-end (Controller + YAML-driven Form/Lists + Models)
• YAML-configuration for scaffolding admin UIs
• Asset bundling under plugin namespace
• Plugin modularity: self-contained migration, translations, models, controllers, components
d. Key technologies/frameworks
• OctoberCMS (Laravel based)
• PHP 7+, Twig template engine
• jQuery + custom lightgallery.js plugins
• CSS transitions (falls back to JS)
• YAML for configuration (backend lists/forms, model definitions)
• MySQL/PostgreSQL/SQLite