sherlockode/sylius-advanced-content-plugin

Sylius plugin for SherlockodeAdvancedContentBundle

v0.3.1 2023-11-14 13:56 UTC

This package is auto-updated.

Last update: 2024-11-11 11:52:19 UTC


README

Support

image

Table of Content

Overview

This plugin enables Sherlockode's AdvancedContentBundle on your Sylius website.

It provides advanced CMS features for end user contribution. Users can build their website pages quickly and effortlessly thanks to our intuitive interface. Several standard elements are included, such as text block, heading, image, image carousel, video player, ... Responsive layouts can be shaped as needed with row and column elements. Drafts are saved automatically and it's easy to rollback to a previous version. Custom elements can be added simply with a few lines of code.

Installation

Install the plugin with composer:

$ composer require sherlockode/sylius-advanced-content-plugin

Configuration

Import the routing configuration and Sylius configuration from the bundle

# config/sylius_acb.yaml
imports:
    - { resource: "@SherlockodeSyliusAdvancedContentPlugin/Resources/config/config.yaml" }
# config/routes/sylius_acb.yaml
sherlockode_advanced_content_bundle:
    resource: "@SherlockodeAdvancedContentBundle/Resources/config/routing/base.xml"
    prefix: '/%sylius_admin.path_name%/acb'

sherlockode_advanced_content:
    resource: "@SherlockodeSyliusAdvancedContentPlugin/Resources/config/admin_routing.yaml"
    prefix: '/%sylius_admin.path_name%/acb'

Regarding the assets, the same setup as for the standalone AdvancedContentBundle should be done.

Update your package.json with the following:

{
  "dependencies": {
    "@fortawesome/fontawesome-free": "^6.1.2",
    "jquery": "^3.5.0",
    "jquery-ui": "1.12.1"
  }
}

In the admin JS entry file from your assets, add the resources from the bundle:

// ./assets/admin/entry.js
//...
import '../../vendor/sherlockode/advanced-content-bundle/Resources/public/css/index.scss';
import '../../vendor/sherlockode/advanced-content-bundle/Resources/js/index.js';
import '../../vendor/sherlockode/sylius-advanced-content-plugin/src/Resources/public/css/index.scss';

import '@fortawesome/fontawesome-free/css/fontawesome.css';
import '@fortawesome/fontawesome-free/css/solid.css';

If you are using Webpack, you can add the following lines to your admin configuration:

// ./webpack.config.js
//...
Encore.addLoader({
    resolve: {
        alias: {
            './acb-notification.js$': path.resolve(__dirname, 'vendor/sherlockode/sylius-advanced-content-plugin/src/Resources/js/AdvancedContentBundle/acb-notification.js')
        }
    }
});

Usage

The plugin adds a new Content section in the admin menu.
It includes links to the Page grid, to the Content grid and to the Tools page.

You can checkout our documentation on the Advanced Content Bundle to learn more on how to use the plugin:

Customizing page preview

By default, the layout used to show the page previews is located at @SherlockodeSyliusAdvancedContentPlugin/Preview/preview.html.twig. You can customize this template by overriding it like any template in a third party bundle, or by replacing the sherlockode_sylius_acb.preview.view_handler service to manage different layouts depending on the page type:

services:
    sherlockode_sylius_acb.preview.view_handler:
        class: App\Acb\ViewHandler

And defining the service by yourself:

<?php

namespace App\Acb;

use Sherlockode\AdvancedContentBundle\Model\PageInterface;
use Sherlockode\AdvancedContentBundle\Model\ScopeInterface;
use Sherlockode\SyliusAdvancedContentPlugin\Preview\ViewHandlerInterface;

class ViewHandler implements ViewHandlerInterface
{
    /**
     * @param PageInterface  $page
     * @param ScopeInterface $scope
     *
     * @return string|null
     */
    public function getViewTemplate(PageInterface $page, ScopeInterface $scope): ?string
    {
        if ('homepage' === $page->getPageIdentifier()) {
            return '@SyliusShop/Acb/homepage.html.twig';
        }
        
        return '@SyliusShop/Acb/page.html.twig';
    }
}

Demo Sylius Shop

We created a demo app with some useful use-cases of plugins! Visit sylius-demo.sherlockode.fr to take a look at it. The admin can be accessed under sylius-demo.sherlockode.fr/admin/login link.
Plugins that we have used in the demo:

Additional resources for developers

To learn more about our contribution workflow and more, we encourage you to use the following resources:

License

This plugin's source code is completely free and released under the terms of the MIT license.

Contact

If you want to contact us, the best way is to fill the form on our website or send us an e-mail to contact@sherlockode.fr with your question(s). We guarantee that we answer as soon as we can!