2017 © Pedro PelĂĄez
 

library contentful

A contentful connector for spryker.

image

fond-of-spryker/contentful

A contentful connector for spryker.

  • Wednesday, July 18, 2018
  • by daniel-rose
  • Repository
  • 2 Watchers
  • 1 Stars
  • 439 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 79 % Grown

The README.md

fond-of-spryker/contentful

license, (*1)

A Spryker-Contentful connector. Import content from contentful to storage and updates it via cronjob., (*2)

Install

composer require fond-of-spryker/contentful

1. Add twig service provider to YvesBootstrap.php in registerServiceProviders()

$this->application->register(new ContentfulTwigServiceProvider());

2. Add ContentfulRouter to YvesBootstrap.php in registerRouters()

$this->application->addRouter((new ContentfulRouter())->setSsl(false));

3. Add console command to ConsoleDependencyProvider.php in getConsoleCommands()

new ContentfulConsole(),

4. Add configs to your shop config file or in config/Shared/config_default.php

Example configuration, (*3)

// API-Key
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_ACCESS_TOKEN] = 'fu';
// Space id
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_SPACE_ID] = 'bar';
// Space default locale
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_DEFAULT_LOCALE] = 'en';
// Optional: To deactivate an entry. If Field doesn't exists entry is always shown. Default is "isActive"
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_FIELD_NAME_ACTIVE] = 'isActive';
// Optional: If entry is a page, this is the field where the url is stored. Default is "identifier"
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_FIELD_NAME_IDENTIFIER] = 'identifier';
// Mapping of contentful locales to available shop locales
$config[\FondOfSpryker\Shared\Contentful\ContentfulConstants::CONTENTFUL_LOCALE_TO_STORE_LOCALE] = [
    'en' => 'en_US',
    'de' => 'de_DE'
];

5. Add cronjob in jobs.php

Retrieve updated contentful entries every 5min., (*4)

$jobs[] = [
    'name' => 'contentful-updater',
    'command' => '$PHP_BIN vendor/bin/console contentful:import -vvv',
    'schedule' => '*/5 * * * *',
    'enable' => true,
    'run_on_non_production' => true,
    'stores' => $allStores,
];

6. Run

vendor/bin/console transfer:generate
vendor/bin/console contentful:import --all

Console commands

Import last updated entries (last 5min), (*5)

vendor/bin/console contentful:import

Import all, (*6)

vendor/bin/console contentful:import --all

Import entry by id, (*7)

vendor/bin/console contentful:import [entryId]

Usage in twig templates

Template path is Theme/default/contentful/[contentType].twig, (*8)

 {{ contentfulEntry('contentfulEntryId') }}

Access contentful properties in twig templates like the following example:, (*9)

 {{ entry.[fieldname].value }}

Markdown to html, (*10)

 {{ entry.[markdownFieldName].value | Markdown }}

Image resize, (*11)

{{ contentfulImage(entry.[assetFieldName].value, int width, int height) }}

Fields

Text (Default), (*12)

{{ entry.[assetFieldName].type }} // 'Text'
{{ entry.[assetFieldName].value }} // Value

Boolean, (*13)

{{ entry.[assetFieldName].type }} // 'Boolean'
{{ entry.[assetFieldName].value }} // Value

Asset, (*14)

{{ entry.[assetFieldName].type }} // 'Asset'
{{ entry.[assetFieldName].value }} // Url of asset
{{ entry.[assetFieldName].title }}
{{ entry.[assetFieldName].description }}

Array, (*15)

{{ entry.[assetFieldName].type }} // 'Array'
{{ entry.[assetFieldName].value }} // Array of fields

Reference, (*16)

{{ entry.[assetFieldName].type }} // 'Reference'
{{ entry.[assetFieldName].value }} // ContentfulEntryId

Object (Json) ``` {{ entry.[assetFieldName].type }} // 'Object' {{ entry.[assetFieldName].value }} // ContentfulEntryId, (*17)

Pages

  • If the contentful entry has a "Indentifier" field (URL) it will be imported as page with the given route via IdentifierImporterPlugin.
  • Add an additional ResourceCreator to add custom logic to a special contentful entry type.
  • More documentation soon

The Versions

18/07 2018

dev-master

9999999-dev

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

18/07 2018

2.1.0

2.1.0.0

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

12/07 2018

2.0.0-RC2

2.0.0.0-RC2

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

06/07 2018

2.0.0-RC1

2.0.0.0-RC1

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

23/05 2018

1.0.0-RC5

1.0.0.0-RC5

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

07/05 2018

1.0.0-RC4

1.0.0.0-RC4

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

04/05 2018

1.0.0-RC3

1.0.0.0-RC3

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

25/04 2018

1.0.0-RC2

1.0.0.0-RC2

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng

23/04 2018

1.0.0-RC1

1.0.0.0-RC1

A contentful connector for spryker.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Rose
by Markus Nörenberg
by Pascal Fischer
by Jozsef Geng