lifestyle/sulu-template-api-bundle

1.2.0 2019-04-11 09:44 UTC

This package is not auto-updated.

Last update: 2020-07-30 16:28:06 UTC


README

... for the Sulu CMS.

Requirements

  • Sulu Version 1.6
  • PHP7.2

Installation

composer require lifestyle/sulu-template-api-bundle

1. add to abstract kernel app/AbstractKernel.php

abstract class AbstractKernel extends SuluKernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new LifeStyle\Sulu\TemplateApiBundle\LifeStyleSuluTemplateApiBundle(),
            ...
        ];
        ...
    }
    ...
}

2. add route app/config/website/routing.yml

life_style_api_route:
    resource: "@LifeStyleSuluTemplateApiBundle/Resources/config/routing.yml"
    prefix: /

3. add the configuration to your app/config/config.yml

life_style_sulu_template_api:
    available_languages: ['de', 'en']
    header_template: '@LifestyleSuluTemplate/templates/includes/header/header.html.twig'
    footer_template: '@LifestyleSuluTemplate/templates/includes/footer/footer.html.twig'

4. example request

GET http://your-domain.tld/{locale}/api/template.json

5. example response

{
    "scriptTimeSec": 0.5397,
    "locale": "de",
    "webspace": "sulu-webspace-name",
    "headerHtml": "some html markup",  
    "footerHtml": "some html markup"
}

good luck and have fun!