Create New Template

To create a new template, use the following artisan command:

php artisan gp247:make-template --name=YourTemplateName --download=0

Where:

  • YourTemplateName: Your template name
  • --download=0: Create template directly in app/GP247/Templates directory
  • --download=1: Create template zip file in storage/tmp directory

GP247 Template Structure

This is the standard template for developing templates in the GP247 system. The template is designed following the MVC (Model-View-Controller) pattern and adheres to Laravel framework rules.

Directory Structure

template/
├── Admin/           # Contains admin-related files
├── Controllers/     # Contains logic handling controllers
├── Lang/           # Contains language files
├── Models/         # Contains models
├── public/         # Contains public files (css, js, images). When installed, will be copied to public/GP247/Templates/Your-template
├── Views/          # Contains view files
├── AppConfig.php   # Main template configuration file
├── config.php      # Configuration file
├── function.php    # Contains helper functions
├── gp247.json      # Template information declaration file
├── Provider.php    # Template service provider
├── Route.php       # Route definitions
└── route_front.stub # Frontend route template

Key Files

1. gp247.json

File declaring basic template information:

  • name: Template name
  • image: Template logo
  • auth: Author
  • configGroup: Configuration group
  • configCode: Configuration code
  • configKey: Configuration key, must be unique and match the template folder name
  • version: Version
  • requireCore: Compatible Gp247/Core version
  • requirePackages: Required packages from packagist.org. Default requires gp247/front
  • requireExtensions: Required GP247 extensions (plugins, templates)

2. AppConfig.php

Main template configuration file, contains methods:

  • install(): Install template
  • uninstall(): Uninstall template
  • enable(): Enable template
  • disable(): Disable template
  • setupStore(): Setup for store
  • removeStore(): Remove store setup
  • clickApp(): Handle when clicking template in admin
  • getInfo(): Get template information

3. Provider.php

Template service provider, registers services and middleware.

4. Route.php

Defines template routes.

Usage

  1. Create new template:

    • Rename directory to match template name (must match configKey value)
    • Update information in gp247.json
  2. Development:

    • Add logic to Controllers
    • Create models in Models
    • Create views in Views
    • Add languages in Lang
    • Add assets in public
  3. Installation:

Notes

  • Follow MVC structure
  • Use correct namespace
  • Ensure multilingual support
  • Check dependencies before installation
  • Handle errors and rollback when necessary
  • Ensure responsive design
  • Optimize performance and page load speed